Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [#1642] Adds support for child combinator to :has pseudo selector #1660

Conversation

capricorn86
Copy link
Owner

No description provided.

if (args[0] === '+') {
newArgs = args.replace('+', '');
} else if (args[0] === '>') {
newArgs = args.replace('>', '');

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This replaces only the first occurrence of '>'.

Copilot Autofix AI 14 days ago

To fix the problem, we need to ensure that all occurrences of the character > in the args string are replaced, not just the first one. This can be achieved by using a regular expression with the global flag (g). Specifically, we will replace args.replace('>', '') with args.replace(/>/g, '').

Suggested changeset 1
packages/happy-dom/src/query-selector/SelectorParser.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/happy-dom/src/query-selector/SelectorParser.ts b/packages/happy-dom/src/query-selector/SelectorParser.ts
--- a/packages/happy-dom/src/query-selector/SelectorParser.ts
+++ b/packages/happy-dom/src/query-selector/SelectorParser.ts
@@ -338,3 +338,3 @@
 					} else if (args[0] === '>') {
-						newArgs = args.replace('>', '');
+						newArgs = args.replace(/>/g, '');
 					}
EOF
@@ -338,3 +338,3 @@
} else if (args[0] === '>') {
newArgs = args.replace('>', '');
newArgs = args.replace(/>/g, '');
}
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@capricorn86 capricorn86 merged commit 17634e6 into master Jan 1, 2025
4 of 6 checks passed
@capricorn86 capricorn86 deleted the 1642-child-combinator-and-has-pseudo-class-doesnt-work-together branch January 1, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Child combinator and :has() pseudo class doesn't work together
1 participant