mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-17 06:20:07 +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')
|
.attr('xmlns', 'http://www.w3.org/2000/svg')
|
||||||
.append('g');
|
.append('g');
|
||||||
} else {
|
} else {
|
||||||
|
const existingSvg = document.getElementById(id);
|
||||||
|
if (existingSvg) {
|
||||||
|
existingSvg.remove();
|
||||||
|
}
|
||||||
const element = document.querySelector('#' + 'd' + id);
|
const element = document.querySelector('#' + 'd' + id);
|
||||||
if (element) {
|
if (element) {
|
||||||
element.innerHTML = '';
|
element.innerHTML = '';
|
||||||
|
Reference in New Issue
Block a user