From ecfdbcf34e21812f7e5f8789d024254d3d5898cf Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Tue, 29 Jun 2021 12:47:29 +0200 Subject: [PATCH] chore: use Element#remove instead of Node#removeChild --- src/js/charts/AxisChart.js | 4 ++-- src/js/charts/BaseChart.js | 8 ++++---- src/js/utils/animation.js | 4 ++-- src/js/utils/export.js | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/js/charts/AxisChart.js b/src/js/charts/AxisChart.js index 6d574887..e01a1e3c 100644 --- a/src/js/charts/AxisChart.js +++ b/src/js/charts/AxisChart.js @@ -455,7 +455,7 @@ export default class AxisChart extends BaseChart { if (this.overlayGuides) { this.overlayGuides.forEach(g => { let o = g.overlay; - o.parentNode.removeChild(o); + o.remove(); }); } @@ -484,7 +484,7 @@ export default class AxisChart extends BaseChart { if (this.overlayGuides) { this.overlayGuides.forEach(g => { let o = g.overlay; - o.parentNode.removeChild(o); + o.remove(); }); } } diff --git a/src/js/charts/BaseChart.js b/src/js/charts/BaseChart.js index befa2446..a4fa852e 100644 --- a/src/js/charts/BaseChart.js +++ b/src/js/charts/BaseChart.js @@ -163,7 +163,7 @@ export default class BaseChart { this.data = this.realData; setTimeout(() => { this.update(this.data, true); }, this.initTimeout); } - + if (this.config.showLegend) { this.renderLegend(); } @@ -180,7 +180,7 @@ export default class BaseChart { makeChartArea() { if (this.svg) { - this.container.removeChild(this.svg); + this.svg.remove(); } let m = this.measures; @@ -240,7 +240,7 @@ export default class BaseChart { if (!data) console.error('No data to update.'); if (!drawing) data = deepClone(data); const animate = drawing ? !this.config.disableEntryAnimation : this.config.animate; - + this.data = this.prepareData(data); this.calc(); // builds state this.render(this.components, animate); @@ -249,7 +249,7 @@ export default class BaseChart { render(components = this.components, animate = true) { if (this.config.isNavigable) { // Remove all existing overlays - this.overlays.map(o => o.parentNode.removeChild(o)); + this.overlays.map(o => o.remove()); // ref.parentNode.insertBefore(element, ref); } let elementsToAnimate = []; diff --git a/src/js/utils/animation.js b/src/js/utils/animation.js index 77bf2f10..5f74ee5e 100644 --- a/src/js/utils/animation.js +++ b/src/js/utils/animation.js @@ -101,7 +101,7 @@ export function runSMILAnimation(parent, svgElement, elementsToAnimate) { let animSvgElement = animateSVG(svgElement, elementsToAnimate); if (svgElement.parentNode == parent) { - parent.removeChild(svgElement); + svgElement.remove(); parent.appendChild(animSvgElement); } @@ -109,7 +109,7 @@ export function runSMILAnimation(parent, svgElement, elementsToAnimate) { // Replace the new svgElement (data has already been replaced) setTimeout(() => { if (animSvgElement.parentNode == parent) { - parent.removeChild(animSvgElement); + animSvgElement.remove(); parent.appendChild(svgElement); } }, REPLACE_ALL_NEW_DUR); diff --git a/src/js/utils/export.js b/src/js/utils/export.js index 284f40b9..023ad493 100644 --- a/src/js/utils/export.js +++ b/src/js/utils/export.js @@ -11,7 +11,7 @@ export function downloadFile(filename, data) { document.body.appendChild(a); a.click(); setTimeout(function () { - document.body.removeChild(a); + a.remove(); window.URL.revokeObjectURL(url); }, 300); }