-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Strange behaviour on IE11 #47
Comments
@jasalguero I just did a quick google for 'IE11 localStorage' and it seems that the IE11 has a lot of problems with localStorage. What is the exact version number? |
@jasalguero can you try to debug the issue by removing these lines? |
I have the same issue with IE (10 and 11). Adding |
@varoot hmm but that would make the entire purpose of the storage event obsolete, doesn't it? |
@varoot wait! does your code look like:
That would mean that the IE fires in the same tab the change occurred and that's why it results in an infinite loop. So it is the opposite of your guess but could be the fix. |
we might need a check |
Just found this in our app as well. According to CanIUse "The storage event's oldValue and newValue are identical (newValue is supposed to contain the storage's updated value)". Not sure if that gives anyone aid, but trying to look in to this as well. |
@fsmanuel No, my code is like this:
which means that only hidden (inactive) tabs will take values. I think it makes sense since it's probably the active tab that sends out events in the first place. You can look at my commit here: https://github.com/smartkarma/ember-local-storage/commit/1875172126b3e8e61800582c61c0ac55f2eb9dd8 |
The downside of this approach (that I can think of) is that But for me this is acceptable, since it won't break the functionality even if the browser doesn't support |
Yeah, it works. Tested on IE10 and IE11. |
I'll try to release the fix tomorrow. |
@jasalguero @krivaten @varoot I released |
This is still a problem if you call For example, we nest localStorage items for namespacing purposes, potentially calling if (!storage.get('123')) { storage.set('123', {}) };
storage.set('123.john', { language: 'english' }); This in turn causes the storage change event to fire repeatedly: // first event
console.log(event.oldValue) // => null
console.log(event.newValue) // => { '123': {} }
// next event
console.log(event.oldValue) // => { '123': {} }
console.log(event.newValue) // => { '123': { john: { language: 'english } } }
// next event
console.log(event.oldValue) // => { '123': { john: { language: 'english } } }
console.log(event.newValue) // => { '123': {} }
// next event
console.log(event.oldValue) // => { '123': {} }
console.log(event.newValue) // => { '123': { john: { language: 'english } } }
// etc.... We ended up forking the lib and adding a check Any ideas for a solution? Thanks! |
I'll investigate. |
@MattNguyen I released |
Hi,
I'm using the plugin to store a couple of simple values in local storage and it works all fine, except in IE (IE11), where there is no initial value set, and on changing (is a page size that I can change in an input) it gets in an infinite loop setting the variable to the new and initial value back and forth.
The text was updated successfully, but these errors were encountered: