-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CSSGroupingRule and CSSConditionRule
- Loading branch information
1 parent
97bee09
commit 6b6de70
Showing
9 changed files
with
134 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//.CommonJS | ||
var CSSOM = { | ||
CSSRule: require("./CSSRule").CSSRule, | ||
CSSGroupingRule: require("./CSSGroupingRule").CSSGroupingRule | ||
}; | ||
///CommonJS | ||
|
||
|
||
/** | ||
* @constructor | ||
* @see https://www.w3.org/TR/css-conditional-3/#the-cssconditionrule-interface | ||
*/ | ||
CSSOM.CSSConditionRule = function CSSConditionRule() { | ||
CSSOM.CSSGroupingRule.call(this); | ||
this.cssRules = []; | ||
}; | ||
|
||
CSSOM.CSSConditionRule.prototype = new CSSOM.CSSGroupingRule(); | ||
CSSOM.CSSConditionRule.prototype.constructor = CSSOM.CSSConditionRule; | ||
CSSOM.CSSConditionRule.prototype.conditionText = '' | ||
CSSOM.CSSConditionRule.prototype.cssText = '' | ||
|
||
//.CommonJS | ||
exports.CSSConditionRule = CSSOM.CSSConditionRule; | ||
///CommonJS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//.CommonJS | ||
var CSSOM = { | ||
CSSRule: require("./CSSRule").CSSRule | ||
}; | ||
///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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters