-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: Incorrect parsing of functional pseudo class css selector #169
Conversation
This fixes a parsing issue of CSS selectors that use a functional pseudo class with multiple arguments. See the test cases
let j = 0; | ||
const len = splitSelectors.length; | ||
const finalSelectors = []; | ||
while (i < len) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic is as follows:
- Iterate through the split selectors and look for the first selector with an opening parenthesis
- If opening paren is found, look through the rest of the selectors to look for a matching number of closing parentheses
- If closing paren is found, merge together all selectors between the opening and closing
- Move iterator index to the next selector and continue
- If no closing paren is found, assume that selectors were correctly split
- If closing paren is found, merge together all selectors between the opening and closing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests are passing and comment on logic of the code makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to break it 🗡️
edit: i will check it out, and run these test suggestions to see what happens. Maybe think of more tests
edit2: huzzah! 2/3 of my suggestions break it. The first and the last .bar:has(div, input:is(:disabled), button) {}
and .bar:has(input:is(:disabled),.foo,button:is(:disabled)), .foo:has(input, button), .baz, {}
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
@ryan953 good test cases! I've updated to track the net unbalanced across each selector - however this does add another regex |
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
#169)" (#182) This reverts commit 810b39f. Reverting this in favor of rrweb-io#1401 and rrweb-io#1440 which is better than whatever it is I wrote. I kept our tests just to ensure the fix is compatible with our previous patch.
This fixes a parsing issue of CSS selectors that use a functional pseudo class with multiple arguments. For example, ``` .foo:has(button,div) {} ``` Would get parsed as 2 selectors: `.foo:has(button` and `div)` - this results in an invalid stylesheet and looks like the replay is broken. --------- Co-authored-by: Ryan Albrecht <ryan@ryanalbrecht.ca>
This fixes a parsing issue of CSS selectors that use a functional pseudo class with multiple arguments.
For example,
Would get parsed as 2 selectors:
.foo:has(button
anddiv)
- this results in an invalid stylesheet and looks like the replay is broken.