Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IE versions for StorageEvent API #10837

Merged
merged 1 commit into from
Jun 12, 2021
Merged

Conversation

queengooborg
Copy link
Collaborator

This PR adds real values for Internet Explorer for the StorageEvent API, based upon results from the mdn-bcd-collector project (v3.1.4). Results are manually confirmed for accuracy.

Tests Used: https://mdn-bcd-collector.appspot.com/tests/api/StorageEvent

This PR adds real values for Internet Explorer for the `StorageEvent` API, based upon results from the [mdn-bcd-collector](https://mdn-bcd-collector.appspot.com) project (v3.1.4).  Results are manually confirmed for accuracy.

Tests Used: https://mdn-bcd-collector.appspot.com/tests/api/StorageEvent
@github-actions github-actions bot added the data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API label Jun 7, 2021
Copy link
Collaborator

@foolip foolip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://caniuse.com/namevalue-storage and https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage#browser_compatibility say IE8 for the API that would fire this event.

Can you try making the event fire somehow to see if this is a question of a missing interface object?

@queengooborg
Copy link
Collaborator Author

In #10183, the onstorage event handler and the storage event were set to IE 9, so I'd say this makes sense. (I'm having troubles setting up a test case too...)

@foolip
Copy link
Collaborator

foolip commented Jun 12, 2021

I'm too stubborn/curious for my own good. I found https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/cc289326(v=vs.85) which says IE8, and there's enough clues in there to arrive at this test case:

<!DOCTYPE html>
<button id=b1>setItem</button>
<button id=b2>clear</button>
<div id=log></div>
<script>
alert(document.onstorage)
document.onstorage = function() {
  alert(event.key + ' was updated');
}; 
document.getElementById('b1').onclick = function() {
  localStorage.setItem('key', 'value');
  alert('set done');
};
document.getElementById('b2').onclick = function() {
  localStorage.clear();
  alert('clear done');
};
</script>

Loading that in 2 tabs in IE shows that:

  • document.onstorage is supported
  • The event is fired in the other tab when clicking "set"
  • The event that's fired doesn't have a key property, but it does have a url property. It seems seems to be just an Event though, I guess in IE8 they just added properties to the event instances or something like that.

IE8 doesn't support addEventListener, but I also couldn't get this to work with attachEvent. Maybe I did it wrong and document.attachEvent('storage', ...) works, but it doesn't really matter so not checked further.

So how should one summarize this situation? In the end, since the event is fired on document instead of the global object as per spec and it doesn't have the same properties, I think we should say that today's notion of the event was not supported, even partially, in IE8. So IE9 is correct.

@foolip foolip merged commit dc86961 into mdn:main Jun 12, 2021
@queengooborg queengooborg deleted the api/StorageEvent/ie branch June 12, 2021 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data:api 🐇 Compat data for Web APIs. https://developer.mozilla.org/docs/Web/API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants