diff --git a/js/Extensions/Exporting.js b/js/Extensions/Exporting.js index da3494d40ce..58fe9787c02 100644 --- a/js/Extensions/Exporting.js +++ b/js/Extensions/Exporting.js @@ -1876,9 +1876,9 @@ Chart.prototype.inlineStyles = function () { * @return {void} */ function tearDown() { - dummySVG.parentNode.remove(); + dummySVG.parentNode.removeChild(dummySVG); // Remove trash from DOM that stayed after each exporting - iframe.remove(); + iframe.parentNode.removeChild(iframe); } recurse(this.container.querySelector('svg')); tearDown(); diff --git a/samples/unit-tests/exporting/getsvg/demo.js b/samples/unit-tests/exporting/getsvg/demo.js index c53d5e99e81..03c4e9dd0a3 100644 --- a/samples/unit-tests/exporting/getsvg/demo.js +++ b/samples/unit-tests/exporting/getsvg/demo.js @@ -111,6 +111,10 @@ QUnit.test('getSVG', function (assert) { 'Reference by id, series name ok' ); + // #14954 + const remove = Element.prototype.remove; + Element.prototype.remove = void 0; + chart.getSVG({ chart: { styledMode: true @@ -131,6 +135,8 @@ QUnit.test('getSVG', function (assert) { false, 'Iframe should be destroyed in DOM after getSVG().' ); + + Element.prototype.remove = remove; }); QUnit.test('Hide label with useHTML', function (assert) { diff --git a/ts/Extensions/Exporting.ts b/ts/Extensions/Exporting.ts index bc1e4f3b133..118f60c0b75 100644 --- a/ts/Extensions/Exporting.ts +++ b/ts/Extensions/Exporting.ts @@ -2565,9 +2565,9 @@ Chart.prototype.inlineStyles = function (): void { * @return {void} */ function tearDown(): void { - (dummySVG.parentNode as any).remove(); + dummySVG.parentNode.removeChild(dummySVG); // Remove trash from DOM that stayed after each exporting - iframe.remove(); + iframe.parentNode.removeChild(iframe); } recurse(this.container.querySelector('svg') as any);