Git Product home page Git Product logo

Comments (4)

shlomiassaf avatar shlomiassaf commented on August 26, 2024

@magnusbakken This does not sound right...

How did you patch the array prototype?

Did you use Object.defineProperty? Did you set the configurable and enumerable properties to false?

from ngrid.

magnusbakken avatar magnusbakken commented on August 26, 2024

I'm sorry, I should've been more explicit about what I meant by patching the prototype. No, I haven't been using Object.defineProperty. I can see that doing so solves the problem, and will rewrite my own prototype overrides to set enumerable to false. Thanks for the tip!

However I would still recommend using for (let i = 0..., since doing Array.prototype.foo = ... is a fairly common pattern, and not everybody is in a position to easily change it.

from ngrid.

shlomiassaf avatar shlomiassaf commented on August 26, 2024

@magnusbakken I will wait with this for now, not sure how to tackle this because I don't think this should be an issue for 99% of the users.

If I see this come up again, I'll see how we can address the issue.

While it looks like a minor patch there are several points in mind:

  • Making sure performance is not effected.
  • Verifying that all places it occurs in are transformed (it might be in places you didn't use, like plugins)
  • Making sure it is forbidden through a linter

I understand that while patching is not common and not recommended, it might still happen here and there, however, I believe that most prototype patches done by 3rd party libraries are done using Object.defineProperty with enumerable set to false and when it's done locally the developer can always fix it.

Btw, even if a 3rd party lib has done this the wrong way you can always fix that by overriding the property assignment with a new one using Object.defineProperty.

from ngrid.

magnusbakken avatar magnusbakken commented on August 26, 2024

No worries. I agree it's not a very important thing, and the issue actually inspired me to simply get rid of all the array prototype patching in my own project, so some good came of this.

from ngrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.