From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 7 Sep 2019 11:19:17 +0000 (-0700) Subject: Html dom building (#6490) X-Git-Tag: v2.9.0~1^2~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=df9e2d00bdf87f3517b238d038256e312a5deaec;p=thirdparty%2FChart.js.git Html dom building (#6490) Replaces #6179 and builds HTML legend strings using dom nodes rather than building up an HTML string directly. --- diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index de418e7ed..7cee54444 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 1e0e30ba2..76ca3b70c 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 91ff07a20..dc5b9325d 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 a01284c1a..afef1aabf 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); });