How to skip the Shadow DOM (and use the Light DOM)

2019-07-04 21:18发布

Sometimes you may want to skip the Shadow DOM completely with Polymer.

1条回答
我只想做你的唯一
2楼-- · 2019-07-04 21:35

You can force your Polymer Element's template into the Light DOM by overriding parseDeclaration on your Polymer() JS/Coffeescript declaration.

Coffeescript Example:

Polymer "my-element",

  parseDeclaration: (elementElement) ->
    @lightFromTemplate(@fetchTemplate(elementElement))

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.

Edit: If there's a better way to do this, please let me know.

查看更多
登录 后发表回答