diff --git a/cypress/integration/other/rerender.spec.js b/cypress/integration/other/rerender.spec.js index d7b3d2b47..06967af59 100644 --- a/cypress/integration/other/rerender.spec.js +++ b/cypress/integration/other/rerender.spec.js @@ -1,5 +1,11 @@ /* eslint-env jest */ describe('Rerendering', () => { + it('should be able to render after an error has occured', () => { + const url = 'http://localhost:9000/render-after-error.html'; + cy.viewport(1440, 1024); + cy.visit(url); + cy.get('#graphDiv').should('exist'); + }); it('should be able to render and rerender a graph via API', () => { const url = 'http://localhost:9000/rerender.html'; diff --git a/cypress/platform/render-after-error.html b/cypress/platform/render-after-error.html new file mode 100644 index 000000000..a46f093bd --- /dev/null +++ b/cypress/platform/render-after-error.html @@ -0,0 +1,32 @@ + + + + + + Mermaid Quick Test Page + + + +
+
+ + + + + + diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index 8bbe30f96..e84413c91 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -728,7 +728,7 @@ const render = function(id, _txt, cb, container) { } const element = document.querySelector('#' + 'd' + id); if (element) { - element.innerHTML = ''; + element.remove(); } select('body')