https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore reads:
referenceNode The node before which newNode is inserted. If this is null, then newNode is inserted at the end of node's child nodes.
but Node.insertBefore requires a reference node to be provided.
Possible workaround:
case referenceNode of
Just r -> Node.insertBefore newNode r this
Nothing -> Node.appendChild newNode this