attachShadow return 不是#shadow-root 的#document-fragment 可以吗?

Can a attachShadow return a #document-fragment that isn't a #shadow-root?

我没有在 Chrome 中使用 polyfill,在某些情况下,我发现自定义元素中的 this.shadowRoot#document-fragment 而不是 #shadow-root .

例如,这是我的自定义元素中的一些代码,当我将鼠标悬停在调试器中时,看看它说了什么:

我期待看到 #shadow-root

是否有一个升级过程,在一段时间内,#document-fragment 最初还不是 #shadow-root

shadowRoot 属性 应始终为 #document-fragment / DocumentFragment.

类型

根据 WHATWG DOM specs:

interface ShadowRoot : DocumentFragment {

readonly attribute ShadowRootMode mode;
readonly attribute Element host;

};

您应该只在 Element 窗格中看到 #shadow-root

您应该会在 Sources 窗格中看到 #document-fragment