Skip to content

[css-contain] CQ vs shadow boundaries #5984

@tabatkins

Description

@tabatkins

Can a CQ see past shadow boundaries? If so, exactly how?

If the CQ is done via selectors, the answer is obvious - you can only CQ against elements you can see via selectors. So from within a shadow, the highest ancestor you can CQ against is your host element, no higher.

If CQ is done via an at-rule, the answer is not quite as clear; theoretically, we can walk the box tree (flat tree) to find ancestors. However, we do not want a ::part() to be able to see an ancestor within the targeted shadow (it violates shadow encapsulation). And letting a shadow see ancestors outside in the light DOM gives us similar power to :host-context(), which already makes browser vendors unhappy, so maybe we don't want that either. And that's all the cases, so presumably we don't want it to work in either case.


As a related issue, we'll need to specifically define that the CQ pseudo-class matches on host elements, since they're featureless and don't match anything besides :host by default otherwise.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions