Skip to content

Commit

Permalink
Add polyfill for Array.indexOf
Browse files Browse the repository at this point in the history
  • Loading branch information
yohanboniface committed Jul 9, 2015
1 parent 4f10f2d commit a034bdc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/core/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ L.Util = {
return (Object.prototype.toString.call(obj) === '[object Array]');
},

indexOf: Array.indexOf || function (array, el) {
for (var i = 0; i < array.length; i++) {
if (array[i] === el) { return i; }
}
return -1;
},

// minimal image URI, set to an image when disposing to flush memory
emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
};
Expand Down
2 changes: 1 addition & 1 deletion src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ L.Map = L.Evented.extend({
if (targets[i].listens(type, true)) {
targets[i].fire(type, data, true);
if (data.originalEvent._stopped
|| (targets[i].options.nonBubblingEvents && targets[i].options.nonBubblingEvents.indexOf(type) !== -1)) { return; }
|| (targets[i].options.nonBubblingEvents && L.Util.indexOf(targets[i].options.nonBubblingEvents, type) !== -1)) { return; }
}
}
},
Expand Down

0 comments on commit a034bdc

Please sign in to comment.