Skip to content

Commit

Permalink
Remove connected callback externs and typecast instead
Browse files Browse the repository at this point in the history
  • Loading branch information
rcebulko committed May 5, 2021
1 parent 4296522 commit 31cf506
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 0 additions & 9 deletions src/polyfills/custom-elements.extern.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,3 @@
// window externs file.
/** @type {!typeof HTMLElement} */
window.HTMLElementOrig;

// These callbacks are used for custom elements, but don't appear to belong to
// any available type definitions. There's a TODO(jridgewell) from ~2 years ago
// to call them differently; if that can be figured out, these may be dropped.
// If not, these may belong to a separate node.extern.js externs file.
/** @function @this {Node} */
Node.prototype.connectedCallback;
/** @function @this {Node} */
Node.prototype.disconnectedCallback;
4 changes: 3 additions & 1 deletion src/polyfills/custom-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ class Registry {
if (!def) {
return;
}
this.upgradeSelf_(/** @type {!Element} */ (node), def);
node = /** @type {!HTMLElement} */ (node);
this.upgradeSelf_(node, def);
// TODO(jridgewell): It may be appropriate to adoptCallback, if the node
// used to be in another doc.
// TODO(jridgewell): I should be calling the definitions connectedCallback
Expand All @@ -446,6 +447,7 @@ class Registry {
disconnectedCallback_(node) {
// TODO(jridgewell): I should be calling the definitions connectedCallback
// with node as the context.
node = /** @type {!HTMLElement} */ (node);
if (node.disconnectedCallback) {
try {
node.disconnectedCallback();
Expand Down

0 comments on commit 31cf506

Please sign in to comment.