docs icon indicating copy to clipboard operation
docs copied to clipboard

::slotted and ::part

Open apprat opened this issue 5 years ago • 4 comments

::slotted(my-button::part(icon)) Error ::slotted(my-button)::part(icon) Error

Is this the way it is designed

apprat avatar Jun 17 '20 11:06 apprat

What error? Could you provide an example?

fergald avatar Jun 17 '20 15:06 fergald

What error? Could you provide an example?

example: https://github.com/vdapk/demo/blob/master/demo.html

I don’t know if it’s a design or a bug

apprat avatar Jun 18 '20 05:06 apprat

::slotted(*::part(a)) is not correct, the part is not the slotted elements (a part is not an element at all actually since it can refer to multiple elements). So tweaking your example we have (let's pretend there's a <shadow> element)

  <my-group>
    <shadow>
       <style>
          ::slotted(*)::part(a) {
            background:red;
          }  
        </style>
        <slot></slot>
    </shadow>
    # this goes in the slot
    <my-button>Button
      <shadow>
        <div part="a">Text</div>
      </shadow>
    </my-button>
  </my-group>

I would expect ::slotted(*) to find <my-button> and then ::part(a) should find the div.

So this seems like a bug to me. I don't work on this anymore. I have filed a chromium bug for this. The CSS team might point out some misunderstanding. If you have time, please check and edge, safari. Firefox seems to be the same as chrome.

fergald avatar Jun 20 '20 04:06 fergald

::slotted(*::part(a)) is not correct, the part is not the slotted elements (a part is not an element at all actually since it can refer to multiple elements). So tweaking your example we have (let's pretend there's a <shadow> element)

  <my-group>
    <shadow>
       <style>
          ::slotted(*)::part(a) {
            background:red;
          }  
        </style>
        <slot></slot>
    </shadow>
    # this goes in the slot
    <my-button>Button
      <shadow>
        <div part="a">Text</div>
      </shadow>
    </my-button>
  </my-group>

I would expect ::slotted(*) to find <my-button> and then ::part(a) should find the div.

So this seems like a bug to me. I don't work on this anymore. I have filed a chromium bug for this. The CSS team might point out some misunderstanding. If you have time, please check and edge, safari. Firefox seems to be the same as chrome.

thank

apprat avatar Jun 20 '20 08:06 apprat