| Index: tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
|
| diff --git a/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate b/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
|
| index 61fc7150a0350e5b6e9b6180ac2e9fee432f6886..1a12fb8a49f7430ae03f5ca3e4448d1104306adc 100644
|
| --- a/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
|
| +++ b/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate
|
| @@ -413,7 +413,6 @@ $else
|
| }
|
| var elemProto = js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'Object'), "create", [js.JsNative.getProperty(baseElement, 'prototype')]);
|
|
|
| - // Remember for any upgrading done in wrap_jso.
|
| addCustomElementType(tag, customElementClass, extendsTag);
|
|
|
| // TODO(terry): Hack to stop recursion re-creating custom element when the
|
| @@ -430,13 +429,14 @@ $else
|
| int creating = 0;
|
|
|
| // If any JS code is hooked we want to call it too.
|
| - var oldCreatedCallback = elemProto['createdCallback'];
|
| - var oldAttributeChangedCallback = elemProto['attributeChangedCallback'];
|
| - var oldAttachedCallback = elemProto['attachedCallback'];
|
| - var oldDetachedCallback = elemProto['detachedCallback'];
|
| -
|
| - // TODO(jacobr): warning:
|
| - elemProto['createdCallback'] = js.JsNative.withThis(($this) {
|
| + var oldCreatedCallback = js.JsNative.getProperty(elemProto, 'createdCallback');
|
| + var oldAttributeChangedCallback = js.JsNative.getProperty(elemProto, 'attributeChangedCallback');
|
| + var oldAttachedCallback = js.JsNative.getProperty(elemProto, 'attachedCallback');
|
| + var oldDetachedCallback = js.JsNative.getProperty(elemProto, 'detachedCallback');
|
| +
|
| + // TODO(jacobr): this code seems far more complex than it should be
|
| + // unless I am missing something.
|
| + js.JsNative.setProperty(elemProto, 'createdCallback', js.allowInteropCaptureThis(($this) {
|
| if (_getJSClassName(reflectClass(customElementClass).superclass) != null && creating < 2) {
|
| creating++;
|
|
|
| @@ -447,18 +447,17 @@ $else
|
| // Then upgrade that element to the customElementClass through
|
| // normal flow.
|
| dartClass = document.createElement(extendsTag);
|
| - js.setDartHtmlWrapperFor($this, dartClass);
|
| - dartClass.blink_jsObject = $this;
|
| + // TODO(jacobr): THIS MAKES NO SENSE. WAAT?
|
| +
|
| + $this = js.JsNative.$setInstanceInterceptor($this, dartClass.runtimeType);
|
| + dartClass = $this; // THIS IS CRAZY CODE CODE BUT IT MATCHES WHAT HAD. WTH.. THIS CODE JUST SEEMS WRONG.
|
| }
|
|
|
| // Upgrade to the CustomElement Dart class.
|
| dartClass = _blink.Blink_Utils.constructElement(customElementClass, $this);
|
| } catch (e) {
|
| // Got a problem make it an HtmlElement and rethrow the error.
|
| - dartClass = HtmlElement.internalCreateHtmlElement();
|
| - // We need to remember the JS object (because constructElement failed
|
| - // it normally sets up the blink_jsObject.
|
| - dartClass.blink_jsObject = $this;
|
| + dartClass = js.JsNative.$setInstanceInterceptor($this, new HtmlElement.internalCreateHtmlElement().runtimeType);
|
|
|
| // Mark to only try this once don't try upgrading from HtmlElement
|
| // to the user's Dart class - we had a problem.
|
| @@ -469,35 +468,36 @@ $else
|
| // return it and setup the blink_jsObject to the $this that we'll be working
|
| // with as we talk to blink.
|
| js.setDartHtmlWrapperFor($this, dartClass);
|
| -
|
| + // TODO(jacobr) THIS MAKES NO SENSE BUT MATCHES WHAT WE HAD BEFORE.
|
| + js.JsNative.$setInstanceInterceptor($this, dartClass.runtimeType);
|
| creating--;
|
| }
|
| }
|
|
|
| if (oldCreatedCallback != null)
|
| - oldCreatedCallback.apply([], thisArg: unwrap_jso($this));
|
| - });
|
| - elemProto['attributeChangedCallback'] = new js.JsFunction.withThis(($this, attrName, oldVal, newVal) {
|
| + oldCreatedCallback.apply([], thisArg: $this);
|
| + }));
|
| + js.JsNative.setProperty(elemProto, 'attributeChangedCallback', js.allowInteropCaptureThis(($this, attrName, oldVal, newVal) {
|
| $this.attributeChanged(attrName, oldVal, newVal);
|
|
|
| if (oldAttributeChangedCallback != null)
|
| - oldAttributeChangedCallback.apply([], thisArg: unwrap_jso($this));
|
| - });
|
| - elemProto['attachedCallback'] = new js.JsFunction.withThis(($this) {
|
| + oldAttributeChangedCallback.apply([], thisArg: $this);
|
| + }));
|
| + js.JsNative.setProperty(elemProto, 'attachedCallback', js.allowInteropCaptureThis(($this) {
|
| $this.attached();
|
|
|
| if (oldAttachedCallback != null)
|
| - oldAttachedCallback.apply([], thisArg: unwrap_jso($this));
|
| - });
|
| - elemProto['detachedCallback'] = new js.JsFunction.withThis(($this) {
|
| + oldAttachedCallback.apply([], thisArg: $this);
|
| + }));
|
| + js.JsNative.setProperty(elemProto, 'detachedCallback', js.allowInteropCaptureThis(($this) {
|
| $this.detached();
|
|
|
| if (oldDetachedCallback != null)
|
| - oldDetachedCallback.apply([], thisArg: unwrap_jso($this));
|
| - });
|
| + oldDetachedCallback.apply([], thisArg: $this);
|
| + }));
|
| // document.registerElement('x-foo', {prototype: elemProto, extends: extendsTag});
|
| var jsMap = new js.JsObject.jsify({'prototype': elemProto, 'extends': extendsTag});
|
| - js.JsNative.callMethod(js.JsNative.getProperty(js.context, 'document'), 'registerElement', [tag, jsMap]);
|
| + js.JsNative.callMethod(document, 'registerElement', [tag, jsMap]);
|
| }
|
| $endif
|
| }
|
|
|