Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
franzwilding opened this issue Nov 2, 2017 · 0 comments

Comments

@franzwilding
Copy link

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)
    }

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant