@projectwallace/css-parser 0.8.9 → 0.8.10
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/parse-atrule-prelude.js +30 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Lexer } from './tokenize.js';
|
|
2
|
-
import { CSSDataArena, PRELUDE_OPERATOR, MEDIA_TYPE, MEDIA_QUERY, MEDIA_FEATURE, IDENTIFIER, CONTAINER_QUERY, SUPPORTS_QUERY, LAYER_NAME, URL } from './arena.js';
|
|
3
|
-
import { TOKEN_COMMA, TOKEN_IDENT, TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN,
|
|
2
|
+
import { CSSDataArena, PRELUDE_OPERATOR, MEDIA_TYPE, MEDIA_QUERY, MEDIA_FEATURE, FUNCTION, IDENTIFIER, CONTAINER_QUERY, SUPPORTS_QUERY, LAYER_NAME, URL } from './arena.js';
|
|
3
|
+
import { TOKEN_COMMA, TOKEN_IDENT, TOKEN_LEFT_PAREN, TOKEN_RIGHT_PAREN, TOKEN_FUNCTION, TOKEN_EOF, TOKEN_WHITESPACE, TOKEN_URL, TOKEN_STRING } from './token-types.js';
|
|
4
4
|
import { str_equals } from './string-utils.js';
|
|
5
5
|
import { trim_boundaries, skip_whitespace_forward } from './parse-utils.js';
|
|
6
6
|
import { CSSNode } from './css-node.js';
|
|
@@ -153,6 +153,34 @@ class AtRulePreludeParser {
|
|
|
153
153
|
if (feature !== null) {
|
|
154
154
|
components.push(feature);
|
|
155
155
|
}
|
|
156
|
+
} else if (token_type === TOKEN_FUNCTION) {
|
|
157
|
+
let func_name = this.source.substring(this.lexer.token_start, this.lexer.token_end - 1);
|
|
158
|
+
let func_start = this.lexer.token_start;
|
|
159
|
+
let content_start = this.lexer.token_end;
|
|
160
|
+
let paren_depth = 1;
|
|
161
|
+
let func_end = this.lexer.token_end;
|
|
162
|
+
let content_end = content_start;
|
|
163
|
+
while (this.lexer.pos < this.prelude_end && paren_depth > 0) {
|
|
164
|
+
this.next_token();
|
|
165
|
+
let inner_token = this.lexer.token_type;
|
|
166
|
+
if (inner_token === TOKEN_LEFT_PAREN || inner_token === TOKEN_FUNCTION) {
|
|
167
|
+
paren_depth++;
|
|
168
|
+
} else if (inner_token === TOKEN_RIGHT_PAREN) {
|
|
169
|
+
paren_depth--;
|
|
170
|
+
if (paren_depth === 0) {
|
|
171
|
+
content_end = this.lexer.token_start;
|
|
172
|
+
func_end = this.lexer.token_end;
|
|
173
|
+
}
|
|
174
|
+
} else if (inner_token === TOKEN_EOF) {
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
let func_node = this.create_node(FUNCTION, func_start, func_end);
|
|
179
|
+
this.arena.set_content_start_delta(func_node, 0);
|
|
180
|
+
this.arena.set_content_length(func_node, func_name.length);
|
|
181
|
+
this.arena.set_value_start_delta(func_node, content_start - func_start);
|
|
182
|
+
this.arena.set_value_length(func_node, content_end - content_start);
|
|
183
|
+
components.push(func_node);
|
|
156
184
|
} else if (token_type === TOKEN_IDENT) {
|
|
157
185
|
let text = this.source.substring(this.lexer.token_start, this.lexer.token_end);
|
|
158
186
|
if (this.is_and_or_not(text)) {
|
package/package.json
CHANGED