锚标记<a id="jump"> with hash inside shadow dom

时间:2017-04-15 11:18:25

标签: html shadow-dom custom-element

I would like to use an anchor-element with a hash-URL inside of a custom element that uses shadow DOM. I would expect, that the browser scrolls down to that anchor, but it does not do it (at least Chrome).

Detail:

I have an index.html like this:

...
<a href="#destinationInsideShadowDOM">Jump</a>
...
<my-custom-element></my-custom-element>
...

And another html-file for the custom-element, which contains the anchor:

<template id="my-custom-element">
   ...
   <a id="destinationInsideShadowDOM"></a>
   ...
</template>

I want the browser to scroll down to that anchor when I click on the link in index.html.

When I move the anchor into index.html, outside of the custom-element, it works, but not inside.

0 个答案:

没有答案