Using template defined in light dom inside a Polymer element

后端 未结 1 1053
小蘑菇
小蘑菇 2020-12-10 08:18

I\'m trying to get a template moved from the DOM to inside the element.

Here is my elements:



        
1条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-10 08:33

    To use the (light dom) content of a custom element you need to include an insertion point in your element ():

    http://www.polymer-project.org/platform/shadow-dom.html#shadow-dom-subtrees

    However, insertion points are purely placeholders for rendering nodes in the shadow DOM. What you're after is a bit different because it's using Polymer's data binding features to bridge the light dom world outside of your Polymer element, with the shadow dom world inside of it.

    I was able to get things working by dynamically creating the