Skip to content

Commit 26634f7

Browse files
Murray, ElizabethMurray, Elizabeth
authored andcommitted
Alternative to window.addEventListener for IE 8
1 parent 6424893 commit 26634f7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/stores/URLStore.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ var invariant = require('react/lib/invariant');
33
var warning = require('react/lib/warning');
44

55
var CHANGE_EVENTS = {
6-
hash: 'hashchange',
6+
hash: (window.addEventListener) ? 'hashchange' : 'onhashchange',
77
history: 'popstate'
88
};
99

@@ -139,7 +139,10 @@ var URLStore = {
139139
if (location === 'hash' && window.location.hash === '')
140140
URLStore.replace('/');
141141

142-
window.addEventListener(changeEvent, notifyChange, false);
142+
if (window.addEventListener) //check for IE 8
143+
window.addEventListener(changeEvent, notifyChange, false);
144+
else
145+
window.attachEvent(changeEvent, notifyChange);
143146

144147
notifyChange();
145148
},

0 commit comments

Comments
 (0)