mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-16 22:09:57 +02:00
#478 API crashes on 2nd render() call
- remove element from DOM before rendering to avoid conflicts in case of rerendering
This commit is contained in:
@@ -462,6 +462,10 @@ const render = function(id, txt, cb, container) {
|
||||
.attr('xmlns', 'http://www.w3.org/2000/svg')
|
||||
.append('g');
|
||||
} else {
|
||||
const existingSvg = document.getElementById(id);
|
||||
if (existingSvg) {
|
||||
existingSvg.remove();
|
||||
}
|
||||
const element = document.querySelector('#' + 'd' + id);
|
||||
if (element) {
|
||||
element.innerHTML = '';
|
||||
|
Reference in New Issue
Block a user