Bug 1121994 - Implement adopted callback for custom elements.

Tag UXP Issue #1344
This commit is contained in:
Gaming4JC 2020-01-05 18:15:57 -05:00 committed by Roy Tam
commit d35ff2985e
14 changed files with 76 additions and 130 deletions

View file

@ -526,6 +526,23 @@ nsNodeUtils::CloneAndAdopt(nsINode *aNode, bool aClone, bool aDeep,
nsIDocument* newDoc = aNode->OwnerDoc();
if (newDoc) {
if (CustomElementRegistry::IsCustomElementEnabled()) {
// Adopted callback must be enqueued whenever a nodes
// shadow-including inclusive descendants that is custom.
Element* element = aNode->IsElement() ? aNode->AsElement() : nullptr;
if (element) {
RefPtr<CustomElementData> data = element->GetCustomElementData();
if (data && data->mState == CustomElementData::State::eCustom) {
LifecycleAdoptedCallbackArgs args = {
oldDoc,
newDoc
};
nsContentUtils::EnqueueLifecycleCallback(nsIDocument::eAdopted,
element, nullptr, &args);
}
}
}
// XXX what if oldDoc is null, we don't know if this should be
// registered or not! Can that really happen?
if (wasRegistered) {