Created
October 6, 2016 19:27
-
-
Save domenic/507d42421403bc3f4a4e6cfb05f1cb36 to your computer and use it in GitHub Desktop.
A use for adoptedCallback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That would be amazing for both incremental upgrades and hot-reloading (two pain points of SWC's)