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

[css-pseudo] Allow custom Properties in ::selection pseudos (revisited) #11317

Open
schenney-chromium opened this issue Dec 3, 2024 · 3 comments
Labels
Async Resolution: Proposed Candidate for auto-resolve with stated time limit css-pseudo-4 Current Work

Comments

@schenney-chromium
Copy link
Contributor

Chromium continues to try to ship the Highlight Inheritance model for selection. The third attempt has failed because CSS pre-processing and generation tools create ::selection rules like this:

div::selection {
   --my-opacity: 1;
   background-color: rgb(0 0 0/var(--my-opacity));
}

In #6264 we allowed custom properties on highlight pseudos.

Then in #6641 we also said that all custom properties should be copied from the root for the root::selection, and then start adding those in the ::selection inheritance path.

This proved insufficient when launched in Chromium because many sites rely on ::selection inheriting custom properties from their originating elements. So we discussed disallowing custom properties in highlights and inheriting from the originating elements, and resolved to do that in #9909.

@tabatkins commented in #6641 that the example above must be allowed for their support. @LeaVerou also raised the same concern in one of the issues above. I did not pay enough attention to that. So the change from #9909 broke many many major sites.

To make it possible to ship highlight inheritance for ::selection, and bring ::selection implementations into line with other highlight pseudos, I believe we need this ...

::selection pseudo elements inherit custom properties from their originating-element and then apply custom properties from the ::selection rule itself. Custom properties from ::selection rules apply only within that rule, and are not inherited by descendants.

My current thinking is that we limit this behavior to ::selection and not other highlight pseudos, as a back-compatibility requirement. It's not a strongly held position.

Proposing async resolution but feel free to add to the agenda. 4 week time limit given holidays.

@delan @fantasai @frivoal

@schenney-chromium schenney-chromium added Async Resolution: Proposed Candidate for auto-resolve with stated time limit css-pseudo-4 Current Work labels Dec 3, 2024
@schenney-chromium
Copy link
Contributor Author

I should note that implementing the proposed behavior is likely straight-forward and efficient (it's a 2 line change in Chromium). Implementing dual inheritance paths, through both originating and highlight trees, is likely very bad for performance,

@astearns
Copy link
Member

I am a bit concerned about making ::selection work differently than other highlight pseudos. As use of the other pseudos rises, won’t people be creating similar rules for them with pre-processors and expect those to work like ::selection?

@schenney-chromium
Copy link
Contributor Author

schenney-chromium commented Dec 16, 2024

I'm totally fine with making it apply to all highlight pseudos.

So the proposed resolution would be:

Highlight pseudo elements inherit custom properties from their originating-element and then apply custom properties from the highlight itself. Custom properties in Highlight Pseudos are not inherited through the highlight inheritance chain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Async Resolution: Proposed Candidate for auto-resolve with stated time limit css-pseudo-4 Current Work
Projects
None yet
Development

No branches or pull requests

2 participants