Skip to content

Commit a6f0631

Browse files
committedJan 22, 2023
Fix :matches, :not after something matched
Related-to: syntax-tree/hast-util-select#6.
1 parent e0b90cd commit a6f0631

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
 

‎lib/pseudo.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ function has(query, node, _1, _2, state) {
133133
/** @type {SelectState} */
134134
const childState = {
135135
...state,
136+
// Not found yet.
137+
found: false,
136138
// Do walk deep.
137139
shallow: false,
138140
// One result is enough.
@@ -197,6 +199,8 @@ function matches(query, node, _1, _2, state) {
197199
/** @type {SelectState} */
198200
const childState = {
199201
...state,
202+
// Not found yet.
203+
found: false,
200204
// Do walk deep.
201205
shallow: false,
202206
// One result is enough.

‎test/all.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,17 @@ test('all together now', () => {
8484
u('c', 'Hotel')
8585
]
8686
)
87+
88+
assert.deepEqual(
89+
selectAll(
90+
'a:not([b])',
91+
u('root', [
92+
u('a', {id: 'w', b: 'a'}),
93+
u('a', {id: 'x'}),
94+
u('a', {id: 'y', b: 'a'}),
95+
u('a', {id: 'z'})
96+
])
97+
),
98+
[u('a', {id: 'x'}), u('a', {id: 'z'})]
99+
)
87100
})

0 commit comments

Comments
 (0)
Please sign in to comment.