Skip to content

Commit

Permalink
capricorn86#792@minor: Handle special pseudo selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Feb 25, 2023
1 parent 34395ae commit e995b0d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/happy-dom/src/query-selector/QuerySelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,17 @@ export default class QuerySelector {
}

if (parts.length > 0) {
groups.push(parts);
// Handle special pseudo-class selectors, such as: nth-child(2n + 1)
const newParts = [];
for (let i = 0; i < parts.length; i++) {
if (parts[i].includes('(') && parts[i + 1] === '+' && parts[i + 2].includes(')')) {
newParts.push(parts[i] + parts[i + 1] + parts[i + 2]);
i += 2;
} else {
newParts.push(parts[i]);
}
}
groups.push(newParts);
}

return groups;
Expand Down

0 comments on commit e995b0d

Please sign in to comment.