Skip to content

Commit

Permalink
Revert "Preserve object prototypes when cloning (chartjs#7404)"
Browse files Browse the repository at this point in the history
This reverts commit 484f0d1.
  • Loading branch information
GramParallelo committed Mar 24, 2022
1 parent 171a7e3 commit 478b44c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 20 deletions.
2 changes: 1 addition & 1 deletion src/helpers/helpers.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var helpers = {
}

if (helpers.isObject(source)) {
var target = Object.create(source);
var target = {};
var keys = Object.keys(source);
var klen = keys.length;
var k = 0;
Expand Down
19 changes: 0 additions & 19 deletions test/specs/helpers.core.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,25 +306,6 @@ describe('Chart.helpers.core', function() {
expect(output.o.a).not.toBe(a1);
expect(output.a).not.toBe(a0);
});
it('should preserve prototype of objects', function() {
// https://github.com/chartjs/Chart.js/issues/7340
function MyConfigObject(s) {
this._s = s;
}
MyConfigObject.prototype.func = function() {
return 10;
};
var original = new MyConfigObject('something');
var output = helpers.merge({}, {
plugins: [{
test: original
}]
});
var clone = output.plugins[0].test;
expect(clone).toBeInstanceOf(MyConfigObject);
expect(clone).toEqual(original);
expect(clone === original).toBeFalse();
});
});

describe('merge', function() {
Expand Down

0 comments on commit 478b44c

Please sign in to comment.