-
Notifications
You must be signed in to change notification settings - Fork 693
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
[cssom] getComputedStyle only supports ::before/::after #2149
Comments
I think it makes sense to support all pseudo-elements which the user-agent supports, and it probably should also be specified that what should happen when the pseudo-element is not supported. Personally I think throwing an exception (maybe Note that, Firefox currently throws FWIW, there could be tricky cases for supporting returning all properties on all pseudo-elements, for example, since many pseudo-elements have only limited properties applied, user-agents may want to avoid computing the rest if possible, and may optimize their storage, which can lead to observable difference on returned value. Also some properties which use used value rather than computed value as resolve value might be tricky in some cases, although it isn't clear to me what the cases would be. |
Edge supports a broad range of them, and like Chrome we fallback to returning the style of the element if we are not able to return the pseudo element style. We are supposed to support -webkit-input-placeholder but I am not sure it's actually working in the end, this could be just a bug. I believe the advantage of returning a functioning style object when asked about a pseudo-element you don't support is that you don't crash, with a bit of chance the script will do just fine with slighly wrong values. |
The Working Group just discussed
The full IRC log of that discussion<dael> Topic: getComputedStyle only supports ::before/::after<dael> github: <dael> github: https://github.com//issues/2149 <dael> gsnedders: getComputedStyle takes a second arg we could pass a pseudo element. Spec desn't agree with impl. It only allows some pseudo and impl allow any. <dael> gsnedders: What do we do when it's invalid? <dael> TabAtkins: Seems that we should support first-letter and first-line, but I don't see why not all. <dael> emilio: Except slotted <dael> TabAtkins: Yeah. We do still want some sort of magic thing. <dael> TabAtkins: Slotted is first case of a pseudo being an alias for 1 or more elements. Aliases wouldn't work from this sort of example. <dael> TabAtkins: We should prob make a term for things like slotted and things not like slotted and say it works for all things in that category. <dael> Rossen: Currently it should work for non-slotted pseudo elements. <dael> TabAtkins: Yes. <dael> TabAtkins: I need to make it into 2 categories where slotted is only one in the second currently. <dael> Rossen: Reasonable. Other optinos or objections? <dael> RESOLVED: getComputedStyle for pseudo elements that are not slotted is supported. <dael> gsnedders: What to do given an invalid pseudo element? All browsers return a css style declaration. FF throws if you trya nd access a property, everyone else returns the element style declaration and ignores the pseudo element. <dael> TabAtkins: Returning element styles is...there's no reason to do that. Throwing would be best. <dael> gsnedders: Nothing does that. So can it be web compat? <dael> TabAtkins: FF doesn't let you touch it. Unless there's code to getgCS and not do anything I suspect we can throw. <dael> fremy: Empty strings? <dael> gsnedders: Reasonable. I'd prefer try throwing. <dael> TabAtkins: At gCS call time. <dael> ???: incl slotted? <dael> TabAtkins: Yeah. <TabAtkins> s/???/ewilligers/ <dael> Rossen: Do we throw for non-elements? <dael> emilio: Yes. <dael> Rossen: So this is not different. <dael> TabAtkins: We're trying to say do the same. <dael> Rossen: I'm trying to align whatever we do in that situation we should do it for this situation <dael> fremy: If people call getComputedStyle with a placeholder we'll throw. <dael> emilio: blink claims to support all eleemnts at parse time which is weird. <dael> fremy: [missed] <dael> emilio: Does gCS webkit get a result now? I guess not. <dael> fremy: They work in Edge and Chrome they return. <dael> emilio: gCS in ::webkit-foo <dael> fremy: I think that's why we returnt he element style. People do random things we don't support and since Chrome does something we do something. <dael> fremy: I'm fine saying we should throw but I won't be first to impl. <dael> Rossen: In terms of defining behavior the most sensible thing is throw. <dael> Rossen: Objections to that proposal? <dael> RESOLVED: Throw in this case |
…is unknown or ::slotted. Fixes w3c#2149
…edStyle is unknown or ::slotted. Fixes w3c#2149
…edStyle is unknown or ::slotted. Fixes w3c#2149
…ment throws. This tests the resolution in w3c/csswg-drafts#2149.
…ment throws. This tests the resolution in w3c/csswg-drafts#2149.
…edStyle is unknown or ::slotted. Fixes w3c#2149
https://drafts.csswg.org/cssom/#extensions-to-the-window-interface
Roughly, from what I've tested:
::first-letter
and::first-line
.NS_ERROR_NOT_AVAILABLE
for::marker
(and doesn't support::marker
AFAIK), Chrome doesn't support it so returns the element, and Safari does support::marker
and does support it for gCS::placeholder
, Chrome and Safari does not (despite supporting the feature)Is there any reason not to allow all pseudo-elements for gCS?
The text was updated successfully, but these errors were encountered: