@acemir/cssom 0.9.23 → 0.9.25
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 +2113 -1269
- package/lib/CSSConditionRule.js +3 -1
- package/lib/CSSContainerRule.js +20 -9
- package/lib/CSSCounterStyleRule.js +36 -2
- package/lib/CSSDocumentRule.js +10 -2
- package/lib/CSSFontFaceRule.js +9 -2
- package/lib/CSSGroupingRule.js +65 -9
- package/lib/CSSHostRule.js +22 -6
- package/lib/CSSImportRule.js +49 -39
- package/lib/CSSKeyframeRule.js +9 -2
- package/lib/CSSKeyframesRule.js +20 -7
- package/lib/CSSLayerBlockRule.js +20 -9
- package/lib/CSSLayerStatementRule.js +9 -5
- package/lib/CSSMediaRule.js +20 -9
- package/lib/CSSNamespaceRule.js +27 -17
- package/lib/CSSNestedDeclarations.js +9 -5
- package/lib/CSSOM.js +16 -1
- package/lib/CSSPageRule.js +11 -155
- package/lib/CSSRule.js +10 -0
- package/lib/CSSScopeRule.js +13 -5
- package/lib/CSSStartingStyleRule.js +20 -6
- package/lib/CSSStyleRule.js +11 -157
- package/lib/CSSStyleSheet.js +115 -4
- package/lib/CSSSupportsRule.js +19 -8
- package/lib/CSSValueExpression.js +3 -1
- package/lib/MediaList.js +3 -1
- package/lib/StyleSheet.js +24 -1
- package/lib/errorUtils.js +23 -16
- package/lib/index.js +2 -0
- package/lib/parse.js +1521 -784
- package/package.json +1 -1
package/lib/CSSSupportsRule.js
CHANGED
|
@@ -16,19 +16,30 @@ CSSOM.CSSSupportsRule = function CSSSupportsRule() {
|
|
|
16
16
|
CSSOM.CSSConditionRule.call(this);
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
CSSOM.CSSSupportsRule.prototype =
|
|
19
|
+
CSSOM.CSSSupportsRule.prototype = Object.create(CSSOM.CSSConditionRule.prototype);
|
|
20
20
|
CSSOM.CSSSupportsRule.prototype.constructor = CSSOM.CSSSupportsRule;
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
Object.setPrototypeOf(CSSOM.CSSSupportsRule, CSSOM.CSSConditionRule);
|
|
23
|
+
|
|
24
|
+
Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "type", {
|
|
25
|
+
value: 12,
|
|
26
|
+
writable: false
|
|
27
|
+
});
|
|
22
28
|
|
|
23
29
|
Object.defineProperty(CSSOM.CSSSupportsRule.prototype, "cssText", {
|
|
24
30
|
get: function() {
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
var values = "";
|
|
32
|
+
var valuesArr = [" {"];
|
|
33
|
+
if (this.cssRules.length) {
|
|
34
|
+
valuesArr.push(this.cssRules.reduce(function(acc, rule){
|
|
35
|
+
if (rule.cssText !== "") {
|
|
36
|
+
acc.push(rule.cssText);
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}, []).join("\n "));
|
|
29
40
|
}
|
|
30
|
-
|
|
31
|
-
return "@supports " + this.conditionText +
|
|
41
|
+
values = valuesArr.join("\n ") + "\n}";
|
|
42
|
+
return "@supports " + this.conditionText + values;
|
|
32
43
|
}
|
|
33
44
|
});
|
|
34
45
|
|
|
@@ -15,9 +15,11 @@ CSSOM.CSSValueExpression = function CSSValueExpression(token, idx) {
|
|
|
15
15
|
this._idx = idx;
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
CSSOM.CSSValueExpression.prototype =
|
|
18
|
+
CSSOM.CSSValueExpression.prototype = Object.create(CSSOM.CSSValue.prototype);
|
|
19
19
|
CSSOM.CSSValueExpression.prototype.constructor = CSSOM.CSSValueExpression;
|
|
20
20
|
|
|
21
|
+
Object.setPrototypeOf(CSSOM.CSSValueExpression, CSSOM.CSSValue);
|
|
22
|
+
|
|
21
23
|
/**
|
|
22
24
|
* parse css expression() value
|
|
23
25
|
*
|
package/lib/MediaList.js
CHANGED
|
@@ -26,7 +26,9 @@ CSSOM.MediaList.prototype = {
|
|
|
26
26
|
* @param {string} value
|
|
27
27
|
*/
|
|
28
28
|
set mediaText(value) {
|
|
29
|
-
var values = value.split(",")
|
|
29
|
+
var values = value.split(",").filter(function(text){
|
|
30
|
+
return !!text;
|
|
31
|
+
});
|
|
30
32
|
var length = this.length = values.length;
|
|
31
33
|
for (var i=0; i<length; i++) {
|
|
32
34
|
this[i] = values[i].trim();
|
package/lib/StyleSheet.js
CHANGED
|
@@ -6,15 +6,38 @@ var CSSOM = {
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @constructor
|
|
10
9
|
* @see http://dev.w3.org/csswg/cssom/#the-stylesheet-interface
|
|
11
10
|
*/
|
|
12
11
|
CSSOM.StyleSheet = function StyleSheet() {
|
|
12
|
+
this.__href = null;
|
|
13
|
+
this.__ownerNode = null;
|
|
14
|
+
this.__title = null;
|
|
13
15
|
this.__media = new CSSOM.MediaList();
|
|
14
16
|
this.__parentStyleSheet = null;
|
|
17
|
+
this.disabled = false;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
20
|
Object.defineProperties(CSSOM.StyleSheet.prototype, {
|
|
21
|
+
type: {
|
|
22
|
+
get: function() {
|
|
23
|
+
return "text/css";
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
href: {
|
|
27
|
+
get: function() {
|
|
28
|
+
return this.__href;
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
ownerNode: {
|
|
32
|
+
get: function() {
|
|
33
|
+
return this.__ownerNode;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
title: {
|
|
37
|
+
get: function() {
|
|
38
|
+
return this.__title;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
18
41
|
media: {
|
|
19
42
|
get: function() {
|
|
20
43
|
return this.__media;
|
package/lib/errorUtils.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
//.CommonJS
|
|
2
|
+
var CSSOM = {
|
|
3
|
+
getGlobalObject: require('./CSSOM').getGlobalObject
|
|
4
|
+
}
|
|
5
|
+
///CommonJS
|
|
6
|
+
|
|
1
7
|
// Utility functions for CSSOM error handling
|
|
2
8
|
|
|
3
9
|
/**
|
|
@@ -10,19 +16,8 @@
|
|
|
10
16
|
* @return {Function} The error constructor
|
|
11
17
|
*/
|
|
12
18
|
function getErrorConstructor(context, errorType) {
|
|
13
|
-
|
|
14
|
-
|
|
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];
|
|
19
|
+
if (CSSOM.getGlobalObject() && CSSOM.getGlobalObject()[errorType]) {
|
|
20
|
+
return CSSOM.getGlobalObject()[errorType];
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
// Fall back to native constructor
|
|
@@ -31,6 +26,19 @@ function getErrorConstructor(context, errorType) {
|
|
|
31
26
|
eval(errorType);
|
|
32
27
|
}
|
|
33
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Creates an appropriate error with context-aware constructor.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} context - The CSSOM object (rule, stylesheet, etc.)
|
|
33
|
+
* @param {string} errorType - The error type ('TypeError', 'RangeError', 'DOMException', etc.)
|
|
34
|
+
* @param {string} message - The error message
|
|
35
|
+
* @param {string} [name] - Optional name for DOMException
|
|
36
|
+
*/
|
|
37
|
+
function createError(context, errorType, message, name) {
|
|
38
|
+
var ErrorConstructor = getErrorConstructor(context, errorType);
|
|
39
|
+
return new ErrorConstructor(message, name);
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
/**
|
|
35
43
|
* Creates and throws an appropriate error with context-aware constructor.
|
|
36
44
|
*
|
|
@@ -40,9 +48,7 @@ function getErrorConstructor(context, errorType) {
|
|
|
40
48
|
* @param {string} [name] - Optional name for DOMException
|
|
41
49
|
*/
|
|
42
50
|
function throwError(context, errorType, message, name) {
|
|
43
|
-
|
|
44
|
-
var error = new ErrorConstructor(message, name);
|
|
45
|
-
throw error;
|
|
51
|
+
throw createError(context, errorType, message, name);
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
/**
|
|
@@ -95,6 +101,7 @@ function throwIndexError(context, methodName, objectName, index, maxIndex, name)
|
|
|
95
101
|
}
|
|
96
102
|
|
|
97
103
|
var errorUtils = {
|
|
104
|
+
createError: createError,
|
|
98
105
|
getErrorConstructor: getErrorConstructor,
|
|
99
106
|
throwError: throwError,
|
|
100
107
|
throwMissingArguments: throwMissingArguments,
|