From 9cb8f87d6ace82f002b0da3770b21f5919943553 Mon Sep 17 00:00:00 2001 From: Justin Van Dort Date: Thu, 10 Oct 2019 10:24:12 -0400 Subject: [PATCH 1/2] Check for typed array in minExtend Modified minExtend to check for both arrays and TypedArrays --- src/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/index.js b/src/lib/index.js index 7a43f10b300..0eb31958db8 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -660,7 +660,7 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(Array.isArray(v)) { + else if(lib.isArrayOrTypedArray(v)) { if(k === 'colorscale') { objOut[k] = v.slice(); } else { From 7f3b2bb75f5018ee584e8128149be0beada97bf2 Mon Sep 17 00:00:00 2001 From: Justin Van Dort Date: Fri, 11 Oct 2019 18:09:12 -0400 Subject: [PATCH 2/2] PR-4286: Updated broken test Used subarray instead of slice for typed array to support older browsers --- src/lib/index.js | 4 +++- test/jasmine/tests/scatter_test.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/index.js b/src/lib/index.js index 0eb31958db8..17ff52c33db 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -660,12 +660,14 @@ lib.minExtend = function(obj1, obj2) { v = obj1[k]; if(k.charAt(0) === '_' || typeof v === 'function') continue; else if(k === 'module') objOut[k] = v; - else if(lib.isArrayOrTypedArray(v)) { + else if(Array.isArray(v)) { if(k === 'colorscale') { objOut[k] = v.slice(); } else { objOut[k] = v.slice(0, arrayLen); } + } else if(lib.isTypedArray(v)) { + objOut[k] = v.subarray(0, arrayLen); } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } diff --git a/test/jasmine/tests/scatter_test.js b/test/jasmine/tests/scatter_test.js index 8c599352fd8..9af59f51dfa 100644 --- a/test/jasmine/tests/scatter_test.js +++ b/test/jasmine/tests/scatter_test.js @@ -1121,7 +1121,7 @@ describe('end-to-end scatter tests', function() { var legendPts = d3.select('.legend').selectAll('.scatterpts'); expect(legendPts.size()).toBe(1, '# legend items'); - expect(getColor(legendPts.node())).toBe('rgb(0, 0, 0)', 'legend pt color'); + expect(getColor(legendPts.node())).toBe('rgb(0, 255, 0)', 'legend pt color'); expect(getMarkerSize(legendPts.node())).toBe(16, 'legend pt size'); }) .catch(failTest)