Skip to content

Commit

Permalink
Fix :matches, :not after something matched
Browse files Browse the repository at this point in the history
Closes GH-6.
  • Loading branch information
wooorm committed Jan 22, 2023
1 parent a0681a0 commit 4ee85b0
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -261,6 +261,8 @@ function has(query, element, _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 @@ -344,6 +346,8 @@ function matches(query, element, _, parent, state) {
/** @type {SelectState} */
const childState = {
...state,
// Not found yet.
found: false,
// Do walk deep.
shallow: false,
// One result is enough.
Expand Down
9 changes: 9 additions & 0 deletions test/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,13 @@ test('all together now', () => {
h('dd', 'Hotel')
]
)

assert.deepEqual(
selectAll(
'a:not([class])',
u('root', [h('a#w.a'), h('a#x'), h('a#y.b'), h('a#z')])
),
[h('a#x'), h('a#z')],
'should support `:not` with multiple matches (GH-6)'
)
})

0 comments on commit 4ee85b0

Please sign in to comment.