Custom elements not detecting children when instantiated in template of another custom element

放肆的年华 提交于 2019-12-08 03:31:32
Günter Zöchbauer

The constructor is just the wrong place. You need to allow the elements to properly initialize before using them.

Try

@override
void attached() {
  super.attached();
  print("NUM CHILDREN " + this.children.length.toString());
}

see also Justins answer here When is shadowRoot available to a polymer component?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!