anchor tag <a id=“jump”> with hash inside shadow dom

岁酱吖の 提交于 2019-12-22 08:32:04

问题


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.

来源:https://stackoverflow.com/questions/43425398/anchor-tag-a-id-jump-with-hash-inside-shadow-dom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!