ccforward / progressive-image

A progressive-image module for Vanilla JavaScript and Vue 1.0+ & 2.0+
https://ccforward.github.io/progressive-image/index.html
MIT License
379 stars 43 forks source link

Will not work with any other library that uses the Array 'in' operator #12

Open franzwilding opened 7 years ago

franzwilding commented 7 years ago

In undex-vue.js you create a new array property 'remove' as enumerable property.

Array.prototype.remove = function(item) {
      if(!this.length) return
      const idx = this.indexOf(item);
      if(idx > -1) return this.splice(idx,1)
}

Because of this every Array will have a new property 'remove' with the function as value when getting the Array properties by:

for(x in array) {}

This breaks for examle jQuery ajaxForm and many other libraries.

Please declare the remove method as non enumerable:

Object.defineProperty(Array.prototype, 'remove', { 
    enumerable: false,
    value: function(item) {
      if(!this.length) return
      const idx = this.indexOf(item);
      if(idx > -1) return this.splice(idx,1)
    }

});