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 1df549ea47fd88a320ab661c4723aa1138c2c771..6cbf8834c304007bd76bf39e558b0f723418a2c6 100644 |
--- a/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate |
+++ b/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate |
@@ -436,6 +436,13 @@ $else |
// |
// See https://github.com/dart-lang/sdk/issues/23666 |
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) { |
if (_getJSClassName(reflectClass(customElementClass).superclass) != null && creating < 2) { |
@@ -474,15 +481,27 @@ $else |
creating--; |
} |
} |
+ |
+ if (oldCreatedCallback != null) |
+ oldCreatedCallback.apply([], thisArg: unwrap_jso($this)); |
}); |
elemProto['attributeChangedCallback'] = new js.JsFunction.withThis(($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) { |
$this.attached(); |
+ |
+ if (oldAttachedCallback != null) |
+ oldAttachedCallback.apply([], thisArg: unwrap_jso($this)); |
}); |
elemProto['detachedCallback'] = new js.JsFunction.withThis(($this) { |
$this.detached(); |
+ |
+ if (oldDetachedCallback != null) |
+ oldDetachedCallback.apply([], thisArg: unwrap_jso($this)); |
}); |
// document.registerElement('x-foo', {prototype: elemProto, extends: extendsTag}); |
var jsMap = new js.JsObject.jsify({'prototype': elemProto, 'extends': extendsTag}); |