lib/assets/javascripts/extensions.coffee in material_raingular-0.2.3 vs lib/assets/javascripts/extensions.coffee in material_raingular-0.2.3.1
- old
+ new
@@ -41,11 +41,11 @@
total = 0
for i in this
total += parseFloat(i) if i
total
Array.prototype.includes = (entry)->
- unless entry.hasOwnProperty('id')
+ unless (entry || {}).hasOwnProperty('id')
return @.indexOf(entry) > -1
@.pluck('id').includes(entry.id)
Array.prototype.drop = (entry)->
if (entry || {}).hasOwnProperty('id')
index = @.pluck('id').indexOf(entry.id)
@@ -105,10 +105,10 @@
@.intersection(arr).length > 0
Array.prototype.find = (id) ->
index = @.pluck('id').indexOf(id)
@[index]
Array.prototype.index = (obj) ->
- return unless obj.hasOwnProperty('id')
+ return unless (obj || {}).hasOwnProperty('id')
@.pluck('id').indexOf(obj.id)
Array.prototype.update = (obj) ->
- return unless obj.hasOwnProperty('id')
+ return unless (obj || {}).hasOwnProperty('id')
@[@.index(obj)] = obj