Skip to content

[selectors] Context selectors' limitation #1013

@jolleekin

Description

@jolleekin

Suppose I have a custom element called x-toggle, which has two states on and off reflected by two CSS classes on and off, respectively.

First I want to style the element based its states. This is simple as follows

:host(.on) { ... }
:host(.off) { ... }

Next, I want to support RTL layout. The attribute dir=rtl can be specified on x-foo itself or one of its ancestors.

  1. dir=rtl is on x-foo
:host([dir=rtl].on) { ... }
:host([dir=rtl].off) { ... }
  1. dir=rtl is on an ancestor. Currently, there's no way I can create the following selectors within x-foo's style tag. Will this problem be solved?
[dir=rtl] x-toggle.on { ... }
[dir=rtl] x-toggle.off { ... }

References:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions