Skip to content

Commit 8f95f59

Browse files
author
Guido D'Orsi
committed
#1191@patch: Support for passing pseudo-selectors as argument of :not.
1 parent 9a0062b commit 8f95f59

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
@@ -1126,5 +1126,16 @@ describe('QuerySelector', () => {
11261126
expect(element === div.children[0]).toBe(true);
11271127
expect(element2 === div.children[0]).toBe(true);
11281128
});
1129+
1130+
it('Has support for passing pseudoseletors inside :not', () => {
1131+
const div = document.createElement('div');
1132+
const child = document.createElement('div');
1133+
const child2 = document.createElement('div');
1134+
1135+
div.appendChild(child);
1136+
div.appendChild(child2);
1137+
1138+
expect(div.querySelector(':not(:nth-child(1))')).toBe(child2);
1139+
});
11291140
});
11301141
});

0 commit comments

Comments
 (0)