Bug 1792028 - Apply the lazy defineLazyPreferenceGetter workaround to browser-sidebar.js. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D157932
This commit is contained in:
Andrew McCreight 2022-09-22 15:07:57 +00:00
Родитель 2fecef1b02
Коммит db4c1e8525
1 изменённых файлов: 11 добавлений и 1 удалений

Просмотреть файл

@ -662,6 +662,10 @@ var SidebarUI = {
},
};
/* Work around the pref callback being run after the document has been unlinked.
See bug 1543537. */
var docWeak = Cu.getWeakReference(document);
// Add getters related to the position here, since we will want them
// available for both startDelayedLoad and init.
XPCOMUtils.defineLazyPreferenceGetter(
@ -669,5 +673,11 @@ XPCOMUtils.defineLazyPreferenceGetter(
"_positionStart",
SidebarUI.POSITION_START_PREF,
true,
SidebarUI.setPosition.bind(SidebarUI)
() => {
let doc = docWeak.get();
if (!doc) {
return;
}
SidebarUI.setPosition();
}
);