Open Bug 1857849 Opened 1 year ago Updated 2 months ago

Implement Element.computedStyleMap()

Categories

(Core :: DOM: CSS Object Model, enhancement)

enhancement

Tracking

()

People

(Reporter: fredw, Unassigned)

References

(Blocks 3 open bugs)

Details

(Keywords: dev-doc-needed, parity-chrome, parity-safari, Whiteboard: webcompat:risk-moderate )

Attachments

(1 obsolete file)

The specification is https://drafts.css-houdini.org/css-typed-om/#computed-stylepropertymapreadonly-objects

Note the following, which means this is different from https://searchfox.org/mozilla-central/rev/abbea4195b00e82af2ae9abaafc31e4b4ec4f8c0/layout/style/nsComputedDOMStyle.cpp#2385

The StylePropertyMapReadOnly returned by this method represents the actual computed values, not the resolved value concept used by Window.getComputedStyle(). It can thus return different values than Window.getComputedStyle() for some properties (such as width).

There are a couple of WPT tests relying on it:
https://searchfox.org/mozilla-central/search?q=computedStyleMap%28%29&path=testing%2Fweb-platform%2Ftests&case=false&regexp=false

In particular, the following WPT tests from the CSS properties and values API rely on this API:

/css/css-properties-values-api/at-property-typedom.html
/css/css-properties-values-api/property-cascade.html
/css/css-properties-values-api/typedom.html

Checking a bit the spec, computedStyleMap() returns its a StylePropertyMapReadOnly where the values are CSSStyleValue objects constructed by "reification" and with special serialization rules. So only implementing computedStyleMap() would already require implementing a good chunk of the css-typed-om spec.

Duplicate of this bug: 1852016

At the end, this may not be necessary for interop 2023 if we rewrite property-cascade.html (the typedom ones will still require this though). I opened https://github.com/web-platform-tests/interop/issues/588

Keywords: dev-doc-needed

This feature is no longer in draft and is already implemented by every other browser. We would be extremely helpful to have it available to list CSS variables applied to an element when you don't know the name of the variables ahead of time.

It's also been recommended by W3C members, here: https://github.com/w3c/csswg-drafts/issues/8398#issuecomment-1570264185

Lack of support for this is at least partly why we fail WPTs like https://wpt.fyi/results/css/css-color/system-color-compute.html

Whiteboard: webcompat:risk-moderate
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: