在 Polymer 组件中找不到 shadow-root 但有效,为什么?

No shadow-root found in Polymer component but works, why?

Polymer 在 docs.

处为其组件使用阴影 DOM

我正在研究 github 中 Hello-World 的一个非常基本的示例: https://github.com/webcomponents/hello-world-polymer

我正在检查 demo我找不到任何 shadow-root

我用过Polymer,之前用过shadow-root,但是为什么这个组件没有shadow-root?因为一些优化?

没有 shadow-root 因为他们使用 polyfilled Shadow DOM 作为 v0 规范而不是浏览器支持的当前规范 (v1)。

您提供的演示是使用 Polymer 1 构建的(根据 hello-world.html 源代码,因为它使用 Polymer() 函数和弃用的 HTML 导入)。 Polymer 1 建立在 Web Components v0 规范(Custom Elements v0、Shadow DOM v0 和 HTML Imports)之上,这些规范现已弃用并由 Shadow DOM v1 和 Custom Elements v1 取代。