Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Try fix for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerkin committed Oct 30, 2017
1 parent 69c8fa2 commit abd136a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/sequential-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,15 @@ const onceify = ( target, eventName, eventFn ) => {
* @inner
*/
const removeEventListener = ( eventCat, callback ) => {
const indexes = [ eventCat.indexOf( callback ), eventCat.findIndex( elem => elem.origFn === callback ) ];
const indexes = [ eventCat.indexOf( callback ), (() => {
const I = eventCat.length;
for(let i = 0; i < I; i++){
if(eventCat[i].origFn === callback){
return i;
}
}
return -1;
})() ];
const index = Math.min( ...indexes.filter( v => v >= 0 ));
if ( isFinite( index )) {
eventCat.splice( index, 1 );
Expand Down
5 changes: 4 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ if ( process.env.SAUCE === 'no' || typeof process.env.SAUCE === 'undefined') {
mySequentialEvent.on('bar', () => {
called++;
});
const events = Object.assign({}, mySequentialEvent.__events);
const events = {};
for(const eventCat in mySequentialEvent.__events){
events[eventCat] = mySequentialEvent.__events[eventCat];
}
mySequentialEvent.off('foo');
return mySequentialEvent.emit('foo').then(() => {
return mySequentialEvent.emit('bar');
Expand Down

0 comments on commit abd136a

Please sign in to comment.