| 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 10 matching lines...) Expand all Loading... |
| 21 } else { | 21 } else { |
| 22 if (document.createElement(extendsTag).runtimeType != _nativeType) { | 22 if (document.createElement(extendsTag).runtimeType != _nativeType) { |
| 23 throw new UnsupportedError( | 23 throw new UnsupportedError( |
| 24 'extendsTag does not match base native class'); | 24 'extendsTag does not match base native class'); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 } | 27 } |
| 28 | 28 |
| 29 Element upgrade(element) { | 29 Element upgrade(element) { |
| 30 var jsObject; | 30 var jsObject; |
| 31 var tag; | 31 var tag = _getCustomElementName(element); |
| 32 if (element.runtimeType == HtmlElement) { | 32 if (element.runtimeType == HtmlElement || element.runtimeType == TemplateEle
ment) { |
| 33 jsObject = unwrap_jso(element); | 33 jsObject = unwrap_jso(element); |
| 34 tag = element.localName; | |
| 35 } else if (element.runtimeType == js.JsObjectImpl) { | 34 } else if (element.runtimeType == js.JsObjectImpl) { |
| 36 // It's a Polymer core element (written in JS). | 35 // It's a Polymer core element (written in JS). |
| 37 jsObject = element; | 36 jsObject = element; |
| 38 tag = element['localName']; | |
| 39 } else { | 37 } else { |
| 40 throw new UnsupportedError('Element is incorrect type. Got ${element.runti
meType}, expected HtmlElement/JsObjectImpl.'); | 38 throw new UnsupportedError('Element is incorrect type. Got ${element.runti
meType}, expected HtmlElement/JsObjectImpl.'); |
| 41 } | 39 } |
| 42 | 40 |
| 43 // Remember Dart class to tagName for any upgrading done in wrap_jso. | 41 // Remember Dart class to tagName for any upgrading done in wrap_jso. |
| 44 _knownCustomeElements[tag] = _type; | 42 _knownCustomElements[tag] = _type; |
| 45 | 43 |
| 46 return createCustomUpgrader(_nativeType, jsObject); | 44 return createCustomUpgrader(_nativeType, jsObject); |
| 47 } | 45 } |
| 48 } | 46 } |
| 49 | 47 |
| 50 /// Validates that the custom type is properly formed- | 48 /// Validates that the custom type is properly formed- |
| 51 /// | 49 /// |
| 52 /// * Is a user-defined class. | 50 /// * Is a user-defined class. |
| 53 /// * Has a created constructor with zero args. | 51 /// * Has a created constructor with zero args. |
| 54 /// * Derives from an Element subclass. | 52 /// * Derives from an Element subclass. |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 return nativeClass; | 95 return nativeClass; |
| 98 } | 96 } |
| 99 | 97 |
| 100 | 98 |
| 101 bool _isBuiltinType(ClassMirror cls) { | 99 bool _isBuiltinType(ClassMirror cls) { |
| 102 // TODO(vsm): Find a less hackish way to do this. | 100 // TODO(vsm): Find a less hackish way to do this. |
| 103 LibraryMirror lib = cls.owner; | 101 LibraryMirror lib = cls.owner; |
| 104 String libName = lib.uri.toString(); | 102 String libName = lib.uri.toString(); |
| 105 return libName.startsWith('dart:'); | 103 return libName.startsWith('dart:'); |
| 106 } | 104 } |
| OLD | NEW |