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", () => {
8484 }
8585
8686 const codeId = node . firstChild . id
87- let code = localStorage . getItem ( codeId ) || node . textContent
87+ let code = ( window . localStorage && localStorage . getItem ( codeId ) ) || node . textContent
8888 let wrap = node . parentNode . insertBefore ( elt ( "div" , { "class" : "editor-wrap" } ) , node )
8989 let editor = CodeMirror ( div => wrap . insertBefore ( div , wrap . firstChild ) , {
9090 value : code ,
@@ -104,7 +104,8 @@ window.addEventListener("load", () => {
104104 clearTimeout ( pollingScroll )
105105 pollingScroll = setTimeout ( pollScroll , 500 )
106106 } )
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 ) )
108109 wrap . style . marginLeft = wrap . style . marginRight = - Math . min ( article . offsetLeft , 100 ) + "px"
109110 setTimeout ( ( ) => editor . refresh ( ) , 600 )
110111 if ( e ) {
You can’t perform that action at this time.
0 commit comments