仕様によると、それは動作しません。
http://www.w3.org/TR/shadow-dom/#content-insertion-points
次の条件をすべて満たすコンテンツ要素は、コンテンツ挿入ポイントを表します。
- コンテンツ要素のルート ノードはシャドウ ルートです
- content 要素の祖先に他の content 要素がない
- content 要素の祖先に shadow 要素がない
これを念頭に置いて、ネストされたコンテンツ要素でこれを機能させることはできないと思います。
これはうまくいきます。両方が適用された場合、カスタム アイコンが勝ちます
<polymer-element name="the-button">
<template>
<content id="contentButton" select=".useBtn">
<button id="PREFIXEDdefaultBtn">
Default Button
</button>
</content>
<button id="defaultBtnWithCustomIcon">
<!--be sure that this content element doesnt contain a default set -->
<content id="contentIcon" select=".useBtnIcon"></content>
</button>
</template>
<script>
Polymer('the-button', {
domReady: function () {
var customIcon = this.$.contentIcon;
var disNodes = customIcon.getDistributedNodes();
//Test if the content element contains distributed nodes.
if (disNodes.length !== 0) {
this.$.contentButton.remove();
} else {
// the button is customized, remove the icon
this.$.defaultBtnWithCustomIcon.remove();
}
}
});
</script>
</polymer-element>