Skip to content

Commit c9c23fc

Browse files
authored
deps: update css-parser to 0.13.0 (#146)
1 parent 061f7aa commit c9c23fc

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

index.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo
139139
let parts = []
140140
for (let node of nodes) {
141141
if (node.type === NODE.FUNCTION) {
142-
let fn = node.name.toLowerCase()
142+
let fn = node.name?.toLowerCase()
143143
parts.push(fn, OPEN_PARENTHESES)
144144
parts.push(print_list(node.children))
145145
parts.push(CLOSE_PARENTHESES)
@@ -192,7 +192,7 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo
192192
important.push(OPTIONAL_SPACE, text.slice(start, end).toLowerCase())
193193
}
194194
let value = print_value(node.value as CSSNode[] | null)
195-
let property = node.property
195+
let property = node.property!
196196

197197
// Special case for `font` shorthand: remove whitespace around /
198198
if (property === 'font') {
@@ -262,9 +262,11 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo
262262
}
263263

264264
function print_simple_selector(node: CSSNode, is_first: boolean = false): string {
265+
let name = node.name ?? ''
266+
265267
switch (node.type) {
266268
case NODE.TYPE_SELECTOR: {
267-
return node.name.toLowerCase()
269+
return name.toLowerCase() ?? ''
268270
}
269271

270272
case NODE.COMBINATOR: {
@@ -280,7 +282,7 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo
280282
case NODE.PSEUDO_ELEMENT_SELECTOR:
281283
case NODE.PSEUDO_CLASS_SELECTOR: {
282284
let parts = [COLON]
283-
let name = node.name.toLowerCase()
285+
name = name.toLowerCase()
284286

285287
// Legacy pseudo-elements or actual pseudo-elements use double colon
286288
if (name === 'before' || name === 'after' || node.type === NODE.PSEUDO_ELEMENT_SELECTOR) {
@@ -305,7 +307,7 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo
305307
}
306308

307309
case NODE.ATTRIBUTE_SELECTOR: {
308-
let parts = [OPEN_BRACKET, node.name.toLowerCase()]
310+
let parts = [OPEN_BRACKET, name.toLowerCase()]
309311

310312
if (node.attr_operator) {
311313
parts.push(print_attribute_selector_operator(node.attr_operator))
@@ -507,7 +509,7 @@ export function format(css: string, { minify = false, tab_size = undefined }: Fo
507509

508510
function print_atrule(node: CSSNode): string {
509511
let lines = []
510-
let name = [`@`, node.name.toLowerCase()]
512+
let name = [`@`, node.name!.toLowerCase()]
511513
if (node.prelude) {
512514
name.push(SPACE, print_atrule_prelude(node.prelude.text))
513515
}

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@
6060
"singleQuote": true
6161
},
6262
"dependencies": {
63-
"@projectwallace/css-parser": "^0.12.3"
63+
"@projectwallace/css-parser": "^0.13.0"
6464
}
6565
}

0 commit comments

Comments
 (0)