Re: [csswg-drafts] [cssom-1] Expose nested selectorText on CSSStyleRule (#10246)

This would be very useful!

For all things PostCSS, Stylelint, ... we also need to determine the full selector and I created a helper for this : https://github.com/csstools/postcss-plugins/tree/main/packages/selector-resolve-nested#readme

The wording we use is a bit different : https://github.com/csstools/postcss-plugins/blob/main/packages/selector-resolve-nested/docs/selector-resolve-nested.md#functions

We use `flatten` for naive replacements. This does a simple replacement of `&` with the parent selector. The result is a mangled selector that won't match the same elements but this is useful for static analysis. (e.g. how many type selectors did the author write in source?)

We use `resolve` to get a full selector that would also match the same elements. (e.g. what is the specificity of this selector?)

If there was a specification for this action we should have similar behavior between tooling and browsers. 

-- 
GitHub Notification of comment by romainmenke
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10246#issuecomment-2074553231 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 24 April 2024 09:49:39 UTC