From df25ac0ded3199619819dc6fa26d7c5e4ec53031 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 7 Sep 2019 04:19:17 -0700 Subject: [PATCH] Html dom building (#6490) Replaces #6179 and builds HTML legend strings using dom nodes rather than building up an HTML string directly. --- src/controllers/controller.doughnut.js | 18 +++++++++--------- src/controllers/controller.polarArea.js | 18 +++++++++--------- src/plugins/plugin.legend.js | 23 ++++++++++++++--------- test/specs/global.defaults.tests.js | 4 ++-- 4 files changed, 34 insertions(+), 29 deletions(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index de418e7edbc..7cee5444457 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -22,25 +22,25 @@ defaults._set('doughnut', { mode: 'single' }, legendCallback: function(chart) { - var text = []; - text.push(''); - return text.join(''); + return list.outerHTML; }, legend: { labels: { diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 1e0e30ba2dd..76ca3b70cae 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -32,25 +32,25 @@ defaults._set('polarArea', { startAngle: -0.5 * Math.PI, legendCallback: function(chart) { - var text = []; - text.push(''); - return text.join(''); + return list.outerHTML; }, legend: { labels: { diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index 91ff07a20bd..dc5b9325d6f 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -78,17 +78,22 @@ defaults._set('global', { }, legendCallback: function(chart) { - var text = []; - text.push(''); - return text.join(''); + + return list.outerHTML; } }); diff --git a/test/specs/global.defaults.tests.js b/test/specs/global.defaults.tests.js index a01284c1a0b..afef1aabf2a 100644 --- a/test/specs/global.defaults.tests.js +++ b/test/specs/global.defaults.tests.js @@ -102,7 +102,7 @@ describe('Default Configs', function() { options: config }); - var expectedLegend = ''; + var expectedLegend = ''; expect(chart.generateLegend()).toBe(expectedLegend); }); @@ -218,7 +218,7 @@ describe('Default Configs', function() { options: config }); - var expectedLegend = ''; + var expectedLegend = ''; expect(chart.generateLegend()).toBe(expectedLegend); });