[csswg-drafts] [cssom-1][css-pseudo-4] getComputedStyle and pseudo-elements with pseudo-classes or sub-pseudo-elements (#10297)

delan has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom-1][css-pseudo-4] getComputedStyle and pseudo-elements with pseudo-classes or sub-pseudo-elements ==
getComputedStyle currently [takes an optional <pseudo-element-selector>](https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle), and for highlight pseudos like ::search-text (#3812), it returns the styles that would apply to the element [if that highlight is the only one active](https://drafts.csswg.org/css-pseudo/#getComputedStyle).

But pseudo-elements [can have their own pseudo-classes](https://drafts.csswg.org/selectors/#pseudo-element-states), such as ::search-text:current (#10212) or [::first-line:hover](https://drafts.csswg.org/selectors/#example-61c8ad8f), or even their own [sub-pseudo-elements](https://drafts.csswg.org/selectors/#sub-pseudo-elements), such as ::before::marker. Note that while an element’s ::first-line is either :hover or :not(hover), both the :current and :not(current) styles can apply to different parts of an element’s ::search-text at once.

1. **Should `getComputedStyle(x, "::search-text")` return the `:current` styles or the `:not(:current)` styles?** We propose `:not(:current)`, and specifying this behaviour for ::search-text in [css-pseudo #getComputedStyle](https://drafts.csswg.org/css-pseudo/#getComputedStyle).

2. **Given that `getComputedStyle(x)` returns the `:hover` styles when x is being hovered, should `getComputedStyle(x, "::first-line")` return the `::first-line:hover` styles when the first line is being hovered?** My current belief is that it should, and that in general, getComputedStyle should take pseudo-classes of the given <var>pseudoElt</var> into account. Note that ::first-line:hover rules are [not yet supported by major impls](https://stackoverflow.com/a/78084258) ([demo](https://bucket.daz.cat/work/igalia/0/66.html)).

3. **Can we give authors a way to get the `::search-text:current` styles?** My current belief is that we should change <var>pseudoElt</var> from “&lt;pseudo-element-selector>” to “&lt;pseudo-compound-selector>”, but I’m not yet sure how we would update the algorithm in a way that satisfies both my beliefs in question 2 and question 3.

4. **Can we give authors a way to get the `::before::marker` styles?** My current belief is that we should change <var>pseudoElt</var> to “&lt;pseudo-element-selector>+” or “&lt;pseudo-compound-selector>+”, depending on the outcome of question 3.

I may experiment with questions 2 through 4 in Chromium to see what’s feasible.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10297 using your GitHub account


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

Received on Thursday, 9 May 2024 08:11:54 UTC