@acemir/cssom 0.9.25 → 0.9.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/CSSOM.js CHANGED
@@ -1,17 +1,56 @@
1
- var __globalObject = null;
2
-
3
1
  var CSSOM = {
4
- setup: function(opts) {
5
- if (opts.globalObject) {
6
- __globalObject = opts.globalObject;
7
- }
8
- },
9
- getGlobalObject: function() {
10
- return __globalObject;
2
+ /**
3
+ * Creates and configures a new CSSOM instance with the specified options.
4
+ *
5
+ * @param {Object} opts - Configuration options for the CSSOM instance
6
+ * @param {Object} [opts.globalObject] - Optional global object to be assigned to CSSOM objects prototype
7
+ * @returns {Object} A new CSSOM instance with the applied configuration
8
+ * @description
9
+ * This method creates a new instance of CSSOM and optionally
10
+ * configures CSSStyleSheet with a global object reference. When a globalObject is provided
11
+ * and CSSStyleSheet exists on the instance, it creates a new CSSStyleSheet constructor
12
+ * using a factory function and assigns the globalObject to its prototype's __globalObject property.
13
+ */
14
+ setup: function (opts) {
15
+ var instance = Object.create(this);
16
+ if (opts.globalObject) {
17
+ if (instance.CSSStyleSheet) {
18
+ const factoryCSSStyleSheet = createFunctionFactory(instance.CSSStyleSheet);
19
+ const CSSStyleSheet = factoryCSSStyleSheet();
20
+ CSSStyleSheet.prototype.__globalObject = opts.globalObject;
21
+
22
+ instance.CSSStyleSheet = CSSStyleSheet;
23
+ }
11
24
  }
25
+ return instance;
26
+ }
12
27
  };
13
28
 
29
+ function createFunctionFactory(fn) {
30
+ return function() {
31
+ // Create a new function that delegates to the original
32
+ var newFn = function() {
33
+ return fn.apply(this, arguments);
34
+ };
14
35
 
36
+ // Copy prototype chain
37
+ Object.setPrototypeOf(newFn, Object.getPrototypeOf(fn));
38
+
39
+ // Copy own properties
40
+ for (var key in fn) {
41
+ if (Object.prototype.hasOwnProperty.call(fn, key)) {
42
+ newFn[key] = fn[key];
43
+ }
44
+ }
45
+
46
+ // Clone the .prototype object for constructor-like behavior
47
+ if (fn.prototype) {
48
+ newFn.prototype = Object.create(fn.prototype);
49
+ }
50
+
51
+ return newFn;
52
+ };
53
+ }
15
54
 
16
55
 
17
56
 
@@ -27,8 +66,19 @@ var CSSOM = {
27
66
  * @return {Function} The error constructor
28
67
  */
29
68
  function getErrorConstructor(context, errorType) {
30
- if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()[errorType]) {
31
- return CSSOM.getGlobalObject()[errorType];
69
+ // Try parentStyleSheet.__globalObject first
70
+ if (context.parentStyleSheet && context.parentStyleSheet.__globalObject && context.parentStyleSheet.__globalObject[errorType]) {
71
+ return context.parentStyleSheet.__globalObject[errorType];
72
+ }
73
+
74
+ // Try __parentStyleSheet (alternative naming)
75
+ if (context.__parentStyleSheet && context.__parentStyleSheet.__globalObject && context.__parentStyleSheet.__globalObject[errorType]) {
76
+ return context.__parentStyleSheet.__globalObject[errorType];
77
+ }
78
+
79
+ // Try __globalObject on the context itself
80
+ if (context.__globalObject && context.__globalObject[errorType]) {
81
+ return context.__globalObject[errorType];
32
82
  }
33
83
 
34
84
  // Fall back to native constructor
@@ -800,12 +850,20 @@ CSSOM.MediaList.prototype = {
800
850
  * @param {string} value
801
851
  */
802
852
  set mediaText(value) {
803
- var values = value.split(",").filter(function(text){
804
- return !!text;
805
- });
806
- var length = this.length = values.length;
807
- for (var i=0; i<length; i++) {
808
- this[i] = values[i].trim();
853
+ if (typeof value === "string") {
854
+ var values = value.split(",").filter(function(text){
855
+ return !!text;
856
+ });
857
+ var length = this.length = values.length;
858
+ for (var i=0; i<length; i++) {
859
+ this[i] = values[i].trim();
860
+ }
861
+ } else if (value === null) {
862
+ var length = this.length;
863
+ for (var i = 0; i < length; i++) {
864
+ delete this[i];
865
+ }
866
+ this.length = 0;
809
867
  }
810
868
  },
811
869
 
@@ -827,8 +885,15 @@ CSSOM.MediaList.prototype = {
827
885
  if (index !== -1) {
828
886
  Array.prototype.splice.call(this, index, 1);
829
887
  }
830
- }
888
+ },
831
889
 
890
+ item: function(index) {
891
+ return this[index] || null;
892
+ },
893
+
894
+ toString: function() {
895
+ return this.mediaText;
896
+ }
832
897
  };
833
898
 
834
899
 
@@ -1796,6 +1861,9 @@ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
1796
1861
  };
1797
1862
 
1798
1863
  CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
1864
+ if (index === void 0) {
1865
+ index = 0;
1866
+ }
1799
1867
  this.deleteRule(index);
1800
1868
  };
1801
1869
 
@@ -1808,11 +1876,17 @@ CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
1808
1876
  */
1809
1877
  CSSOM.CSSStyleSheet.prototype.replace = function(text) {
1810
1878
  var _Promise;
1811
- if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()['Promise']) {
1812
- _Promise = CSSOM.getGlobalObject()['Promise'];
1879
+ if (this.__globalObject && this.__globalObject['Promise']) {
1880
+ _Promise = this.__globalObject['Promise'];
1813
1881
  } else {
1814
1882
  _Promise = Promise;
1815
1883
  }
1884
+ var _setTimeout;
1885
+ if (this.__globalObject && this.__globalObject['setTimeout']) {
1886
+ _setTimeout = this.__globalObject['setTimeout'];
1887
+ } else {
1888
+ _setTimeout = setTimeout;
1889
+ }
1816
1890
  var sheet = this;
1817
1891
  return new _Promise(function (resolve, reject) {
1818
1892
  // If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
@@ -1825,7 +1899,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
1825
1899
  sheet.__disallowModification = true;
1826
1900
 
1827
1901
  // In parallel, do these steps:
1828
- setTimeout(function() {
1902
+ _setTimeout(function() {
1829
1903
  // Let rules be the result of running parse a stylesheet's contents from text.
1830
1904
  var rules = new CSSOM.CSSRuleList();
1831
1905
  CSSOM.parse(text, { styleSheet: sheet, cssRules: rules });
@@ -1839,7 +1913,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
1839
1913
  }
1840
1914
  }
1841
1915
  // Set sheet's CSS rules to rules.
1842
- sheet.__cssRules = rules;
1916
+ sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
1843
1917
  // Unset sheet’s disallow modification flag.
1844
1918
  delete sheet.__disallowModification;
1845
1919
  // Resolve promise with sheet.
@@ -1874,7 +1948,7 @@ CSSOM.CSSStyleSheet.prototype.replaceSync = function(text) {
1874
1948
  }
1875
1949
  }
1876
1950
  // Set sheet's CSS rules to rules.
1877
- sheet.__cssRules = rules;
1951
+ sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
1878
1952
  }
1879
1953
 
1880
1954
  /**
@@ -2900,17 +2974,17 @@ Object.defineProperty(CSSOM.CSSPageRule.prototype, "cssText", {
2900
2974
 
2901
2975
 
2902
2976
  /**
2903
- * Parses a CSS string and returns a CSSOM.CSSStyleSheet object representing the parsed stylesheet.
2977
+ * Parses a CSS string and returns a `CSSStyleSheet` object representing the parsed stylesheet.
2904
2978
  *
2905
2979
  * @param {string} token - The CSS string to parse.
2906
2980
  * @param {object} [opts] - Optional parsing options.
2907
- * @param {object} [opts.globalObject] - @deprecated This property will be removed in the next release. Use CSSOM.setup({ globalObject }) instead. - An optional global object to override globals and window. Useful on jsdom webplatform tests.
2981
+ * @param {object} [opts.globalObject] - An optional global object to prioritize over the window object. Useful on jsdom webplatform tests.
2908
2982
  * @param {Element | ProcessingInstruction} [opts.ownerNode] - The owner node of the stylesheet.
2909
2983
  * @param {CSSRule} [opts.ownerRule] - The owner rule of the stylesheet.
2910
2984
  * @param {CSSOM.CSSStyleSheet} [opts.styleSheet] - Reuse a style sheet instead of creating a new one (e.g. as `parentStyleSheet`)
2911
2985
  * @param {CSSOM.CSSRuleList} [opts.cssRules] - Prepare all rules in this list instead of mutating the style sheet continually
2912
2986
  * @param {function|boolean} [errorHandler] - Optional error handler function or `true` to use `console.error`.
2913
- * @returns {CSSOM.CSSStyleSheet} The parsed CSSStyleSheet object.
2987
+ * @returns {CSSOM.CSSStyleSheet} The parsed `CSSStyleSheet` object.
2914
2988
  */
2915
2989
  CSSOM.parse = function parse(token, opts, errorHandler) {
2916
2990
  errorHandler = errorHandler === true ? (console && console.error) : errorHandler;
@@ -2959,7 +3033,11 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
2959
3033
  if (opts && opts.styleSheet) {
2960
3034
  styleSheet = opts.styleSheet;
2961
3035
  } else {
2962
- styleSheet = new CSSOM.CSSStyleSheet()
3036
+ if (opts && opts.globalObject && opts.globalObject.CSSStyleSheet) {
3037
+ styleSheet = new opts.globalObject.CSSStyleSheet();
3038
+ } else {
3039
+ styleSheet = new CSSOM.CSSStyleSheet();
3040
+ }
2963
3041
  styleSheet.__constructed = false;
2964
3042
  }
2965
3043
 
@@ -2970,12 +3048,12 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
2970
3048
  topScope = styleSheet;
2971
3049
  }
2972
3050
 
2973
- if (opts && opts.globalObject) {
2974
- CSSOM.setup({ globalObject: opts.globalObject });
2975
- }
2976
-
2977
3051
  if (opts && opts.ownerNode) {
2978
3052
  styleSheet.__ownerNode = opts.ownerNode;
3053
+ var ownerNodeMedia = opts.ownerNode.media || (opts.ownerNode.getAttribute && opts.ownerNode.getAttribute("media"));
3054
+ if (ownerNodeMedia) {
3055
+ styleSheet.media.mediaText = ownerNodeMedia;
3056
+ }
2979
3057
  }
2980
3058
 
2981
3059
  if (opts && opts.ownerRule) {
@@ -5001,6 +5079,9 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
5001
5079
  });
5002
5080
  if (isValid) {
5003
5081
  importRule = new CSSOM.CSSImportRule();
5082
+ if (opts && opts.globalObject && opts.globalObject.CSSStyleSheet) {
5083
+ importRule.styleSheet = new opts.globalObject.CSSStyleSheet();
5084
+ }
5004
5085
  importRule.__parentStyleSheet = importRule.styleSheet.__parentStyleSheet = styleSheet;
5005
5086
  importRule.parse(buffer + character);
5006
5087
  topScope.cssRules.push(importRule);
package/lib/CSSOM.js CHANGED
@@ -1,18 +1,58 @@
1
- var __globalObject = null;
2
-
3
1
  var CSSOM = {
4
- setup: function(opts) {
5
- if (opts.globalObject) {
6
- __globalObject = opts.globalObject;
7
- }
8
- },
9
- getGlobalObject: function() {
10
- return __globalObject;
2
+ /**
3
+ * Creates and configures a new CSSOM instance with the specified options.
4
+ *
5
+ * @param {Object} opts - Configuration options for the CSSOM instance
6
+ * @param {Object} [opts.globalObject] - Optional global object to be assigned to CSSOM objects prototype
7
+ * @returns {Object} A new CSSOM instance with the applied configuration
8
+ * @description
9
+ * This method creates a new instance of CSSOM and optionally
10
+ * configures CSSStyleSheet with a global object reference. When a globalObject is provided
11
+ * and CSSStyleSheet exists on the instance, it creates a new CSSStyleSheet constructor
12
+ * using a factory function and assigns the globalObject to its prototype's __globalObject property.
13
+ */
14
+ setup: function (opts) {
15
+ var instance = Object.create(this);
16
+ if (opts.globalObject) {
17
+ if (instance.CSSStyleSheet) {
18
+ const factoryCSSStyleSheet = createFunctionFactory(instance.CSSStyleSheet);
19
+ const CSSStyleSheet = factoryCSSStyleSheet();
20
+ CSSStyleSheet.prototype.__globalObject = opts.globalObject;
21
+
22
+ instance.CSSStyleSheet = CSSStyleSheet;
23
+ }
11
24
  }
25
+ return instance;
26
+ }
12
27
  };
13
28
 
29
+ function createFunctionFactory(fn) {
30
+ return function() {
31
+ // Create a new function that delegates to the original
32
+ var newFn = function() {
33
+ return fn.apply(this, arguments);
34
+ };
35
+
36
+ // Copy prototype chain
37
+ Object.setPrototypeOf(newFn, Object.getPrototypeOf(fn));
38
+
39
+ // Copy own properties
40
+ for (var key in fn) {
41
+ if (Object.prototype.hasOwnProperty.call(fn, key)) {
42
+ newFn[key] = fn[key];
43
+ }
44
+ }
45
+
46
+ // Clone the .prototype object for constructor-like behavior
47
+ if (fn.prototype) {
48
+ newFn.prototype = Object.create(fn.prototype);
49
+ }
50
+
51
+ return newFn;
52
+ };
53
+ }
54
+
14
55
  //.CommonJS
15
- exports.setup = CSSOM.setup;
16
- exports.getGlobalObject = CSSOM.getGlobalObject;
56
+ module.exports = CSSOM;
17
57
  ///CommonJS
18
58
 
@@ -1,6 +1,5 @@
1
1
  //.CommonJS
2
2
  var CSSOM = {
3
- getGlobalObject: require('./CSSOM').getGlobalObject,
4
3
  MediaList: require("./MediaList").MediaList,
5
4
  StyleSheet: require("./StyleSheet").StyleSheet,
6
5
  CSSRuleList: require("./CSSRuleList").CSSRuleList,
@@ -257,6 +256,9 @@ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
257
256
  };
258
257
 
259
258
  CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
259
+ if (index === void 0) {
260
+ index = 0;
261
+ }
260
262
  this.deleteRule(index);
261
263
  };
262
264
 
@@ -269,11 +271,17 @@ CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
269
271
  */
270
272
  CSSOM.CSSStyleSheet.prototype.replace = function(text) {
271
273
  var _Promise;
272
- if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()['Promise']) {
273
- _Promise = CSSOM.getGlobalObject()['Promise'];
274
+ if (this.__globalObject && this.__globalObject['Promise']) {
275
+ _Promise = this.__globalObject['Promise'];
274
276
  } else {
275
277
  _Promise = Promise;
276
278
  }
279
+ var _setTimeout;
280
+ if (this.__globalObject && this.__globalObject['setTimeout']) {
281
+ _setTimeout = this.__globalObject['setTimeout'];
282
+ } else {
283
+ _setTimeout = setTimeout;
284
+ }
277
285
  var sheet = this;
278
286
  return new _Promise(function (resolve, reject) {
279
287
  // If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
@@ -286,7 +294,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
286
294
  sheet.__disallowModification = true;
287
295
 
288
296
  // In parallel, do these steps:
289
- setTimeout(function() {
297
+ _setTimeout(function() {
290
298
  // Let rules be the result of running parse a stylesheet's contents from text.
291
299
  var rules = new CSSOM.CSSRuleList();
292
300
  CSSOM.parse(text, { styleSheet: sheet, cssRules: rules });
@@ -300,7 +308,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
300
308
  }
301
309
  }
302
310
  // Set sheet's CSS rules to rules.
303
- sheet.__cssRules = rules;
311
+ sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
304
312
  // Unset sheet’s disallow modification flag.
305
313
  delete sheet.__disallowModification;
306
314
  // Resolve promise with sheet.
@@ -335,7 +343,7 @@ CSSOM.CSSStyleSheet.prototype.replaceSync = function(text) {
335
343
  }
336
344
  }
337
345
  // Set sheet's CSS rules to rules.
338
- sheet.__cssRules = rules;
346
+ sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
339
347
  }
340
348
 
341
349
  /**
package/lib/MediaList.js CHANGED
@@ -26,12 +26,20 @@ CSSOM.MediaList.prototype = {
26
26
  * @param {string} value
27
27
  */
28
28
  set mediaText(value) {
29
- var values = value.split(",").filter(function(text){
30
- return !!text;
31
- });
32
- var length = this.length = values.length;
33
- for (var i=0; i<length; i++) {
34
- this[i] = values[i].trim();
29
+ if (typeof value === "string") {
30
+ var values = value.split(",").filter(function(text){
31
+ return !!text;
32
+ });
33
+ var length = this.length = values.length;
34
+ for (var i=0; i<length; i++) {
35
+ this[i] = values[i].trim();
36
+ }
37
+ } else if (value === null) {
38
+ var length = this.length;
39
+ for (var i = 0; i < length; i++) {
40
+ delete this[i];
41
+ }
42
+ this.length = 0;
35
43
  }
36
44
  },
37
45
 
@@ -53,8 +61,15 @@ CSSOM.MediaList.prototype = {
53
61
  if (index !== -1) {
54
62
  Array.prototype.splice.call(this, index, 1);
55
63
  }
56
- }
64
+ },
57
65
 
66
+ item: function(index) {
67
+ return this[index] || null;
68
+ },
69
+
70
+ toString: function() {
71
+ return this.mediaText;
72
+ }
58
73
  };
59
74
 
60
75
 
package/lib/errorUtils.js CHANGED
@@ -1,9 +1,3 @@
1
- //.CommonJS
2
- var CSSOM = {
3
- getGlobalObject: require('./CSSOM').getGlobalObject
4
- }
5
- ///CommonJS
6
-
7
1
  // Utility functions for CSSOM error handling
8
2
 
9
3
  /**
@@ -16,8 +10,19 @@ var CSSOM = {
16
10
  * @return {Function} The error constructor
17
11
  */
18
12
  function getErrorConstructor(context, errorType) {
19
- if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()[errorType]) {
20
- return CSSOM.getGlobalObject()[errorType];
13
+ // Try parentStyleSheet.__globalObject first
14
+ if (context.parentStyleSheet && context.parentStyleSheet.__globalObject && context.parentStyleSheet.__globalObject[errorType]) {
15
+ return context.parentStyleSheet.__globalObject[errorType];
16
+ }
17
+
18
+ // Try __parentStyleSheet (alternative naming)
19
+ if (context.__parentStyleSheet && context.__parentStyleSheet.__globalObject && context.__parentStyleSheet.__globalObject[errorType]) {
20
+ return context.__parentStyleSheet.__globalObject[errorType];
21
+ }
22
+
23
+ // Try __globalObject on the context itself
24
+ if (context.__globalObject && context.__globalObject[errorType]) {
25
+ return context.__globalObject[errorType];
21
26
  }
22
27
 
23
28
  // Fall back to native constructor
package/lib/parse.js CHANGED
@@ -1,21 +1,19 @@
1
1
  //.CommonJS
2
- var CSSOM = {
3
- setup: require('./CSSOM').setup
4
- };
2
+ var CSSOM = {};
5
3
  ///CommonJS
6
4
 
7
5
  /**
8
- * Parses a CSS string and returns a CSSOM.CSSStyleSheet object representing the parsed stylesheet.
6
+ * Parses a CSS string and returns a `CSSStyleSheet` object representing the parsed stylesheet.
9
7
  *
10
8
  * @param {string} token - The CSS string to parse.
11
9
  * @param {object} [opts] - Optional parsing options.
12
- * @param {object} [opts.globalObject] - @deprecated This property will be removed in the next release. Use CSSOM.setup({ globalObject }) instead. - An optional global object to override globals and window. Useful on jsdom webplatform tests.
10
+ * @param {object} [opts.globalObject] - An optional global object to prioritize over the window object. Useful on jsdom webplatform tests.
13
11
  * @param {Element | ProcessingInstruction} [opts.ownerNode] - The owner node of the stylesheet.
14
12
  * @param {CSSRule} [opts.ownerRule] - The owner rule of the stylesheet.
15
13
  * @param {CSSOM.CSSStyleSheet} [opts.styleSheet] - Reuse a style sheet instead of creating a new one (e.g. as `parentStyleSheet`)
16
14
  * @param {CSSOM.CSSRuleList} [opts.cssRules] - Prepare all rules in this list instead of mutating the style sheet continually
17
15
  * @param {function|boolean} [errorHandler] - Optional error handler function or `true` to use `console.error`.
18
- * @returns {CSSOM.CSSStyleSheet} The parsed CSSStyleSheet object.
16
+ * @returns {CSSOM.CSSStyleSheet} The parsed `CSSStyleSheet` object.
19
17
  */
20
18
  CSSOM.parse = function parse(token, opts, errorHandler) {
21
19
  errorHandler = errorHandler === true ? (console && console.error) : errorHandler;
@@ -64,7 +62,11 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
64
62
  if (opts && opts.styleSheet) {
65
63
  styleSheet = opts.styleSheet;
66
64
  } else {
67
- styleSheet = new CSSOM.CSSStyleSheet()
65
+ if (opts && opts.globalObject && opts.globalObject.CSSStyleSheet) {
66
+ styleSheet = new opts.globalObject.CSSStyleSheet();
67
+ } else {
68
+ styleSheet = new CSSOM.CSSStyleSheet();
69
+ }
68
70
  styleSheet.__constructed = false;
69
71
  }
70
72
 
@@ -75,12 +77,12 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
75
77
  topScope = styleSheet;
76
78
  }
77
79
 
78
- if (opts && opts.globalObject) {
79
- CSSOM.setup({ globalObject: opts.globalObject });
80
- }
81
-
82
80
  if (opts && opts.ownerNode) {
83
81
  styleSheet.__ownerNode = opts.ownerNode;
82
+ var ownerNodeMedia = opts.ownerNode.media || (opts.ownerNode.getAttribute && opts.ownerNode.getAttribute("media"));
83
+ if (ownerNodeMedia) {
84
+ styleSheet.media.mediaText = ownerNodeMedia;
85
+ }
84
86
  }
85
87
 
86
88
  if (opts && opts.ownerRule) {
@@ -2106,6 +2108,9 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
2106
2108
  });
2107
2109
  if (isValid) {
2108
2110
  importRule = new CSSOM.CSSImportRule();
2111
+ if (opts && opts.globalObject && opts.globalObject.CSSStyleSheet) {
2112
+ importRule.styleSheet = new opts.globalObject.CSSStyleSheet();
2113
+ }
2109
2114
  importRule.__parentStyleSheet = importRule.styleSheet.__parentStyleSheet = styleSheet;
2110
2115
  importRule.parse(buffer + character);
2111
2116
  topScope.cssRules.push(importRule);
@@ -2480,9 +2485,5 @@ CSSOM.CSSLayerBlockRule = require("./CSSLayerBlockRule").CSSLayerBlockRule;
2480
2485
  CSSOM.CSSLayerStatementRule = require("./CSSLayerStatementRule").CSSLayerStatementRule;
2481
2486
  CSSOM.CSSPageRule = require("./CSSPageRule").CSSPageRule;
2482
2487
  // Use cssstyle if available
2483
- try {
2484
- CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
2485
- } catch (e) {
2486
- // ignore
2487
- }
2488
+ require("./cssstyleTryCatchBlock");
2488
2489
  ///CommonJS
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "parser",
8
8
  "styleSheet"
9
9
  ],
10
- "version": "0.9.25",
10
+ "version": "0.9.27",
11
11
  "author": "Nikita Vasilyev <me@elv1s.ru>",
12
12
  "contributors": [
13
13
  "Acemir Sousa Mendes <acemirsm@gmail.com>"