Skip to content

Commit

Permalink
Handle 'Access is denied for this document'
Browse files Browse the repository at this point in the history
Update #1022
  • Loading branch information
mar10 committed Aug 1, 2020
1 parent 29d0655 commit f840149
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# 2.36.2 / Unreleased
* [Fixed] #1022 ext-persist: Handle 'Access is denied for this document'

# 2.36.1 / 2020-07-25
* [Fixed] #1021 ext-dnd5 Regression in drop marker
* [Fixed] #1021 ext-dnd5 Regression (#1012) in drop marker

# 2.36.0 / 2020-07-15
* [Changed] #1005 Cast key to string in getNodeByKey()
Expand Down
63 changes: 37 additions & 26 deletions src/jquery.fancytree.persist.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,38 +35,49 @@
* Private functions and variables
*/
var cookieStore = null,
localStorageStore = window.localStorage
? {
get: function(key) {
return window.localStorage.getItem(key);
},
set: function(key, value) {
window.localStorage.setItem(key, value);
},
remove: function(key) {
window.localStorage.removeItem(key);
},
}
: null,
sessionStorageStore = window.sessionStorage
? {
get: function(key) {
return window.sessionStorage.getItem(key);
},
set: function(key, value) {
window.sessionStorage.setItem(key, value);
},
remove: function(key) {
window.sessionStorage.removeItem(key);
},
}
: null,
localStorageStore = null,
sessionStorageStore = null,
_assert = $.ui.fancytree.assert,
ACTIVE = "active",
EXPANDED = "expanded",
FOCUS = "focus",
SELECTED = "selected";

// Accessing window.xxxStorage may raise security exceptions (see #1022)
try {
_assert(window.localStorage && window.localStorage.getItem);
localStorageStore = {
get: function(key) {
return window.localStorage.getItem(key);
},
set: function(key, value) {
window.localStorage.setItem(key, value);
},
remove: function(key) {
window.localStorage.removeItem(key);
},
};
} catch (e) {
$.ui.fancytree.warn("Could not access window.localStorage", e);
}

try {
_assert(window.sessionStorage && window.sessionStorage.getItem);
sessionStorageStore = {
get: function(key) {
return window.sessionStorage.getItem(key);
},
set: function(key, value) {
window.sessionStorage.setItem(key, value);
},
remove: function(key) {
window.sessionStorage.removeItem(key);
},
};
} catch (e) {
$.ui.fancytree.warn("Could not access window.sessionStorage", e);
}

if (typeof Cookies === "function") {
// Assume https://github.com/js-cookie/js-cookie
cookieStore = {
Expand Down

0 comments on commit f840149

Please sign in to comment.