| Index: tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| diff --git a/tools/dom/templates/html/dartium/html_dartium.darttemplate b/tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| index bb286402efe2af2cd13c1147b710fc85606c67dd..9bd24f0b78f54de6e6ea1ec344a701fb2b2698b2 100644
|
| --- a/tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| +++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate
|
| @@ -355,6 +355,12 @@ Function _getSvgFunction(String key) {
|
| // List of known tagName to DartClass for custom elements, used for upgrade.
|
| var _knownCustomElements = new Map<String, Type>();
|
|
|
| +void _addCustomElementType(String tagName, Type dartClass) {
|
| + _knownCustomElements[tagName] = dartClass;
|
| +}
|
| +
|
| +Type _getCustomElementType(object) => _knownCustomElements[_getCustomElementName(object)];
|
| +
|
| // Return the tag name or is attribute of the custom element or data binding.
|
| String _getCustomElementName(element) {
|
| var jsObject;
|
| @@ -430,8 +436,7 @@ wrap_jso(jsObject) {
|
| if (wrapper != null) {
|
| if (wrapper.runtimeType == HtmlElement && !wrapper._isBadUpgrade) {
|
| // We're a Dart instance but we need to upgrade.
|
| - var tagName = _getCustomElementName(wrapper);
|
| - var customElementClass = _knownCustomElements[tagName];
|
| + var customElementClass = _getCustomElementType(wrapper);
|
| if (customElementClass != null) {
|
| var dartClass_instance;
|
| try {
|
| @@ -483,8 +488,7 @@ wrap_jso(jsObject) {
|
| // make sure it's upgraded.
|
| dartClass_instance = _upgradeHtmlElement(jsObject['dart_class']);
|
| } else {
|
| - var tagName = _getCustomElementName(jsObject);
|
| - var customElementClass = _knownCustomElements[tagName];
|
| + var customElementClass = _getCustomElementType(jsObject);
|
| // Custom Element to upgrade.
|
| if (jsTypeName == 'HTMLElement' && customElementClass != null) {
|
| try {
|
| @@ -503,6 +507,12 @@ wrap_jso(jsObject) {
|
| }
|
|
|
| var func = getHtmlCreateFunction(jsTypeName);
|
| + if (func == null) {
|
| + // One last ditch effort could be a JS custom element.
|
| + if (jsObject.toString() == "[object HTMLElement]") {
|
| + func = getHtmlCreateFunction("HTMLElement");
|
| + }
|
| + }
|
| if (func != null) {
|
| dartClass_instance = func();
|
| dartClass_instance.blink_jsObject = jsObject;
|
| @@ -629,11 +639,12 @@ _upgradeHtmlElement(dartInstance) {
|
| // don't try it again - one failure is enough.
|
| if (dartInstance.runtimeType == HtmlElement && !dartInstance._isBadUpgrade) {
|
| // Must be exactly HtmlElement not something derived from it.
|
| - var jsObject = dartInstance.blink_jsObject;
|
| - var tagName = _getCustomElementName(dartInstance);
|
| - var customElementClass = _knownCustomElements[tagName];
|
| +
|
| + var customElementClass = _getCustomElementType(dartInstance);
|
| +
|
| // Custom Element to upgrade.
|
| if (customElementClass != null) {
|
| + var jsObject = dartInstance.blink_jsObject;
|
| try {
|
| dartInstance = _blink.Blink_Utils.constructElement(customElementClass, jsObject);
|
| } catch (e) {
|
|
|