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

Fix for #1379 #1380

Closed
wants to merge 2 commits into from
Closed

Fix for #1379 #1380

wants to merge 2 commits into from

Conversation

dengelke
Copy link
Contributor

@dengelke dengelke commented Jan 2, 2024

Checks if parentheses are balanced for the selectors

Copy link

changeset-bot bot commented Jan 2, 2024

⚠️ No Changeset found

Latest commit: 17c58fa

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Juice10
Copy link
Contributor

Juice10 commented Jan 5, 2024

Hi @dengelke, thanks for identifying this issue and creating a fix for it. I was looking through the code and I think this isn't error proof yet unfortunately.
It is possible to add all kinds of parentheses inside strings in attribute matchers https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors so that would fail for this test case:

    it('check that parentheses are balanced and ignore parentheses inside strings', () => {
       const cssText = 'a:not(a[data-selector="("]):not(:disabled, div:not(.fit-content)) { border-color: rgb(84, 84, 84); }';
       expect(addHoverClass(cssText, cache)).toEqual(cssText);
     });

@dengelke
Copy link
Contributor Author

dengelke commented Jan 6, 2024

@Juice10 fair, I think realistically the issue is with the css parsing which doesn't parse [_nghost-ng-c4172599085]:not(.fit-content).aim-select:hover:not(:disabled, [_nghost-ng-c4172599085]:not(.fit-content).aim-select--disabled, [_nghost-ng-c4172599085]:not(.fit-content).aim-select--invalid, [_nghost-ng-c4172599085]:not(.fit-content).aim-select--active) { border-color: rgb(84, 84, 84); } correctly

Will see if I can come up with a better solution

@jaj1014
Copy link

jaj1014 commented Jan 19, 2024

It looks like this PR is to address #1379.

I added a new comment to that issue re: a similar issue w/ attribute selectors and css parse() failing to properly handle selectors that have curly brackets in them. If you're looking to update parse() in css, it might be helpful info for other cases to consider.

@dengelke dengelke closed this Jan 24, 2024
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.

3 participants