@acemir/cssom 0.9.25 → 0.9.26
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 +38 -10
- package/lib/CSSStyleSheet.js +12 -3
- package/lib/MediaList.js +22 -7
- package/lib/parse.js +4 -0
- package/package.json +1 -1
package/build/CSSOM.js
CHANGED
|
@@ -800,12 +800,20 @@ CSSOM.MediaList.prototype = {
|
|
|
800
800
|
* @param {string} value
|
|
801
801
|
*/
|
|
802
802
|
set mediaText(value) {
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
803
|
+
if (typeof value === "string") {
|
|
804
|
+
var values = value.split(",").filter(function(text){
|
|
805
|
+
return !!text;
|
|
806
|
+
});
|
|
807
|
+
var length = this.length = values.length;
|
|
808
|
+
for (var i=0; i<length; i++) {
|
|
809
|
+
this[i] = values[i].trim();
|
|
810
|
+
}
|
|
811
|
+
} else if (value === null) {
|
|
812
|
+
var length = this.length;
|
|
813
|
+
for (var i = 0; i < length; i++) {
|
|
814
|
+
delete this[i];
|
|
815
|
+
}
|
|
816
|
+
this.length = 0;
|
|
809
817
|
}
|
|
810
818
|
},
|
|
811
819
|
|
|
@@ -827,8 +835,15 @@ CSSOM.MediaList.prototype = {
|
|
|
827
835
|
if (index !== -1) {
|
|
828
836
|
Array.prototype.splice.call(this, index, 1);
|
|
829
837
|
}
|
|
830
|
-
}
|
|
838
|
+
},
|
|
839
|
+
|
|
840
|
+
item: function(index) {
|
|
841
|
+
return this[index] || null;
|
|
842
|
+
},
|
|
831
843
|
|
|
844
|
+
toString: function() {
|
|
845
|
+
return this.mediaText;
|
|
846
|
+
}
|
|
832
847
|
};
|
|
833
848
|
|
|
834
849
|
|
|
@@ -1796,6 +1811,9 @@ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
|
|
|
1796
1811
|
};
|
|
1797
1812
|
|
|
1798
1813
|
CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
|
|
1814
|
+
if (index === void 0) {
|
|
1815
|
+
index = 0;
|
|
1816
|
+
}
|
|
1799
1817
|
this.deleteRule(index);
|
|
1800
1818
|
};
|
|
1801
1819
|
|
|
@@ -1813,6 +1831,12 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
|
|
|
1813
1831
|
} else {
|
|
1814
1832
|
_Promise = Promise;
|
|
1815
1833
|
}
|
|
1834
|
+
var _setTimeout;
|
|
1835
|
+
if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()['setTimeout']) {
|
|
1836
|
+
_setTimeout = CSSOM.getGlobalObject()['setTimeout'];
|
|
1837
|
+
} else {
|
|
1838
|
+
_setTimeout = setTimeout;
|
|
1839
|
+
}
|
|
1816
1840
|
var sheet = this;
|
|
1817
1841
|
return new _Promise(function (resolve, reject) {
|
|
1818
1842
|
// If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
|
|
@@ -1825,7 +1849,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
|
|
|
1825
1849
|
sheet.__disallowModification = true;
|
|
1826
1850
|
|
|
1827
1851
|
// In parallel, do these steps:
|
|
1828
|
-
|
|
1852
|
+
_setTimeout(function() {
|
|
1829
1853
|
// Let rules be the result of running parse a stylesheet's contents from text.
|
|
1830
1854
|
var rules = new CSSOM.CSSRuleList();
|
|
1831
1855
|
CSSOM.parse(text, { styleSheet: sheet, cssRules: rules });
|
|
@@ -1839,7 +1863,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
|
|
|
1839
1863
|
}
|
|
1840
1864
|
}
|
|
1841
1865
|
// Set sheet's CSS rules to rules.
|
|
1842
|
-
sheet.__cssRules
|
|
1866
|
+
sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
|
|
1843
1867
|
// Unset sheet’s disallow modification flag.
|
|
1844
1868
|
delete sheet.__disallowModification;
|
|
1845
1869
|
// Resolve promise with sheet.
|
|
@@ -1874,7 +1898,7 @@ CSSOM.CSSStyleSheet.prototype.replaceSync = function(text) {
|
|
|
1874
1898
|
}
|
|
1875
1899
|
}
|
|
1876
1900
|
// Set sheet's CSS rules to rules.
|
|
1877
|
-
sheet.__cssRules
|
|
1901
|
+
sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
|
|
1878
1902
|
}
|
|
1879
1903
|
|
|
1880
1904
|
/**
|
|
@@ -2976,6 +3000,10 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
|
|
|
2976
3000
|
|
|
2977
3001
|
if (opts && opts.ownerNode) {
|
|
2978
3002
|
styleSheet.__ownerNode = opts.ownerNode;
|
|
3003
|
+
var ownerNodeMedia = opts.ownerNode.media || (opts.ownerNode.getAttribute && opts.ownerNode.getAttribute("media"));
|
|
3004
|
+
if (ownerNodeMedia) {
|
|
3005
|
+
styleSheet.media.mediaText = ownerNodeMedia;
|
|
3006
|
+
}
|
|
2979
3007
|
}
|
|
2980
3008
|
|
|
2981
3009
|
if (opts && opts.ownerRule) {
|
package/lib/CSSStyleSheet.js
CHANGED
|
@@ -257,6 +257,9 @@ CSSOM.CSSStyleSheet.prototype.deleteRule = function(index) {
|
|
|
257
257
|
};
|
|
258
258
|
|
|
259
259
|
CSSOM.CSSStyleSheet.prototype.removeRule = function(index) {
|
|
260
|
+
if (index === void 0) {
|
|
261
|
+
index = 0;
|
|
262
|
+
}
|
|
260
263
|
this.deleteRule(index);
|
|
261
264
|
};
|
|
262
265
|
|
|
@@ -274,6 +277,12 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
|
|
|
274
277
|
} else {
|
|
275
278
|
_Promise = Promise;
|
|
276
279
|
}
|
|
280
|
+
var _setTimeout;
|
|
281
|
+
if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()['setTimeout']) {
|
|
282
|
+
_setTimeout = CSSOM.getGlobalObject()['setTimeout'];
|
|
283
|
+
} else {
|
|
284
|
+
_setTimeout = setTimeout;
|
|
285
|
+
}
|
|
277
286
|
var sheet = this;
|
|
278
287
|
return new _Promise(function (resolve, reject) {
|
|
279
288
|
// If the constructed flag is not set, or the disallow modification flag is set, throw a NotAllowedError DOMException.
|
|
@@ -286,7 +295,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
|
|
|
286
295
|
sheet.__disallowModification = true;
|
|
287
296
|
|
|
288
297
|
// In parallel, do these steps:
|
|
289
|
-
|
|
298
|
+
_setTimeout(function() {
|
|
290
299
|
// Let rules be the result of running parse a stylesheet's contents from text.
|
|
291
300
|
var rules = new CSSOM.CSSRuleList();
|
|
292
301
|
CSSOM.parse(text, { styleSheet: sheet, cssRules: rules });
|
|
@@ -300,7 +309,7 @@ CSSOM.CSSStyleSheet.prototype.replace = function(text) {
|
|
|
300
309
|
}
|
|
301
310
|
}
|
|
302
311
|
// Set sheet's CSS rules to rules.
|
|
303
|
-
sheet.__cssRules
|
|
312
|
+
sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
|
|
304
313
|
// Unset sheet’s disallow modification flag.
|
|
305
314
|
delete sheet.__disallowModification;
|
|
306
315
|
// Resolve promise with sheet.
|
|
@@ -335,7 +344,7 @@ CSSOM.CSSStyleSheet.prototype.replaceSync = function(text) {
|
|
|
335
344
|
}
|
|
336
345
|
}
|
|
337
346
|
// Set sheet's CSS rules to rules.
|
|
338
|
-
sheet.__cssRules
|
|
347
|
+
sheet.__cssRules.splice.apply(sheet.__cssRules, [0, sheet.__cssRules.length].concat(rules));
|
|
339
348
|
}
|
|
340
349
|
|
|
341
350
|
/**
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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/parse.js
CHANGED
|
@@ -81,6 +81,10 @@ CSSOM.parse = function parse(token, opts, errorHandler) {
|
|
|
81
81
|
|
|
82
82
|
if (opts && opts.ownerNode) {
|
|
83
83
|
styleSheet.__ownerNode = opts.ownerNode;
|
|
84
|
+
var ownerNodeMedia = opts.ownerNode.media || (opts.ownerNode.getAttribute && opts.ownerNode.getAttribute("media"));
|
|
85
|
+
if (ownerNodeMedia) {
|
|
86
|
+
styleSheet.media.mediaText = ownerNodeMedia;
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
if (opts && opts.ownerRule) {
|