Skip to content

[scoping] Direct parent of a :host-context() #7896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Zefling opened this issue Oct 18, 2022 · 1 comment
Open

[scoping] Direct parent of a :host-context() #7896

Zefling opened this issue Oct 18, 2022 · 1 comment
Labels
css-scoping-1 Current Work

Comments

@Zefling
Copy link

Zefling commented Oct 18, 2022

I have a custom element <my-elem> and I would like only the one whose parent with class row to be affected:

<style>
  /* ... */
  :host-context(.row >) > div {
    background-color: blue;
  }
</style>
<div class=".row">
  <div>
    <my-elem>
      <div>DIV!</div>
      <main>MAIN!</main>
      <aside>ASIDE!</aside>
    </my-elem>
  </div>
<div>
<div class=".row">
  <my-elem>
    <div>DIV!</div>  <!-- Only this element -->
    <main>MAIN!</main>
    <aside>ASIDE!</aside>
  </my-elem>
<div>
<my-elem>
  <div>DIV!</div>
  <main>MAIN!</main>
  <aside>ASIDE!</aside>
</my-elem>

This doesn't seem possible, because > at the end of the selector is not valid.

There is a reason for this? If so, how can I do without?

@tabatkins
Copy link
Member

This is currently intentionally impossible - the :host-context() selector only takes a compound selector (only evaluating on one element, with no combinators), to make it faster and easier to evaluate, as :host-context() is already somewhat expensive to do correctly.

@fantasai fantasai added the css-scoping-1 Current Work label Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-scoping-1 Current Work
Projects
None yet
Development

No branches or pull requests

3 participants