File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ window.addEventListener("load", () => {
84
84
}
85
85
86
86
const codeId = node . firstChild . id
87
- let code = localStorage . getItem ( codeId ) || node . textContent
87
+ let code = ( window . localStorage && localStorage . getItem ( codeId ) ) || node . textContent
88
88
let wrap = node . parentNode . insertBefore ( elt ( "div" , { "class" : "editor-wrap" } ) , node )
89
89
let editor = CodeMirror ( div => wrap . insertBefore ( div , wrap . firstChild ) , {
90
90
value : code ,
@@ -104,7 +104,8 @@ window.addEventListener("load", () => {
104
104
clearTimeout ( pollingScroll )
105
105
pollingScroll = setTimeout ( pollScroll , 500 )
106
106
} )
107
- editor . on ( "change" , debounce ( ( ) => localStorage . setItem ( codeId , editor . getValue ( ) ) , 250 ) )
107
+ if ( window . localStorage )
108
+ editor . on ( "change" , debounce ( ( ) => localStorage . setItem ( codeId , editor . getValue ( ) ) , 250 ) )
108
109
wrap . style . marginLeft = wrap . style . marginRight = - Math . min ( article . offsetLeft , 100 ) + "px"
109
110
setTimeout ( ( ) => editor . refresh ( ) , 600 )
110
111
if ( e ) {
You can’t perform that action at this time.
0 commit comments