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

bug: extend function assign array instead of cloning #6

Closed
tvanbeek opened this issue May 21, 2018 · 0 comments
Closed

bug: extend function assign array instead of cloning #6

tvanbeek opened this issue May 21, 2018 · 0 comments

Comments

@tvanbeek
Copy link

Hey me again, found another one :)

On line 142 of ModelMap.js it says:

var labels = original.labels();

But this makes a reference to the array on the original model instead of cloning it. Therefor if when you inherit (or multiple inherit) schema's then all the models will hold the same labels.

To fix it simply rewrite to:

var labels = original.labels().slice(0);

So, combined with the other bug on line 143 the whole function could look like this:

    // starting from line 136 in ModelMap.js
    key: 'extend',
            value: function extend(name, as, using) {
            // Get Original Model
            var original = this.models.get(name);

            // Add new Labels
            var labels = original.labels().slice(0);
            labels.push(as);
            labels.sort();

            // Merge Schema
            var schema = Object.assign({}, original.schema(), using);

            // Create and set
            var model = new _Model2.default(this._neode, as, schema);

            model.setLabels.apply(model, _toConsumableArray(labels));

            this.models.set(as, model);

            return model;
        }
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

2 participants