From 7103199b7c3a233367c3409d966a83af14ac7b56 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Mon, 24 Aug 2020 11:16:16 +0300 Subject: [PATCH] Revert "Preserve object prototypes when cloning (#7381)" This reverts commit 51be3447170fc648c3b5bc3002c963be62bccdf9. --- src/helpers/helpers.core.js | 2 +- test/specs/helpers.core.tests.js | 21 --------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/helpers/helpers.core.js b/src/helpers/helpers.core.js index 2aa8edc2490..6aae6c15875 100644 --- a/src/helpers/helpers.core.js +++ b/src/helpers/helpers.core.js @@ -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; diff --git a/test/specs/helpers.core.tests.js b/test/specs/helpers.core.tests.js index fc20ae63d0a..23a0df539cc 100644 --- a/test/specs/helpers.core.tests.js +++ b/test/specs/helpers.core.tests.js @@ -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() {