Open Bug 2023867 Opened 7 months ago Updated 7 months ago

CSS @scope (:host) not crossing shadow root boundaries

Categories

(Core :: CSS Parsing and Computation, defect, P3)

Firefox 148
defect

Tracking

()

People

(Reporter: voloxxx, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

Attached image Correct render.png —

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:148.0) Gecko/20100101 Firefox/148.0

Steps to reproduce:

Go to https://jsfiddle.net/4yodsgfb/1/ and click "Run" if needed.

The nested divs (.wrapper1 and .wrapper2) should have the correct css props.

Actual results:

The nested divs (.wrapper1 and .wrapper2) lack the css properties defined inside @scope.

Expected results:

Tested with other browsers (latest Chrome and Safari) and it renders as expected, see attached screenshot.

Attached image Wrong render.png —

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

Component: Untriaged → CSS Parsing and Computation
Product: Firefox → Core

One additional note I forgot to mention: the commented CSS targets only Firefox and produces the expected result.

Blocks: @scope
Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Summary: CSS @scope not crossing shadow root boundaries → CSS @scope (:host) not crossing shadow root boundaries

:host is special, we are probably failing to set the right scope in the MatchingContext.

I'm curious, what's the use case for this? @scope (:host) is similar to @scope (:root) outside the shadow tree...

Flags: needinfo?(voloxxx)

We are using a modified version of SingleSPA to inject parcels (UI elements in our case) into the page. One of our elements needs to fill the vertical space of the container element (our :host).

What I was trying to obtain was to set the :host element to flex and my content (.element in then linked example) to grow and fill the parent.

Then I noticed is that there are 2 extra divs that are added between :host and .element. My idea was to force a display contents to all elements between :host and .element since they are not needed.

Flags: needinfo?(voloxxx)
Attached image DOM Structure.png —

Seems you could do that with something like: *:not(:is(.element, .element *)) { display: contents } but yeah that's a weird one :)

A bit :D
I also tried something else but @scope seems to better approach for my use case.

As in the attached fiddle:

:host {
    div:has(.element) {
        display: contents;
    }
}
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: