Open Bug 137688 Opened 19 years ago Updated 26 days ago
Property Value on computed style (get Computed Style) does not do shorthand properties
nsComputedDOMStyle should handle getPropertyValue asking for shorthands
Priority: -- → P5
Target Milestone: --- → Future
No plans to work on this any time in the foreseeable future, so to default owner.
Assignee: bz-vacation → general
Priority: P5 → --
Target Milestone: Future → ---
10 years later... Still no plan on fixing the bug?
Not until there's a spec for the behavior, at least, no, because until then there's no way to implement this: the behavior is not define. The spec is being worked on.
Where is the spec being worked on, and is it possible to see the progress?
And note that there are computed values of some shorthands that cannot actually be represented as a value for the shorthand. Not an issue for "padding", but definitely an issue for "border".
Note that getPropertyCSSValue is supposed to return null for shorthands -- which is what we do for the shorthands that have always been shorthands -- but not the ones that were originally longhands. There are plenty of non-representable values of shorthands -- that happens for specified style too -- and I believe the spec says to handle it the same way, by serializing to the empty string: https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue refers to https://drafts.csswg.org/cssom/#serialize-a-css-value which says: "If shorthand cannot represent the values of list in its grammar, return the empty string and terminate these steps." (and that wording covers both computed and specified style). That said: what do other browsers do here? Will we hit compatibility problems if we start supporting shorthands?
It looks like Chrome and Safari supports shorthands currently. I'm able to get appropriate serialized value on them. I think we should do the same too.
This is sort-of easily-implementable without duplicating a lot of code by using the "uncomputing" machinery we already have for animations, and constructing a temporary declaration block to try serializing the shorthand with all the relevant declarations, I guess.
As per  the CSSWG has resolved: "all shorthands must show up in getComputedStyles". The spec has yet to be updated to reflect the resolution, however.  https://github.com/w3c/csswg-drafts/issues/2529#issuecomment-402386896
Summary: getPropertyValue on computed style does not do shorthand properties → getPropertyValue on computed style (getComputedStyle) does not do shorthand properties
Assignee: nobody → boris.chiou
QA Contact: boris.chiou
You need to log in before you can comment on or make changes to this bug.