是否可以在 Polymer 中的 <content> 节点上使用自定义属性以获得漂亮的 API?

Is it possible to use custom attributes on <content> nodes in Polymer for a beautiful API?

我将如何实现自定义元素 API 如:

<swiper-slider>
  <slide background="http://lorempixel.com/output/people-q-c-640-480-9.jpg"></slide>
  <slide>JUST TEXT!</slide>
</swiper-slider>

在聚合物中?我似乎无法弄清楚如何检查 background 是否已使用 JavaScript 在 slide 节点上设置或如何使用该属性。

我得到的最接近的是 data-background="..."nodes[ i ].dataset.background,其中节点是 nodes = this.$.content.getDistributedNodes()

非常感谢任何见解,特别是如果判决是不可能的!

只需遍历子节点并检查元素:

...
ready: function() {
 for(var i = 0; i < this.childNodes.length; i++) {
  var element = this.childNodes[i];

  if(element.tagName == "SLIDE") {
   switch(true) {
    // Credit here goes to John Smith, btw!
    case element.hasAttribute("background"): 
     var background = element.getAttribute("background");
     break;

    default:
     break;
   }
  }
}
...