Why do I get an Internal Dartium Exception when using custom elements?

三世轮回 提交于 2019-12-22 18:29:18

问题


I am seeing this error in my console:

Exception: InvalidStateError: Internal Dartium Exception
  PolymerDeclaration.registerType (package:polymer/src/declaration.dart:241:22)
  PolymerDeclaration.register (package:polymer/src/declaration.dart:175:17)
  PolymerDeclaration._register (package:polymer/src/declaration.dart:114:13)
  PolymerDeclaration.registerWhenReady (package:polymer/src/declaration.dart:109:14)
  _notifyType (package:polymer/src/declaration.dart:514:49)
  Polymer.register (package:polymer/src/instance.dart:64:16)
  _loadLibrary (package:polymer/src/loader.dart:177:25)

I have code like this:

@CustomTag('person-tag')
class PersonTag extends PolymerElement {

And my HTML is like this:

<polymer-element name="person-tag" extends="li">

Why am I getting this Internal Dartium Exception error from registerType ?


回答1:


You are seeing this error because your HTML says extends="li" but the Dart code only extends PolymerElement.

If you use an extends attribute in your polymer-element, then your Dart class must also extend the same kind of element.

To fix the problem in the question, change the Dart class:

@CustomTag('person-tag')
class PersonTag extends LIElement with Polymer, Observable {

Now PersonTag really does extend <li>.



来源:https://stackoverflow.com/questions/19556711/why-do-i-get-an-internal-dartium-exception-when-using-custom-elements

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