Skip to content

Commit

Permalink
capricorn86#686@patch: Fixed infinite loop bug when there is no numbe…
Browse files Browse the repository at this point in the history
…r before 'n'.
  • Loading branch information
takaya1992 committed Jan 5, 2023
1 parent a54feaf commit 43a5017
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/query-selector/SelectorItem.ts
Expand Up @@ -170,7 +170,7 @@ export default class SelectorItem {
} else if (place.includes('n')) {
const [a, b] = place.replace(/ /g, '').split('n');
const childIndex = children.indexOf(element);
const aNumber = Number(a);
const aNumber = a !== '' ? Number(a) : 1;
const bNumber = b !== undefined ? Number(b) : 0;
if (isNaN(aNumber) || isNaN(bNumber)) {
throw new DOMException(`The selector "${this.selector}" is not valid.`);
Expand Down

0 comments on commit 43a5017

Please sign in to comment.