I have a preview pane next to a text area. On every input change in the text area, the corresponding preview pane div gets populated and rendered, followed by an effect that renders all the Latex in that div (using KaTeX). This works fine on first KaTeX render. All subsequent renders get one of two errors:
Uncaught DOMException: Node.removeChild: The node to be removed is not a child of this node
Uncaught DOMException: Node.insertBefore: Child to insert before is not a child of this node
Consequently the expected preview output in the preview pane gets appended and not replaced.
Here's a minimal code snippet for the preview pane:
keyed.div([], [
#(
constant_id,
element.fragment([
html.div([], [html.text(preview_content)]),
]),
),
])