Rendering a content tag as part of a template in polymer and dart

后端 未结 2 1523
萌比男神i
萌比男神i 2021-01-04 10:26

I wish to make a generic list using polymer and dart. I am extending the UL element to do so. I want to place template variables within the content of this custom element.<

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-04 11:27

    Unfortunately, there are two issues here.

    1. cannot be used like this. It's a placeholder for rendering light DOM nodes at specific locations in the Shadow DOM. The first that selects nodes, wins [1]. Stamping out a bunch like you're doing, while very intuitive, won't work as expected.

    2. You're mixing the internal world of Polymer with the external world outside the element. What this really means is that bindings (e.g. {{}}) only work in the context of .

    One thing you can do is create a copy of the distributed light DOM children as the items property of your element. In JavaScript this looks like:

    
    
    
    

    Note: The only reason I've used is to insure the element only takes in

  • nodes. If you're not worried about users using other types of elements, just use this.items = [].slice.call(this.children);.

提交回复
热议问题