【发布时间】:2016-05-04 02:53:36
【问题描述】:
HTMLImports.whenReady 和 window.addEventListener('WebComponentsReady', function(e) { 有什么区别?
Polymer's official documentation 说:
“要在主 HTML 文档中定义元素,请从 HTMLImports.whenReady(callback) 定义元素。当文档中的所有导入完成加载时调用回调。”
Webcomponents.org's official documentation on imports 说:
在原生导入下,主文档中的标签会阻止加载导入。这是为了确保导入已加载并且其中的任何注册元素都已升级。这种原生行为很难 polyfill,因此 HTML Imports polyfill 不会尝试。相反,WebComponentsReady 事件代表了这种行为:
两者有什么区别?
【问题讨论】:
标签: javascript polymer web-component custom-element html-imports