Re: [csswg-drafts] [selectors-4] Add pseudo-class to establish before-change style for css-transitions on new elements. (#8174)

There was discussion in https://github.com/w3c/csswg-drafts/issues/8174#issuecomment-1379224022 about pseudo-class versus pseudo-element, but I didn't feel that that discussion came to much of a conclusion, and I think I probably lean towards a pseudo-element rather than a pseudo-class (which is where I thought that previous discussion was leaning).

I fully admit that this has some aspects of either -- it's unlike a pseudo-element in that it matches the same *thing* as the element -- but it does so at a different *time* (for a somewhat interesting definition of "time").

I think the restrictions proposed above look a lot like the restrictions that we would put on a pseudo-element, and are quite unusual for a pseudo-class.  In particular, the "only does something on the subject of the selector" really makes it feel quite like a pseudo-element. 

I also think as a pseudo-class people might reasonably expect it to work when applied to something other than the subject.  As a pseudo-class, I think that `div:initial p` is conceptually the same as `div p:initial` -- it would seem that both should affect the before-change style of a p that is a descendant of a div -- since the before-change style of the p inherits from the before-change style of its ancestor (etc.).  I think that these selectors really seem to do the same thing perhaps argues for it being a pseudo-element -- although as noted above that particular situation is different from the existing pseudo-classes and pseudo-elements since it's a difference of "time" rather than object identity.

There's also a rather significant substantive difference between a pseudo-class and a pseudo-element in terms of cascading.  For example compare this situation:
```css
:any-link { color: blue; transition: color 1s; }
:any-link#signature { color: green; }     /* overrides :link:initial */
:any-link:initial { color: purple; }      /* does not affect transition of #signature */
```
with this situation:
```css
:any-link { color: blue; transition: color 1s; }
:any-link#signature { color: green; }     /* does not override :link:initial */
:any-link::initial { color: purple; }     /* affects transitions of all links, including #signature */
```
I'm not sure which cascading setup is preferable, but they're definitely different, and my intuition is that I prefer the pseudo-element version since I think of before-change style as different (even if it's different in "time" rather than object identity).

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


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

Received on Thursday, 2 March 2023 01:18:01 UTC