IE8 was throwing an error on objectCollection.indexOf
Overwriting index of on all objectCollections, where before it checked if the object already had an indexOf method. Change-Id: I85deeb066f1cc3b81b0e0436aea4f47d2df2fcd3 Reviewed-on: https://gerrit.instructure.com/6616 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
be2fecb7ea
commit
cf29385018
|
@ -6,12 +6,10 @@
|
|||
define 'compiled/util/objectCollection', ->
|
||||
(array) ->
|
||||
|
||||
# The usual indexOf support if not present
|
||||
unless array.indexOf
|
||||
array.indexOf = (needle) ->
|
||||
for item, index in array
|
||||
index if item is needle
|
||||
-1
|
||||
array.indexOf = (needle) ->
|
||||
for item, index in array
|
||||
return index if item is needle
|
||||
-1
|
||||
|
||||
# Can find a specific element by a property ie:
|
||||
# arr = arrayOfObjects([{id: 1}, {id: 2}])
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
(function() {
|
||||
define('compiled/util/objectCollection', function() {
|
||||
return function(array) {
|
||||
if (!array.indexOf) {
|
||||
array.indexOf = function(needle) {
|
||||
var index, item, _len, _results;
|
||||
_results = [];
|
||||
for (index = 0, _len = array.length; index < _len; index++) {
|
||||
item = array[index];
|
||||
_results.push(item === needle ? index : void 0);
|
||||
array.indexOf = function(needle) {
|
||||
var index, item, _len;
|
||||
for (index = 0, _len = array.length; index < _len; index++) {
|
||||
item = array[index];
|
||||
if (item === needle) {
|
||||
return index;
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
-1;
|
||||
}
|
||||
}
|
||||
};
|
||||
-1;
|
||||
array.findBy = function(prop, value) {
|
||||
var index, item, _len;
|
||||
for (index = 0, _len = array.length; index < _len; index++) {
|
||||
|
|
Loading…
Reference in New Issue