Skip to content

Commit

Permalink
Merge pull request #1193 from gdorsi/master
Browse files Browse the repository at this point in the history
#1191@patch: Support for passing pseudo-selectors as argument of :not.
  • Loading branch information
capricorn86 authored Jan 29, 2024
2 parents b6ce566 + da5bd8a commit b8bd6e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/query-selector/SelectorParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import ISelectorPseudo from './ISelectorPseudo.js';
* Group 17: Combinator.
*/
const SELECTOR_REGEXP =
/(\*)|([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;
/(\*)|([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;

/**
* Escaped Character RegExp.
Expand Down
11 changes: 11 additions & 0 deletions packages/happy-dom/test/query-selector/QuerySelector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1158,5 +1158,16 @@ describe('QuerySelector', () => {
"Failed to execute 'querySelector' on 'HTMLElement': '#1' is not a valid selector."
);
});

it('Has support for passing pseudoseletors inside :not', () => {
const div = document.createElement('div');
const child = document.createElement('div');
const child2 = document.createElement('div');

div.appendChild(child);
div.appendChild(child2);

expect(div.querySelector(':not(:nth-child(1))')).toBe(child2);
});
});
});

0 comments on commit b8bd6e1

Please sign in to comment.