Index: tools/dom/src/native_DOMImplementation.dart |
diff --git a/tools/dom/src/native_DOMImplementation.dart b/tools/dom/src/native_DOMImplementation.dart |
index e650c6fd0c5c0aef41f0256b35e434d6420ea27e..a5d923b4377dda9a1cc6417ea3369c398e87c9ca 100644 |
--- a/tools/dom/src/native_DOMImplementation.dart |
+++ b/tools/dom/src/native_DOMImplementation.dart |
@@ -411,8 +411,31 @@ class _Utils { |
} |
var className = MirrorSystem.getName(cls.simpleName); |
if (!cls.constructors.containsKey(new Symbol('$className.created'))) { |
- throw new UnsupportedError('Class is missing constructor $className.created'); |
+ throw new UnsupportedError( |
+ 'Class is missing constructor $className.created'); |
} |
+ |
+ Symbol objectName = reflectClass(Object).qualifiedName; |
+ bool isRoot(ClassMirror cls) => |
+ cls == null || cls.qualifiedName == objectName; |
+ Symbol elementName = reflectClass(HtmlElement).qualifiedName; |
+ bool isElement(ClassMirror cls) => |
+ cls != null && cls.qualifiedName == elementName; |
+ ClassMirror superClass = cls.superclass; |
+ ClassMirror nativeClass = _isBuiltinType(superClass) ? superClass : null; |
+ while(!isRoot(superClass) && !isElement(superClass)) { |
+ superClass = superClass.superclass; |
+ if (nativeClass == null && _isBuiltinType(superClass)) { |
+ nativeClass = superClass; |
+ } |
+ } |
+ if (extendsTagName == null) { |
+ if (nativeClass.reflectedType != HtmlElement) { |
+ throw new UnsupportedError('Class must provide extendsTag if base ' |
+ 'native class is not HTMLElement'); |
+ } |
+ } |
+ |
_register(document, tag, type, extendsTagName); |
} |