Re: [WICG/webcomponents] There is no way to navigate to a fragment inside a shadow tree (#924)

> Solving this would need something like delegatesIds = [ list of IDs ].

The downside of something like this is that the parent tree might not be aware of all ids being exposed via all shadow roots, this would make it easy to potentially have conflicting ids. 

An alternative would be to just allow associating an id to a given shadow `::part` e.g.:

```js
<style>
  /* Ideally works, although using it .querySelector wouldn't select anything
     as it's in a shadow root, so this is borderline a pseudo-element */
  :target {
    color: red;
  }
</style>

<a href="ref">Works</a>

<my-element partids="ref:myPart">
  <template shadowroot="closed">
    <div part="myPart">Foo bar!</div>
    <div part="fooPart">Bazz</div>
  </template>
</my-element>
```

The one problem with parts though is that many elements can have the same part name, although this might not be a big deal as we can already have multiple elements with the same id attribute, if we were being consistent with that we'd just ignore all but the first.

Alternatively again this could even be a part of the url similar to scroll-to-text-fragment, e.g. `<a href="#myId:~:part=myPart">`, although this would be trickier with CSS (maybe?).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/924#issuecomment-840103507

Received on Wednesday, 12 May 2021 21:18:59 UTC