캐스트 : index.html을 폴리머 HTML의 정의에서아니오 주요 HTML 페이지에서 폴리머 요소
<poly-container a="Hi">
<poly-item b="hi"></poly-item>
</poly-container>
: 다트 클래스에서
<poly-container>
<template> ...
<content></content>
</template>
</poly-container>
polycontainer.html : polycontainer.dart ... 외부 DOM 렌더링을 위해 <content>
태그를 가지고 있습니다. ... 그리고 두 클래스 : PolyContainer 및 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) 캐스트 OK; (chil [i]는 Node 유형이고 "a"는 HtmlElement (Node-> Element-> HtmlElement) 유형입니다.
* 예외 : 'HtmlElement'유형이 유형 캐스트의 유형의 하위 유형이 아닙니다 .
(3) * 예외 :.. 우리가 필요로하는 경우 유형이 '는 HTMLElement가'형 캐스트 'PolyItem'유형의 하위 유형 아니다
서로 다른 시간에 테스트 옵션 2, 3
나는 생각 일부 변수를 시작하거나 PolyItem 생성자에서 함수를 호출합니다. 누군가가 확장 클래스 PolymerElement를 캐스팅하려고 했습니까?