Permalink
Browse files

Actually fix CSSOM.CSSStyleSheet.prototype.insertRule

Fixes #40
  • Loading branch information...
1 parent d0b9ee1 commit d46609dfd5b94cf5980eb987c633b2cbf9700395 @NV committed Jul 15, 2012
Showing with 13 additions and 11 deletions.
  1. +3 −1 lib/CSSStyleSheet.js
  2. +10 −10 lib/parse.js
View
@@ -40,7 +40,8 @@ CSSOM.CSSStyleSheet.prototype.insertRule = function(rule, index) {
if (index < 0 || index > this.cssRules.length) {
throw new RangeError("INDEX_SIZE_ERR");
}
- this.cssRules.splice(index, 0, require('./parse').parse(rule));
+ var cssRule = CSSOM.parse(rule).cssRules[0];
+ this.cssRules.splice(index, 0, cssRule);
return index;
};
@@ -82,4 +83,5 @@ CSSOM.CSSStyleSheet.prototype.toString = function() {
//.CommonJS
exports.CSSStyleSheet = CSSOM.CSSStyleSheet;
+CSSOM.parse = require('./parse').parse; // Cannot be included sooner due to the mutual dependency between parse.js and CSSStyleSheet.js
///CommonJS
View
@@ -1,14 +1,5 @@
//.CommonJS
-var CSSOM = {
- CSSStyleSheet: require("./CSSStyleSheet").CSSStyleSheet,
- CSSStyleRule: require("./CSSStyleRule").CSSStyleRule,
- CSSImportRule: require("./CSSImportRule").CSSImportRule,
- CSSMediaRule: require("./CSSMediaRule").CSSMediaRule,
- CSSFontFaceRule: require("./CSSFontFaceRule").CSSFontFaceRule,
- CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration,
- CSSKeyframeRule: require('./CSSKeyframeRule').CSSKeyframeRule,
- CSSKeyframesRule: require('./CSSKeyframesRule').CSSKeyframesRule
-};
+var CSSOM = {};
///CommonJS
@@ -335,4 +326,13 @@ CSSOM.parse = function parse(token) {
//.CommonJS
exports.parse = CSSOM.parse;
+// The following modules cannot be included sooner due to the mutual dependency with parse.js
+CSSOM.CSSStyleSheet = require("./CSSStyleSheet").CSSStyleSheet;
+CSSOM.CSSStyleRule = require("./CSSStyleRule").CSSStyleRule;
+CSSOM.CSSImportRule = require("./CSSImportRule").CSSImportRule;
+CSSOM.CSSMediaRule = require("./CSSMediaRule").CSSMediaRule;
+CSSOM.CSSFontFaceRule = require("./CSSFontFaceRule").CSSFontFaceRule;
+CSSOM.CSSStyleDeclaration = require('./CSSStyleDeclaration').CSSStyleDeclaration;
+CSSOM.CSSKeyframeRule = require('./CSSKeyframeRule').CSSKeyframeRule;
+CSSOM.CSSKeyframesRule = require('./CSSKeyframesRule').CSSKeyframesRule;
///CommonJS

0 comments on commit d46609d

Please sign in to comment.