Skip to content

Instantly share code, notes, and snippets.

@domenic
Created October 6, 2016 19:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domenic/507d42421403bc3f4a4e6cfb05f1cb36 to your computer and use it in GitHub Desktop.
Save domenic/507d42421403bc3f4a4e6cfb05f1cb36 to your computer and use it in GitHub Desktop.
A use for adoptedCallback
adoptedCallback(oldDocument, newDocument) {
const newWindow = newDocument.defaultView;
if (newWindow) {
// newDocument belongs to a window
const otherConstructor = newWindow.customElements.get(this.localName);
if (otherConstructor && otherConstructor._isFromPolymer) {
Object.setPrototypeOf(this, otherConstructor.prototype);
// Now any customizations that newWindow code has applied to the
// prototype will apply over here.
}
}
}
@SMotaal
Copy link

SMotaal commented Sep 2, 2017

Have you done any testing across compliant browsers?

@SMotaal
Copy link

SMotaal commented Sep 2, 2017

That would be amazing for both incremental upgrades and hot-reloading (two pain points of SWC's)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment