You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[cssom] Serialization of CSS declaration block returned from getComputedStyle #1033
How should CSS declaration block returned from getComputedStyle be serialized? It contains all longhand properties.
Currently, Gecko and Edge return empty string for it, while WebKit and Blink (probably inherit from WebKit) seem to return serialization of all longhand properties (i.e. not trying to generate shorthands). Apparently none follows the spec.
Following the same algorithm for cssText of declaration block from getComputedStyle is complicated, and probably isn't worth. So I suggest that the spec should either follow Gecko and Edge to return empty string, or follow WebKit and Blink to just return all longhand properties.
I would prefer we just make it return empty string... But there is a webcompat issue reported to Firefox for lack of its support: webcompat/web-bugs#3822. This is a Google website though, so maybe we can just ask Google to fix it and ignore this issue...
I don't think that's something related. IIRC in general we don't serialize new shorthands in computed style, only longhands are serialized there. There are several shorthands get serialized in computed style just for backward compatibility.
(Adding myself to the thread; but could you clarify what you think Chrome doesn't do per standards here? I have the impression their behavior is correct in that case at first glance)
(Just to clarify, talking about the initial issue, not the shorthands-in-gCS one)
could you clarify what you think Chrome doesn't do per standards here? I have the impression their behavior is correct in that case at first glance
In the spec, the serialize a CSS declaration block algorithm tries to construct shorthands whenever possible. In case of declaration block from getComputedStyle, since all longhands are available, most of shorthands would be constructible. However, Chrome doesn't seem to construct any shorthand in that case.
Given the following case, it seems browsers all have some logic to try to serialize as shorthands when possible. It's unclear to me why we want to avoid doing that for getComputedStyle specifically?
@tabatkins Could you link it to the Chrome bug if you can find it please? I think this resolution makes sense, but Chrome hasn't updated its behavior yet :/.
I'll file a WebKit bug pointing to that bug as well.
Activity
mrego commentedon Feb 14, 2017
We've similar issues in CSS Grid Layout spec.
This was an old mail to
www-style: https://lists.w3.org/Archives/Public/www-style/2015Jul/0242.htmlA very basic example:
The output right now in Chrome is:
And in Firefox:
upsuper commentedon Feb 14, 2017
I don't think that's something related. IIRC in general we don't serialize new shorthands in computed style, only longhands are serialized there. There are several shorthands get serialized in computed style just for backward compatibility.
mrego commentedon Feb 14, 2017
Oops, ok I messed it up, I thought you were talking about shorthands.
FremyCompany commentedon Feb 14, 2017
(Adding myself to the thread; but could you clarify what you think Chrome doesn't do per standards here? I have the impression their behavior is correct in that case at first glance)
upsuper commentedon Feb 14, 2017
In the spec, the serialize a CSS declaration block algorithm tries to construct shorthands whenever possible. In case of declaration block from
getComputedStyle, since all longhands are available, most of shorthands would be constructible. However, Chrome doesn't seem to construct any shorthand in that case.tabatkins commentedon Feb 22, 2017
On the call today WG resolved to accept Firefox's and Edge's behavior, and make the object serialize to the empty string.
I'll file a bug on Chrome to fix this, and start evangelizing at Drive to fix the webcompat bug.
FremyCompany commentedon Feb 22, 2017
Thanks Tab!
zcorpan commentedon Mar 6, 2017
@upsuper
Which are these?
upsuper commentedon Mar 6, 2017
Mainly the shorthands which are previously longhands, e.g.
background-position,text-decoration,overflow, andmask.zcorpan commentedon Mar 15, 2017
Given the following case, it seems browsers all have some logic to try to serialize as shorthands when possible. It's unclear to me why we want to avoid doing that for
getComputedStylespecifically?http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4948
(check the value of the
styleattributes after the script has run.)emilio commentedon Apr 27, 2018
@tabatkins Could you link it to the Chrome bug if you can find it please? I think this resolution makes sense, but Chrome hasn't updated its behavior yet :/.
I'll file a WebKit bug pointing to that bug as well.
15 remaining items
[cssom] CSSStyleDeclaration.cssText should return the empty string fo…
[CSS] Return empty string for CSSStyleDeclaration.cssText
[CSS] Return empty string for CSSStyleDeclaration.cssText
[CSS] Return empty string for CSSStyleDeclaration.cssText
[CSS] Return empty string for CSSStyleDeclaration.cssText
[CSS] Return empty string for CSSStyleDeclaration.cssText
Bug 1678010 [wpt PR 26561] - [CSS] Return empty string for CSSStyleDe…
Bug 1678010 [wpt PR 26561] - [CSS] Return empty string for CSSStyleDe…
Bug 1678010 [wpt PR 26561] - [CSS] Return empty string for CSSStyleDe…
karlcow commentedon Aug 16, 2021
Like @emilio I was looking for the chromium bug links. so here it is.
I can't find the webkit one.
graouts commentedon Nov 10, 2021
This will be fixed in WebKit with bug 232943.
The cssText property for a computed style should return an empty string
The cssText property for a computed style should return an empty string
Bug 1629304 [wpt PR 22877] - [cssom] Test that CSSStyleDeclaration.cs…
Bug 1678010 [wpt PR 26561] - [CSS] Return empty string for CSSStyleDe…