Skip to content

Commit 1ed7173

Browse files
authored
feat(traversing): allow : selectors in find (#4967)
1 parent 4fc2bef commit 1ed7173

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/api/traversing.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ describe('$(...)', () => {
9191
expect(q('.a').find('~.a')).toHaveLength(0);
9292
});
9393

94+
it('should find self', () => {
95+
const q = load('<p class=a></p>');
96+
expect(q('.a').find(':scope')).toHaveLength(1);
97+
});
98+
9499
it('should query case-sensitively when in xml mode', () => {
95100
const q = load('<caseSenSitive allTheWay>', { xml: true });
96101
expect(q('caseSenSitive')).toHaveLength(1);

src/api/traversing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
uniqueSort,
2525
} from 'domutils';
2626
import type { FilterFunction, AcceptedFilters } from '../types.js';
27-
const reSiblingSelector = /^\s*[+~]/;
27+
const reSiblingSelector = /^\s*[+~:]/;
2828

2929
/**
3030
* Get the descendants of each element in the current set of matched elements,

0 commit comments

Comments
 (0)