Skip to content

Commit

Permalink
Fix document.persist() in Firefox 63+
Browse files Browse the repository at this point in the history
  • Loading branch information
Infocatcher committed Sep 5, 2018
1 parent 0937d93 commit 23ebdd0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ var notificationPrefix = cbs.getNotificationPrefix(windowId);

this.toggleEnabled = function() {
this.checked = !this.checked;
document.persist(this.id, "checked");
if("persist" in document)
document.persist(this.id, "checked");
else // Firefox 63+
Services.xulStore.persist(this, "checked");
};
this.setAttribute("oncommand", "this.toggleEnabled();");

Expand Down
12 changes: 10 additions & 2 deletions CB_Editor_Toggle_on_Top/cbEditorToggleOnTop.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ if(!watcher) {
styleId: "cbToggleOnTopStyle",
get btnTip() {
var locale = (function() {
if("Services" in window && Services.locale && Services.locale.getRequestedLocales) { var locales = Services.locale.getRequestedLocales(); return locales && locales[0]; }
if("Services" in window && Services.locale && Services.locale.getRequestedLocales) {
var locales = Services.locale.getRequestedLocales();
return locales && locales[0];
}
var prefs = "Services" in window && Services.prefs
|| Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
Expand Down Expand Up @@ -324,7 +327,12 @@ if(!watcher) {
if(toggle) {
onTop = !onTop;
root.setAttribute(this.onTopAttr, onTop);
root.id && document.persist(root.id, this.onTopAttr);
if(root.id) {
if("persist" in document)
document.persist(root.id, this.onTopAttr);
else // Firefox 63+
Services.xulStore.persist(root, this.onTopAttr);
}
}
else if(!onTop) // Just opened or restored window always have zLevel == normalZ
return;
Expand Down
5 changes: 4 additions & 1 deletion Session_Bookmarks/sessionBookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,10 @@ this.bookmarks = {
delete window[key];
btn.removeAttribute(attr);
}
document.persist(btn.id, attr);
if("persist" in document)
document.persist(btn.id, attr);
else // Firefox 63+
Services.xulStore.persist(btn, attr);
return isEmpty;
},
initContextMenu: function(mi) {
Expand Down

0 comments on commit 23ebdd0

Please sign in to comment.