Created
December 13, 2013 13:33
-
-
Save piffie/7944268 to your computer and use it in GitHub Desktop.
The Meteor LocalStorage implementation is not working on all iOS devices with private Browsing turned on. This is default in iOS 7.
The reason is, that window.localStorage exists, but writing to window.localStorage.setItem throws an exception. This gist overrides the meteor implementation if this is the case.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@fix = | |
hasLocalStorage: -> | |
try | |
mod = new Date | |
localStorage.setItem mod, mod.toString() | |
result = localStorage.getItem(mod) == mod.toString() | |
localStorage.removeItem mod | |
return true | |
if $.browser.msie? | |
return true #meteor has special ie code. | |
return false | |
checkLocalStorageFix: -> | |
if @hasLocalStorage() | |
return | |
Meteor._localStorage = #override with local temporary store. | |
_data: {} | |
setItem: (key, val)-> @_data[key] = val | |
removeItem: (key) -> delete @_data[key] | |
getItem: (key)-> | |
value = @_data[key] | |
return value if value? | |
null | |
Meteor.startup -> | |
fix.checkLocalStorageFix() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it still takes time to login on ios 5.x.