onAdoption
This livecycle function is called when the component element is moved from one document to another, for example, if the element is removed from a iFrame document to the current window document.
class BFSButton extends WebComponent {
static observedAttributes = ['label']
onAdoption() {
console.log('adopted')
}
}
BFSButton.register();
const btn = new BFSButton();
const iframe = document.body.querySelector('iframe');
// will trigger onMount call
document.body.appendChild(btn)
// will trigger onAdoption call
iframe.contentDocument.body.appendChild(btn)
CWCO automatically updates the component when attached to a different document. This lifecycle is just if you want to do something extra.