From 478b44c34f5166d5c6c42c3e2d284b9d387622eb Mon Sep 17 00:00:00 2001 From: GramParallelo Date: Thu, 24 Mar 2022 12:45:51 -0700 Subject: [PATCH] Revert "Preserve object prototypes when cloning (#7404)" This reverts commit 484f0d1e518963436d5013f61001558ef9788edf. --- src/helpers/helpers.core.js | 2 +- test/specs/helpers.core.tests.js | 19 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/helpers/helpers.core.js b/src/helpers/helpers.core.js index c975cb0fb66..bd26c2a0836 100644 --- a/src/helpers/helpers.core.js +++ b/src/helpers/helpers.core.js @@ -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; diff --git a/test/specs/helpers.core.tests.js b/test/specs/helpers.core.tests.js index a6325736d78..7a818598a74 100644 --- a/test/specs/helpers.core.tests.js +++ b/test/specs/helpers.core.tests.js @@ -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() {