@projectwallace/css-parser 0.7.1 → 0.7.2
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/dist/css-node.js +20 -1
- package/package.json +1 -1
package/dist/css-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DIMENSION, NUMBER, DECLARATION, FLAG_IMPORTANT, FLAG_VENDOR_PREFIXED, FLAG_HAS_ERROR, FLAG_HAS_BLOCK, FLAG_HAS_DECLARATIONS, STYLE_RULE, BLOCK, AT_RULE, COMMENT, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, FLAG_HAS_PARENS, NTH_SELECTOR, NTH_OF_SELECTOR, SELECTOR_LIST, SELECTOR, COMBINATOR, ATTRIBUTE_SELECTOR, PRELUDE_OPERATOR, LAYER_NAME, SUPPORTS_QUERY, CONTAINER_QUERY, MEDIA_TYPE, MEDIA_FEATURE, MEDIA_QUERY, LANG_SELECTOR, NESTING_SELECTOR, UNIVERSAL_SELECTOR, ID_SELECTOR, CLASS_SELECTOR, TYPE_SELECTOR,
|
|
1
|
+
import { URL, STRING, DIMENSION, NUMBER, DECLARATION, FLAG_IMPORTANT, FLAG_VENDOR_PREFIXED, FLAG_HAS_ERROR, FLAG_HAS_BLOCK, FLAG_HAS_DECLARATIONS, STYLE_RULE, BLOCK, AT_RULE, COMMENT, PSEUDO_CLASS_SELECTOR, PSEUDO_ELEMENT_SELECTOR, FLAG_HAS_PARENS, NTH_SELECTOR, NTH_OF_SELECTOR, SELECTOR_LIST, SELECTOR, COMBINATOR, ATTRIBUTE_SELECTOR, PRELUDE_OPERATOR, LAYER_NAME, SUPPORTS_QUERY, CONTAINER_QUERY, MEDIA_TYPE, MEDIA_FEATURE, MEDIA_QUERY, LANG_SELECTOR, NESTING_SELECTOR, UNIVERSAL_SELECTOR, ID_SELECTOR, CLASS_SELECTOR, TYPE_SELECTOR, PARENTHESIS, OPERATOR, FUNCTION, HASH, IDENTIFIER, STYLESHEET } from './arena.js';
|
|
2
2
|
import { is_whitespace, CHAR_MINUS_HYPHEN, CHAR_PLUS } from './string-utils.js';
|
|
3
3
|
import { parse_dimension } from './parse-utils.js';
|
|
4
4
|
|
|
@@ -82,7 +82,26 @@ class CSSNode {
|
|
|
82
82
|
// Get the value text (for declarations: "blue" in "color: blue")
|
|
83
83
|
// For dimension/number nodes: returns the numeric value as a number
|
|
84
84
|
// For string nodes: returns the string content without quotes
|
|
85
|
+
// For URL nodes with quoted string: returns the string with quotes (consistent with STRING node)
|
|
86
|
+
// For URL nodes with unquoted URL: returns the URL content without quotes
|
|
85
87
|
get value() {
|
|
88
|
+
if (this.type === URL) {
|
|
89
|
+
const firstChild = this.first_child;
|
|
90
|
+
if (firstChild && firstChild.type === STRING) {
|
|
91
|
+
return firstChild.text;
|
|
92
|
+
}
|
|
93
|
+
const text = this.text;
|
|
94
|
+
if (text.startsWith("url(")) {
|
|
95
|
+
const openParen = text.indexOf("(");
|
|
96
|
+
const closeParen = text.lastIndexOf(")");
|
|
97
|
+
if (openParen !== -1 && closeParen !== -1 && closeParen > openParen) {
|
|
98
|
+
let content = text.substring(openParen + 1, closeParen).trim();
|
|
99
|
+
return content;
|
|
100
|
+
}
|
|
101
|
+
} else if (text.startsWith('"') || text.startsWith("'")) {
|
|
102
|
+
return text;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
86
105
|
if (this.type === DIMENSION || this.type === NUMBER) {
|
|
87
106
|
return parse_dimension(this.text).value;
|
|
88
107
|
}
|
package/package.json
CHANGED