fix(selector): SelectorMatcher match elements with :not selector (#12977)
This commit is contained in:
parent
f0b0762f4a
commit
9a8423da36
|
@ -297,12 +297,12 @@ export class SelectorMatcher {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let selectables = map.get(name);
|
let selectables: SelectorContext[] = map.get(name) || [];
|
||||||
const starSelectables = map.get('*');
|
const starSelectables: SelectorContext[] = map.get('*');
|
||||||
if (starSelectables) {
|
if (starSelectables) {
|
||||||
selectables = selectables.concat(starSelectables);
|
selectables = selectables.concat(starSelectables);
|
||||||
}
|
}
|
||||||
if (!selectables) {
|
if (selectables.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let selectable: SelectorContext;
|
let selectable: SelectorContext;
|
||||||
|
|
|
@ -223,6 +223,11 @@ export function main() {
|
||||||
expect(matched).toEqual([s1[0], 1, s2[0], 2, s3[0], 3, s4[0], 4]);
|
expect(matched).toEqual([s1[0], 1, s2[0], 2, s3[0], 3, s4[0], 4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should match * with :not selector', () => {
|
||||||
|
matcher.addSelectables(CssSelector.parse(':not([a])'), 1);
|
||||||
|
expect(matcher.match(CssSelector.parse('div')[0], () => {})).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
it('should match with multiple :not selectors', () => {
|
it('should match with multiple :not selectors', () => {
|
||||||
matcher.addSelectables(s1 = CssSelector.parse('div:not([a]):not([b])'), 1);
|
matcher.addSelectables(s1 = CssSelector.parse('div:not([a]):not([b])'), 1);
|
||||||
expect(matcher.match(CssSelector.parse('div[a]')[0], selectableCollector)).toBe(false);
|
expect(matcher.match(CssSelector.parse('div[a]')[0], selectableCollector)).toBe(false);
|
||||||
|
|
Loading…
Reference in New Issue