Bug 1413418 - Part 2: Keep processing remaining elements in ElementQueue even if some of elements are already unlinked
MozReview-Commit-ID: B8D5q6PbFFS
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -1156,27 +1156,22 @@ CustomElementReactionsStack::InvokeReact
// This is used for error reporting.
Maybe<AutoEntryScript> aes;
if (aGlobal) {
aes.emplace(aGlobal, "custom elements reaction invocation");
}
// Note: It's possible to re-enter this method.
for (uint32_t i = 0; i < aElementQueue->Length(); ++i) {
- Element* element = aElementQueue->ElementAt(i);
-
- if (!element) {
- continue;
- }
-
+ const RefPtr<Element>& element = aElementQueue->ElementAt(i);
RefPtr<CustomElementData> elementData = element->GetCustomElementData();
if (!elementData) {
// This happens when the document is destroyed and the element is already
// unlinked, no need to fire the callbacks in this case.
- return;
+ continue;
}
auto& reactions = elementData->mReactionQueue;
for (uint32_t j = 0; j < reactions.Length(); ++j) {
// Transfer the ownership of the entry due to reentrant invocation of
// this funciton. The entry will be removed when bug 1379573 is landed.
auto reaction(Move(reactions.ElementAt(j)));
if (reaction) {