Bug 1442020 - Make PanelMultiView's description height workaround account for the possibility that panels have closed before a refresh driver tick. r?paolo
MozReview-Commit-ID: IIjGYjoxMx5
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -1318,16 +1318,20 @@ var PanelView = class extends Associated
items.push({ element });
}
};
if (allowSyncReflows) {
collectItems();
} else {
await this.window.promiseDocumentFlushed(collectItems);
+ // Bail out if the panel was closed in the meantime.
+ if (!this.node.panelMultiView) {
+ return;
+ }
}
// Removing the 'height' property will only cause a layout flush in the next
// loop below if it was set.
for (let item of items) {
item.element.style.removeProperty("height");
}
@@ -1337,16 +1341,20 @@ var PanelView = class extends Associated
for (let item of items) {
item.bounds = item.element.getBoundingClientRect();
}
};
if (allowSyncReflows) {
measureItems();
} else {
await this.window.promiseDocumentFlushed(measureItems);
+ // Bail out if the panel was closed in the meantime.
+ if (!this.node.panelMultiView) {
+ return;
+ }
}
// Now we can make all the necessary DOM changes at once.
for (let { element, bounds } of items) {
gMultiLineElementsMap.set(element, { bounds, textContent: element.textContent });
element.style.height = bounds.height + "px";
}
}