我尝试过在chrome扩展中通过原生javascript和聚合物注册自定义元素,但没有成功。The issue is documented here。
Uncaught NotSupportedError: Failed to execute 'registerElement' on 'Document': Registration failed for type 'polymer-element'. Elements cannot be registered from extensions.
我正在寻找在扩展中使用web组件的建议--有人这样做过吗?我的直觉是使用标准的html标签(div等)注册这些元素。暂时放在影子DOM上,直到它被支持。有什么建议吗?
发布于 2017-08-01 05:11:37
在2017年7月解决了这个问题。我找到的最简单的解决方案是加载最新的webcomponents polyfill for custom elements作为额外的内容脚本。polyfill文件中不需要更改代码(可能改进了特征检测)。
从清单中摘录:
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["webcomponents-sd-ce.js", "contentscript.js"]
}
]
https://stackoverflow.com/questions/30022350
复制相似问题