Skip to content

Commit

Permalink
Revert "Preserve object prototypes when cloning (chartjs#7381)"
Browse files Browse the repository at this point in the history
This reverts commit 51be344.
  • Loading branch information
kurkle committed Aug 24, 2020
1 parent 35d669e commit 7103199
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
2 changes: 1 addition & 1 deletion src/helpers/helpers.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function clone(source) {
}

if (isObject(source)) {
const target = Object.create(source);
const target = {};
const keys = Object.keys(source);
const klen = keys.length;
let k = 0;
Expand Down
21 changes: 0 additions & 21 deletions test/specs/helpers.core.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,27 +316,6 @@ describe('Chart.helpers.core', function() {
expect(output.o).not.toBe(o0);
expect(output.o.a).not.toBe(a1);
});
it('should preserve prototype of objects', function() {
// https://github.com/chartjs/Chart.js/issues/7340
class MyConfigObject {
constructor(s) {
this._s = s;
}
func() {
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('mergeIf', function() {
Expand Down

0 comments on commit 7103199

Please sign in to comment.