Skip to content

addons/update.js does not work as expected with prototypes #1807

@slorber

Description

@slorber

Being able to use addons/update.js with a prototype seems to be a goal of the addon according to this line:

return copyProperties(new x.constructor(), x);

Since we use object constructor instead of just {}

When updating an object with a prototype, the prototype is kept, as expected, but the copyProperties.js include prototype methods as object properties.

This is probably because of this loop:

for (var k in v) {

See this http://jsfiddle.net/QVjLw/

I think the loop should be

    for (var k in v) {
        if ( v.hasOwnProperty(k) ) {
           obj[k] = v[k];
        }
    }

Instead of

    for (var k in v) {
           obj[k] = v[k];
    }

It would be nice to not pollute the object attributes with unnecessary methods and keep them in the prototype

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions