Skip to content

Commit 6a55f26

Browse files
author
Guido D'Orsi
committed
#1191@patch: Support for passing pseudo-selectors as argument of :not.
1 parent 52487a2 commit 6a55f26

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/happy-dom/src/query-selector/SelectorParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import ISelectorPseudo from './ISelectorPseudo.js';
2525
* Group 17: Combinator.
2626
*/
2727
const SELECTOR_REGEXP =
28-
/(\*)|([a-zA-Z0-9-]+)|#((?:[a-zA-Z0-9-_]|\\.)+)|\.((?:[a-zA-Z0-9-_]|\\.)+)|\[([a-zA-Z0-9-_]+)\]|\[([a-zA-Z0-9-_]+) *([~|^$*]{0,1}) *= *["']{1}([^"']*)["']{1} *(s|i){0,1}\]|\[([a-zA-Z0-9-_]+) *([~|^$*]{0,1}) *= *([^\]]*)\]|:([a-zA-Z-]+) *\(([^)]+)\)|:([a-zA-Z-]+)|::([a-zA-Z-]+)|([ ,+>]*)/g;
28+
/(\*)|([a-zA-Z0-9-]+)|#((?:[a-zA-Z0-9-_]|\\.)+)|\.((?:[a-zA-Z0-9-_]|\\.)+)|\[([a-zA-Z0-9-_]+)\]|\[([a-zA-Z0-9-_]+) *([~|^$*]{0,1}) *= *["']{1}([^"']*)["']{1} *(s|i){0,1}\]|\[([a-zA-Z0-9-_]+) *([~|^$*]{0,1}) *= *([^\]]*)\]|:([a-zA-Z-]+) *\(([^)]+\)?)\)|:([a-zA-Z-]+)|::([a-zA-Z-]+)|([ ,+>]*)/g;
2929

3030
/**
3131
* Escaped Character RegExp.

packages/happy-dom/test/query-selector/QuerySelector.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -1158,5 +1158,16 @@ describe('QuerySelector', () => {
11581158
"Failed to execute 'querySelector' on 'HTMLElement': '#1' is not a valid selector."
11591159
);
11601160
});
1161+
1162+
it('Has support for passing pseudoseletors inside :not', () => {
1163+
const div = document.createElement('div');
1164+
const child = document.createElement('div');
1165+
const child2 = document.createElement('div');
1166+
1167+
div.appendChild(child);
1168+
div.appendChild(child2);
1169+
1170+
expect(div.querySelector(':not(:nth-child(1))')).toBe(child2);
1171+
});
11611172
});
11621173
});

0 commit comments

Comments
 (0)