Skip to content

Commit ae6d66d

Browse files
committed
fix(traversing): Restrict reContextSelector to :scope
#4967 was overly broad
1 parent 1ed7173 commit ae6d66d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/api/traversing.ts

Lines changed: 2 additions & 2 deletions
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 reContextSelector = /^\s*(?:[+~]|:scope\b)/;
2828

2929
/**
3030
* Get the descendants of each element in the current set of matched elements,
@@ -83,7 +83,7 @@ export function _findBySelector<T extends AnyNode>(
8383
): Cheerio<Element> {
8484
const context = this.toArray();
8585

86-
const elems = reSiblingSelector.test(selector)
86+
const elems = reContextSelector.test(selector)
8787
? context
8888
: this.children().toArray();
8989

0 commit comments

Comments
 (0)