Skip to content

Commit 646df1f

Browse files
committed
actually use @projectwallace/css-parser
1 parent 457e119 commit 646df1f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

package-lock.json

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

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,8 @@
5454
"useTabs": true,
5555
"printWidth": 140,
5656
"singleQuote": true
57+
},
58+
"dependencies": {
59+
"@projectwallace/css-parser": "^0.1.0"
5760
}
5861
}

src/index.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TreeNode } from './TreeNode.js'
2-
import { NODE_AT_RULE, NODE_PRELUDE_IMPORT_LAYER, NODE_PRELUDE_LAYER_NAME, parse, walk_enter_leave } from '../../css-parser/dist/index.js'
2+
import { NODE_AT_RULE, NODE_PRELUDE_IMPORT_LAYER, NODE_PRELUDE_LAYER_NAME, parse, walk_enter_leave } from '@projectwallace/css-parser'
33

44
/** @param {string} name */
55
function get_layer_names(name) {
@@ -24,9 +24,7 @@ export function layer_tree_from_ast(ast) {
2424
if (node.type !== NODE_AT_RULE) return
2525

2626
if (node.name === 'layer') {
27-
let has_prelude = node.has_children && node.children.some((c) => c.type === NODE_PRELUDE_LAYER_NAME)
28-
29-
if (!has_prelude) {
27+
if (!node.has_prelude) {
3028
let name = get_anonymous_id()
3129
root.add_child(current_stack, name, {
3230
line: node.line,
@@ -85,8 +83,7 @@ export function layer_tree_from_ast(ast) {
8583
if (node.type !== NODE_AT_RULE) return
8684

8785
if (node.name === 'layer') {
88-
let has_prelude = node.has_children && node.children.some((c) => c.type === NODE_PRELUDE_LAYER_NAME)
89-
if (has_prelude) {
86+
if (node.has_prelude) {
9087
let has_block = node.has_children && node.children.some((c) => c.type !== NODE_PRELUDE_LAYER_NAME)
9188
if (has_block) {
9289
let name = node.children.find((child) => child.type === NODE_PRELUDE_LAYER_NAME)

0 commit comments

Comments
 (0)