Skip to content

Commit

Permalink
Fix :matches, :not after something matched
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jan 22, 2023
1 parent e0b90cd commit a6f0631
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pseudo.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ function has(query, node, _1, _2, state) {
/** @type {SelectState} */
const childState = {
...state,
// Not found yet.
found: false,
// Do walk deep.
shallow: false,
// One result is enough.
Expand Down Expand Up @@ -197,6 +199,8 @@ function matches(query, node, _1, _2, state) {
/** @type {SelectState} */
const childState = {
...state,
// Not found yet.
found: false,
// Do walk deep.
shallow: false,
// One result is enough.
Expand Down
13 changes: 13 additions & 0 deletions test/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,17 @@ test('all together now', () => {
u('c', 'Hotel')
]
)

assert.deepEqual(
selectAll(
'a:not([b])',
u('root', [
u('a', {id: 'w', b: 'a'}),
u('a', {id: 'x'}),
u('a', {id: 'y', b: 'a'}),
u('a', {id: 'z'})
])
),
[u('a', {id: 'x'}), u('a', {id: 'z'})]
)
})

0 comments on commit a6f0631

Please sign in to comment.