-
Notifications
You must be signed in to change notification settings - Fork 668
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-4] should CSSPseudoElement have a pseudo() method? #3836
Comments
I'd much rather not make |
That's a great reason for not doing it for those pseudos. :-) Are there other pseudos where it still might make sense? |
You could addres the |
I've opened #3876 to discuss that, it is indeed weird. |
Even if we don't have
|
Should be the second; it's a ::marker whose originating element is the ::before. |
Ok, I guess we need to change the type of |
Yeah. And add |
Maybe rename |
Also, what's the story for getting computed style of these "stacked" pseudo-elements? |
It used to be named that (or |
The CSS Working Group just discussed
The full IRC log of that discussion<fantasai> Topic: CSSPseudoElement having a pseudo() method<fantasai> AmeliaBR: Seems to make sense to me, if a pseudo-element can have a pseudo-element, then having .pseudo() would make sense <fantasai> emilio: Have we decided yet how to make those styleable <fantasai> fantasai: will be stylable with selectors like ::before::marker <fantasai> emilio: I would wait to add this method until that is allowed <fantasai> fantasai: So proposal is to add .pseudo() to CSSPseudoElement once stacked pseudo becomes a valid selector <fantasai> plinss: Side issue of whether to rename .element to .parent <fantasai> fantasai: Not always a parent <fantasai> TabAtkins: The full term is "originating element" but that was too long <fantasai> TabAtkins: So shortened to .element <fantasai> plinss: Need to reach pseudo-element between you and the element <fantasai> TabAtkins: Yeah, that's what .element would do <fantasai> plinss: OK <fantasai> TabAtkins: When we adopt this, just the return type would be adapted <fantasai> RESOLVED: add .pseudo() to CSSPseudoElement once some stacked pseudo combination becomes a valid selector. Adjust .element return type to match. <emilio> github: https://github.com//issues/3836 |
I personally think Why? Well a pseudo-element is meant to be transparent as to whether or not it points to single element, multiple elements, text nodes, etc. Because of the way they are specified it's only possible to target all such components or none of them in CSS, similarly I think it should work identically with This would work fine with Also it'd be nice with reference selectors or similar ideas too as then you could do |
Well, parts as well as slotted elements can have different styles even if they are the same part or slotted selector, because of rules in and outside the shadow tree respectively, so that just doesn't hold. |
No the elements that comprise of the parts can have different styles, the styles of an element are resolved from its
As an example I would expect this to return <style>
#foo::part(bar) {
color: red;
}
</style>
<div id="foo">
#shadow-root
<div part="bar" style="color: blue;"></div>
</div>
<script>
// Only the resolved styles of the pseudo-element should be considered
// not the combined styles of the actual elements inside the shadow root
// as outside code should never be able to know about things like style="..."
// attributes or so forth that happen from within the shadow root
getComputedStyle(foo.pseudo("::part(bar)")) === 'red';
</script> |
Would it be worth considering having two separate properties, |
@Jamesernator |
Agenda+ to consider @lpd-au’s #3836 (comment) |
The CSS Working Group just discussed
The full IRC log of that discussion<dael> Topic: should CSSPseudoElement have a pseudo() method? Would it be worth considering having two separate properties, Element element and Element|CSSPseudoElement parent<dael> github: https://github.com//issues/3836#issuecomment-502344378 <dael> florian: Because it is now possible to have pseudo attached to pseudos. In addition to element class having pseudo pseudo element class has apseudo. <dael> florian: Another question, pseduo element class has an element method that returns originating element. Pseudo on a pseudo do you want originating or parent pseduo? <dael> florian: Original thought is return the parent. Later proposed we should have both. Element returns originating element, but also have a parent method that returns parent pseudo if there is one and if there isn't returns originating <dael> florian: Got thumbs up so proposal is accept <dael> astearns: If it's not nested parent returns nothing? <dael> florian: Returns same as element <dael> astearns: First is element ancestor and second is immediatate parent <dael> florian: Yes <dael> fantasai: One thought, if we extend to non-tree-abiding parent is not quite the right word. If you select first-letter element parent is the first line or some weird nesting. We could call it parent and say these things are special <dael> florian: It would be walking up hierarchy step by step. Just need to define weird cases <dael> fantasai: As long as people say it can be repurposed to not quite a parent it's fine to me. Just wanted to point out it's going to be a bit weird <dael> astearns: Other opinions? <dael> astearns: Hearing people in favor <dael> astearns: Prop: Use the existing parent function in css pseudo element as returning fifrst element ancestor and add an immediate parent that could poss return a pseudo element <dael> RESOLVED: Use the existing parent function in css pseudo element as returning firrst element ancestor and add an immediate parent that could possibly return a pseudo element |
…ement) for sub-pseudo-elements #3836
Edits in. I had to add a new section to Selectors 4 also. See @frivoal @lpd-au @heycam Let me know if anything seems off, or if the edits seem to correctly reflect what we agreed here. (CSSOM stuff is not my forte, exactly.) |
Not an OM expert either, but it looks good to me. |
This looks great to me, thanks for your work! :) As a nitpick, I believe it would be helpful to readers for the definition of |
@lpd-au I think that would downplay the idea that an “originating element” can be either an element or a pseudo-element, i.e. that “originating pseudo-element” is defined as a sub-class of “originating element”. Since the next sentence explicitly mentions the case of having an originating pseudo-element, the intent should be clear from the spec already, so I think we don't particularly need to call it out. At least, that's my thinking. Lmk if that makes sense. :) |
https://drafts.csswg.org/css-pseudo-4/#CSSPseudoElement-interface
You can get to the pseudo-element of an element with
Element.pseudo()
. But some pseudos are defined to have other pseudos hanging off them, like with::part(label)::before
. DoesCSSPseudoElement
need its ownpseudo()
method?The text was updated successfully, but these errors were encountered: