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

Nested objects extending #40

Open
cranetm opened this issue Mar 30, 2017 · 0 comments
Open

Nested objects extending #40

cranetm opened this issue Mar 30, 2017 · 0 comments

Comments

@cranetm
Copy link

cranetm commented Mar 30, 2017

in jsface.extend-method nested objects instead of extending just replace each other.
Example

var Man = Class({
    config: {
        prefix: 'Mr',
        name: '',
        eyes: 'green',
        hair: 'blonde',
        rightHanded: true
    },
    constructor: function (name) {
        this.config.name = name;
    },

    echo: function () {
        console.log(JSON.stringify(this.config));
    }
});

var Woman = Class(Man, {
    config: {
        prefix: 'Ms',
        eyes: 'blue'
    }
});
var jack = new Man("Jack");
jack.echo();
var rika = new Woman("Rika");
rika.echo();

and as a result we've got
{"prefix":"Mr","name":"Jack","eyes":"green","hair":"blonde","rightHanded":true}
{"prefix":"Ms","eyes":"blue","name":"Rika"}
(name presents because of contructor)

In my opinion its incorrect behavior, all properties must inherit instead of whole object replacing, but only in case of simple objects (not for classes).

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