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

Add support for relative selector lists #75

Merged
merged 1 commit into from
Jul 17, 2024

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Mar 18, 2024

Fixes #74

This PR adds support for relative selectors used in :has while making the addition of other relative selector pseudo-classes in the future fairly simple.

I added a new type Relative for this but I'm not sure whether or not this is the right design. The CSS spec states that, because :has() takes a relative selector list, the arguments of :has() are actually complex selectors. However, it seems a little odd to me to treat the left side of a complex selector as null (but that could be an alternate design), especially since the text talks about complex selectors being compound selectors separated by combinators. So the "first" compound selector would be nothing in the relative case — somehow feels wrong from the definition.

Thoughts?

Copy link

netlify bot commented Mar 18, 2024

Deploy Preview for parsel ready!

Name Link
🔨 Latest commit f359c31
🔍 Latest deploy log https://app.netlify.com/sites/parsel/deploys/6697f2b152899800082329ea
😎 Deploy Preview https://deploy-preview-75--parsel.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@LeaVerou
Copy link
Owner

Hi there, sorry this took so long!

In the spirit of permissiveness, I wonder if it may be worth it to just parse all relative complex selectors. What do you think?

@thecrypticace
Copy link
Contributor Author

I am so sorry, I only just now saw this comment (gotta tune my GH notifications I guess for being too noisy).

Do you mean just to always parse a selector as possibly relative? Yeah I think that's reasonable. Not all pseudos take relative selector lists but that could very well be expanded in the future so leaving it up to the person using parsel to validate that seems reasonable.

I'll make some time this week to finalize this PR.

@LeaVerou
Copy link
Owner

LeaVerou commented Jul 1, 2024

Yes, exactly.

@thecrypticace
Copy link
Contributor Author

Sorry — "this week" turned into a little over 2 weeks. I made that change. The PR is a good bit simpler now because of it as well!

@LeaVerou LeaVerou merged commit 6a48ad4 into LeaVerou:master Jul 17, 2024
4 checks passed
@LeaVerou
Copy link
Owner

Looks great, thank you!

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.

:has(> selector) can't be parsed
2 participants