]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Revert "Preserve object prototypes when cloning (#7381)" (#7727)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Mon, 24 Aug 2020 12:15:56 +0000 (15:15 +0300)
committerGitHub <noreply@github.com>
Mon, 24 Aug 2020 12:15:56 +0000 (08:15 -0400)
This reverts commit 51be3447170fc648c3b5bc3002c963be62bccdf9.

src/helpers/helpers.core.js
test/specs/helpers.core.tests.js

index 2aa8edc24904cbca1f785290b09f30d0e6fd1b33..6aae6c15875af76d7b5c8f7eab91eddc34c9ad35 100644 (file)
@@ -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;
index fc20ae63d0a2f5f562d179e5afa322919db12438..23a0df539cc48c2dd9f296b130683a5615ec6c88 100644 (file)
@@ -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() {