如何跳过Polymer模板的Shadow DOM(并使用Light DOM) [英] How to skip the Shadow DOM (and use the Light DOM) instead for Polymer templates
本文介绍了如何跳过Polymer模板的Shadow DOM(并使用Light DOM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有时您可能希望使用Polymer完全跳过Shadow DOM.
Sometimes you may want to skip the Shadow DOM completely with Polymer.
推荐答案
您可以通过覆盖Polymer()
JS/Coffeescript声明上的parseDeclaration
来将Polymer Element的模板强制进入Light DOM.
You can force your Polymer Element's template into the Light DOM by overriding parseDeclaration
on your Polymer()
JS/Coffeescript declaration.
咖啡示例:
Polymer "my-element",
parseDeclaration: (elementElement) ->
@lightFromTemplate(@fetchTemplate(elementElement))
当然,您必须要小心,因为如果模板中的任何内容都属于Shadow DOM(例如样式表),那么它将现在位于Light DOM中.
Of course, you have to be careful because if you have anything that belongs in the Shadow DOM (like a stylesheet) in your template, it will now be in the Light DOM.
如果有更好的方法可以做到这一点,请告诉我.
If there's a better way to do this, please let me know.
这篇关于如何跳过Polymer模板的Shadow DOM(并使用Light DOM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文