Code Monkey home page Code Monkey logo

Comments (3)

mwistrand avatar mwistrand commented on May 20, 2024

Resetting prototype.constructor is standard fare in classical JS inheritance schemes, so throwing an error for any base function passed to compose that happens to do so (e.g., third-party modules installed via Bower) could prove problematic. Since constructor functions of other bases are ignored, it would be nice if these constructors were treated the same. In order to prevent these constructors from overriding factory.prototype.constructor, they could be deliberately excluded from the internal copyProperties method, or factory.prototype.constructor = factory could placed after the call to copyProperties within compose, instead of within cloneFactory.

from compose.

maier49 avatar maier49 commented on May 20, 2024

As far as I can tell, a base having a method called constructor isn't really a problem. If there's a method called constructor on the base, the resulting factory will just create instances that also have a constructor method. I'm not sure why somebody would have a method called constructor but it doesn't seem like it would cause any more problems for compose than it would in the first place.

In the case that the constructor is actually on the base.prototype it seems like @mwistrand 's suggestion would be sufficient to handle this. This would just require adding one or two lines to create and extend, as mixin passes the object through create if it's not a ComposeFactory anyway.

from compose.

kitsonk avatar kitsonk commented on May 20, 2024

Agreed that we should exclude constructor from copyProperties.

from compose.

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.