Closed Bug 1586872 Opened 5 years ago Closed 5 years ago

If an element a descendant of a shadow host but the host doesn't have a slot, computed styles don't seem to resolve properly on the descendant element

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: bgrins, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

This is something I noticed working on the <panel> Custom Element conversion in Bug 1397876.

The setup is:

custom-element
  #shadow-root (no slot)
  direct-descendant

If I try to read computed styles on direct-descendant they aren't returning what I expect. Note that if I add a slot so it's like:

custom-element
  #shadow-root
    slot
      <direct-descendant>
  direct-descendant

Then the styles do resolve.

I've attached an html test case for this. In the test case, both chromium and safari log out:

computed style without slot rgb(255, 0, 0)
computed style with slot rgb(255, 0, 0)

But Firefox logs out:

computed style without slot rgba(0, 0, 0, 0) 
computed style with slot rgb(255, 0, 0)

Per spec we shouldn't even return a style in the first place (we should return a style with length = 0 and empty strings). Non-slotted children of the host are not in the flattened tree, and thus have nothing to inherit from.

In this case it happens not to work because of an style system optimization (the bloom filter), that only looks at the flattened tree ancestors.

I need to coordinate with chrome to ship that change at the same time though.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID

In particular, https://drafts.csswg.org/cssom/#dom-window-getcomputedstyle:

If elt is connected, part of the flat tree, and its shadow-including root has a browsing context which either doesn’t have a browsing context container, or whose browsing context container is being rendered, set decls to a list of all longhand properties that are supported CSS properties, in lexicographical order, with the value being the resolved value computed for obj using the style rules associated with doc.

And bug 1483798 tracks that.

Makes sense - thanks for the info

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: