未验证 提交 681f4818 编写于 作者: M Matthew Peveler 提交者: GitHub

Add guards around localStorage in case user disables it (#1399)

Signed-off-by: NMatthew Peveler <matt.peveler@gmail.com>
上级 e3a3a3a8
......@@ -129,11 +129,16 @@ under the License.
history.pushState({}, '', '?' + generateNewQueryString(language) + '#' + hash);
// save language as next default
localStorage.setItem("language", language);
if (localStorage) {
localStorage.setItem("language", language);
}
}
function setupLanguages(l) {
var defaultLanguage = localStorage.getItem("language");
var defaultLanguage = null;
if (localStorage) {
defaultLanguage = localStorage.getItem("language");
}
languages = l;
......@@ -142,7 +147,9 @@ under the License.
// the language is in the URL, so use that language!
activateLanguage(presetLanguage);
localStorage.setItem("language", presetLanguage);
if (localStorage) {
localStorage.setItem("language", presetLanguage);
}
} else if ((defaultLanguage !== null) && (jQuery.inArray(defaultLanguage, languages) != -1)) {
// the language was the last selected one saved in localstorage, so use that language!
activateLanguage(defaultLanguage);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册