Sha256: 607493f62b655203edb330a4c42f7f05b905d4826388b6139b8bb9a774212d92

Contents?: true

Size: 1.88 KB

Versions: 26

Compression:

Stored size: 1.88 KB

Contents

//.CommonJS
var CSSOM = {
	CSSRule: require("./CSSRule").CSSRule,
	parse: require('./parse').parse
};
///CommonJS


/**
 * @constructor
 * @see https://drafts.csswg.org/cssom/#the-cssgroupingrule-interface
 */
CSSOM.CSSGroupingRule = function CSSGroupingRule() {
	CSSOM.CSSRule.call(this);
	this.cssRules = [];
};

CSSOM.CSSGroupingRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSGroupingRule.prototype.constructor = CSSOM.CSSGroupingRule;


/**
 * Used to insert a new CSS rule to a list of CSS rules.
 *
 * @example
 *   cssGroupingRule.cssText
 *   -> "body{margin:0;}"
 *   cssGroupingRule.insertRule("img{border:none;}", 1)
 *   -> 1
 *   cssGroupingRule.cssText
 *   -> "body{margin:0;}img{border:none;}"
 *
 * @param {string} rule
 * @param {number} [index]
 * @see https://www.w3.org/TR/cssom-1/#dom-cssgroupingrule-insertrule
 * @return {number} The index within the grouping rule's collection of the newly inserted rule.
 */
 CSSOM.CSSGroupingRule.prototype.insertRule = function insertRule(rule, index) {
	if (index < 0 || index > this.cssRules.length) {
		throw new RangeError("INDEX_SIZE_ERR");
	}
	var cssRule = CSSOM.parse(rule).cssRules[0];
	cssRule.parentRule = this;
	this.cssRules.splice(index, 0, cssRule);
	return index;
};

/**
 * Used to delete a rule from the grouping rule.
 *
 *   cssGroupingRule.cssText
 *   -> "img{border:none;}body{margin:0;}"
 *   cssGroupingRule.deleteRule(0)
 *   cssGroupingRule.cssText
 *   -> "body{margin:0;}"
 *
 * @param {number} index within the grouping rule's rule list of the rule to remove.
 * @see https://www.w3.org/TR/cssom-1/#dom-cssgroupingrule-deleterule
 */
 CSSOM.CSSGroupingRule.prototype.deleteRule = function deleteRule(index) {
	if (index < 0 || index >= this.cssRules.length) {
		throw new RangeError("INDEX_SIZE_ERR");
	}
	this.cssRules.splice(index, 1)[0].parentRule = null;
};

//.CommonJS
exports.CSSGroupingRule = CSSOM.CSSGroupingRule;
///CommonJS

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/rrweb-cssom/lib/CSSGroupingRule.js