Skip to content

cascade layers : use only simple selectors #387

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

Conversation

romainmenke
Copy link
Member

Older browsers don't have support for compound selectors in :not().
I incorrectly assumed that non-complex selectors were ok.

CI will fail because I haven't updated preset-env tests.
Will do so after : #386

@romainmenke romainmenke changed the title cascade layers : use only simpel selectors cascade layers : use only simple selectors May 19, 2022
Copy link
Member

@Antonio-Laguna Antonio-Laguna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@romainmenke romainmenke merged commit edc0fe3 into main May 20, 2022
@romainmenke romainmenke deleted the cascade-layers-use-only-simple-selectors--frank-impala-65c3dfb6d5 branch May 20, 2022 06:06
@yisibl
Copy link
Contributor

yisibl commented Jan 16, 2023

Do you know exactly which browser versions don't support :not(#a#a)?

@romainmenke
Copy link
Member Author

This shipped at the same time as :is() : https://developer.mozilla.org/en-US/docs/Web/CSS/:is#browser_compatibility

I don't have a reference to back this up, I tested this when I made this change.

@yisibl
Copy link
Contributor

yisibl commented Jan 16, 2023

So can we output :not(#a#a) for browsers that support compound selectors? This would be shorter and keep the Specificity intact.

If you agree, I can submit a PR for this.

@romainmenke
Copy link
Member Author

romainmenke commented Jan 16, 2023

We don't have a way to conditionally output :not(#a#a), adding this is not trivial but possible.

We have a similar mechanic for area[href] in postcss-pseudo-class-any-link.
https://github.com/csstools/postcss-plugins/blob/postcss-preset-env--v8/plugin-packs/postcss-preset-env/src/lib/get-options-for-browsers-by-feature.mjs#L32-L46

postcss-preset-env has code to set the correct plugin options for certain browsers.


Required work for this change

  • MDN must include data for complex/compound selectors in :not()
  • cssdb must be updated to track this new sub feature of :not()
  • postcss-presete-env must set the correct plugin options based on browserslist and the new additions in cssdb
  • postcss-cascade-layers must be updated with a new plugin option to toggle this behavior

It would be best to start this work from the postcss-preset-env--v8 branch : https://github.com/csstools/postcss-plugins/tree/postcss-preset-env--v8. We are unlikely to ship large additions in the current version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants