Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: tools/dom/src/dartium_CustomElementSupport.dart

Issue 1391143006: Fixed native element extension, custom events, _VMUpgrader, and data binding. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged conflicts Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/src/dartium_CustomElementSupport.dart
diff --git a/tools/dom/src/dartium_CustomElementSupport.dart b/tools/dom/src/dartium_CustomElementSupport.dart
index 85ff4d6aca78a57460bc5bff8ee08d3dd4ab552c..c91ab72034051200832e2bb5ca8e29b0265eb8ce 100644
--- a/tools/dom/src/dartium_CustomElementSupport.dart
+++ b/tools/dom/src/dartium_CustomElementSupport.dart
@@ -8,9 +8,11 @@ part of dart.dom.html;
class _VMElementUpgrader implements ElementUpgrader {
final Type _type;
final Type _nativeType;
+ final String _extendsTag;
_VMElementUpgrader(Document document, Type type, String extendsTag) :
_type = type,
+ _extendsTag = extendsTag,
_nativeType = _validateCustomType(type).reflectedType {
if (extendsTag == null) {
@@ -28,20 +30,39 @@ class _VMElementUpgrader implements ElementUpgrader {
Element upgrade(element) {
var jsObject;
- var tag = _getCustomElementName(element);
+ var tag;
+ var isNativeElementExtension = false;
+
+ try {
+ tag = _getCustomElementName(element);
+ } catch (e) {
+ isNativeElementExtension = element.localName == _extendsTag;
+ }
+
if (element.runtimeType == HtmlElement || element.runtimeType == TemplateElement) {
+ if (tag != _extendsTag) {
+ throw new UnsupportedError('$tag is not registered.');
+ }
jsObject = unwrap_jso(element);
} else if (element.runtimeType == js.JsObjectImpl) {
// It's a Polymer core element (written in JS).
jsObject = element;
- } else {
+ } else if (isNativeElementExtension) {
+ // Extending a native element.
+ jsObject = element.blink_jsObject;
+
+ // Element to extend is the real tag.
+ tag = element.localName;
+ } else if (tag != null && element.localName != tag) {
+ throw new UnsupportedError('Element is incorrect type. Got ${element.runtimeType}, expected native Html or Svg element to extend.');
+ } else if (tag == null) {
throw new UnsupportedError('Element is incorrect type. Got ${element.runtimeType}, expected HtmlElement/JsObjectImpl.');
}
// Remember Dart class to tagName for any upgrading done in wrap_jso.
- _addCustomElementType(tag, _type);
+ _addCustomElementType(tag, _type, _extendsTag);
- return createCustomUpgrader(_nativeType, jsObject);
+ return createCustomUpgrader(_type, jsObject);
}
}
« no previous file with comments | « tests/html/html.status ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698