In principal HTML page: index.html
<poly-container a="Hi">
<poly-item b="hi"></poly-item>
</poly-container>
In Polymer HTML definition: polycontainer.html
<poly-container>
<template> ...
<content></content>
</template>
</poly-container>
In Dart class: polycontainer.dart ...Have tag <content>
for render external DOM; ...and the 2 classes: PolyContainer and PolyItem
processList() // calling from PolyContainer Constructor;
{
PolyItem cl;
HtmlElement a;
ContentElement cont=shadowRoot.querySelector('content');
List<Node> chil=cont.getDistributedNodes();
for (var i=0; i < chil.length; i++) {
if ( chil[i].nodeName == 'POLY-ITEM' ) {
a=chil[i]; // (1)
cl=chil[i] as PolyItem; // (2)
cl=a as PolyItem; // (3)
}
chil[i].remove();
}
}
(1) Cast OK; (chil[i] is type Node and "a" is type HtmlElement (Node->Element->HtmlElement)
(2)* Exception: type 'HtmlElement' is not a subtype of type 'PolyItem' in type cast.
(3)* Exception: type 'HtmlElement' is not a subtype of type 'PolyItem' in type cast.
Option 2 and 3 tested at different times.
I thought if we need to start some variable or call a function in the PolyItem constructor. Someone tried to cast an extended class PolymerElement?