OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.dom.html; | 5 part of dart.dom.html; |
6 | 6 |
7 /// Dartium ElementUpgrader implementation. | 7 /// Dartium ElementUpgrader implementation. |
8 class _VMElementUpgrader implements ElementUpgrader { | 8 class _VMElementUpgrader implements ElementUpgrader { |
9 final Type _type; | 9 final Type _type; |
10 final Type _nativeType; | 10 final Type _nativeType; |
(...skipping 26 matching lines...) Expand all Loading... |
37 tag = _getCustomElementName(element); | 37 tag = _getCustomElementName(element); |
38 } catch (e) { | 38 } catch (e) { |
39 isNativeElementExtension = element.localName == _extendsTag; | 39 isNativeElementExtension = element.localName == _extendsTag; |
40 } | 40 } |
41 | 41 |
42 if (element.runtimeType == HtmlElement || element.runtimeType == TemplateEle
ment) { | 42 if (element.runtimeType == HtmlElement || element.runtimeType == TemplateEle
ment) { |
43 if (tag != _extendsTag) { | 43 if (tag != _extendsTag) { |
44 throw new UnsupportedError('$tag is not registered.'); | 44 throw new UnsupportedError('$tag is not registered.'); |
45 } | 45 } |
46 jsObject = unwrap_jso(element); | 46 jsObject = unwrap_jso(element); |
47 } else if (element.runtimeType == js.JsObjectImpl) { | 47 } else if (element.runtimeType == js.JsObject) { |
48 // It's a Polymer core element (written in JS). | 48 // It's a Polymer core element (written in JS). |
49 jsObject = element; | 49 jsObject = element; |
50 } else if (isNativeElementExtension) { | 50 } else if (isNativeElementExtension) { |
51 // Extending a native element. | 51 // Extending a native element. |
52 jsObject = element.blink_jsObject; | 52 jsObject = element.blink_jsObject; |
53 | 53 |
54 // Element to extend is the real tag. | 54 // Element to extend is the real tag. |
55 tag = element.localName; | 55 tag = element.localName; |
56 } else if (tag != null && element.localName != tag) { | 56 } else if (tag != null && element.localName != tag) { |
57 throw new UnsupportedError('Element is incorrect type. Got ${element.runti
meType}, expected native Html or Svg element to extend.'); | 57 throw new UnsupportedError('Element is incorrect type. Got ${element.runti
meType}, expected native Html or Svg element to extend.'); |
58 } else if (tag == null) { | 58 } else if (tag == null) { |
59 throw new UnsupportedError('Element is incorrect type. Got ${element.runti
meType}, expected HtmlElement/JsObjectImpl.'); | 59 throw new UnsupportedError('Element is incorrect type. Got ${element.runti
meType}, expected HtmlElement/JsObject.'); |
60 } | 60 } |
61 | 61 |
62 // Remember Dart class to tagName for any upgrading done in wrap_jso. | 62 // Remember Dart class to tagName for any upgrading done in wrap_jso. |
63 addCustomElementType(tag, _type, _extendsTag); | 63 addCustomElementType(tag, _type, _extendsTag); |
64 | 64 |
65 return _createCustomUpgrader(_type, jsObject); | 65 return _createCustomUpgrader(_type, jsObject); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 /// Validates that the custom type is properly formed- | 69 /// Validates that the custom type is properly formed- |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 return nativeClass; | 116 return nativeClass; |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 bool _isBuiltinType(ClassMirror cls) { | 120 bool _isBuiltinType(ClassMirror cls) { |
121 // TODO(vsm): Find a less hackish way to do this. | 121 // TODO(vsm): Find a less hackish way to do this. |
122 LibraryMirror lib = cls.owner; | 122 LibraryMirror lib = cls.owner; |
123 String libName = lib.uri.toString(); | 123 String libName = lib.uri.toString(); |
124 return libName.startsWith('dart:'); | 124 return libName.startsWith('dart:'); |
125 } | 125 } |
OLD | NEW |