Closed Bug 1793938 Opened 2 years ago Closed 2 years ago

getComputedStyle returns empty array

Categories

(Core :: CSS Parsing and Computation, defect)

Firefox 105
defect

Tracking

()

RESOLVED INVALID

People

(Reporter: michael1.dietrich, Unassigned)

References

(Regression)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.34

Steps to reproduce:

We have an SPA using Blazor and web components. Starting with Firefox 105 getComputedStyle(..) returns an empty array for some DOM elements within web components.

A minimal repro can be found here:
https://blazorrepl.telerik.com/QmbYYqFP31NUn5FA41

Actual results:

Calling getComputedStyle(..) on some DOM elements returns an empty result array.

Expected results:

Calling getComputedStyle(..) on any DOM element should return the computed styles.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Core & HTML' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Component: DOM: Core & HTML → CSS Parsing and Computation

I believe this is expected, and invalid. The test-case doesn't seem super-reliable (sometimes I get a style properly), but when it repros the DOM is in a funky state where the container has a shadow root attached, but no <slot>, so the element is not part of the flattened tree.

Per spec, this should return an empty style, just like for elements outside of the document, see https://w3c.github.io/csswg-drafts/cssom-1/#extensions-to-the-window-interface step 5:

  • If obj is not null, and elt is connected, part of the flat tree, and its ...

The important bit here is the part of the flat tree.

I'm not familiar with the component library you're using, but it's weird that you can run user code in a half-baked DOM state like that.

So this technically regressed in bug 1784943, but the style we returned before was bogus (and so is the style returned by other engines, there's just no style to inherit from).

Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Regressed by: 1784943
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: