Skip to content

Commit

Permalink
πŸ› Use __proto__ instead of setPrototypeOf (#24781)
Browse files Browse the repository at this point in the history
* Use __proto__ instead of setPrototypeOf

We're getting an error from `setPrototypeOf` somehow not being a method on `Object`.

* WHY DO I ALWAYS DO THIS?!?!
  • Loading branch information
jridgewell committed Sep 27, 2019
1 parent 814b534 commit 885cd5b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/polyfills/custom-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -770,11 +770,11 @@ function polyfill(win) {
el = createElement.call(document, def.name);
}

// Finally, if the node was already constructed, we need to reset it's
// Finally, if the node was already constructed, we need to reset its
// prototype to the custom element prototype. And if it wasn't already
// constructed, we created a new node via native createElement, and we need
// to reset it's prototype. Basically always reset the prototype.
Object.setPrototypeOf(el, constructor.prototype);
// to reset its prototype. Basically always reset the prototype.
el.__proto__ = constructor.prototype;
return el;
}
subClass(Object, HTMLElement, HTMLElementPolyfill);
Expand Down Expand Up @@ -830,6 +830,7 @@ function subClass(Object, superClass, subClass) {
value: subClass,
},
});
subClass.__proto__ = superClass;
}

/**
Expand Down

0 comments on commit 885cd5b

Please sign in to comment.