Your mutation observer code works fine. You are trying to pass linkifyContainer
a NodeList
argument (namely, mutation.addedNodes
), but linkifyContainer
expects to be passed a single element.
Compare the calls:
linkifyContainer(event.target)
and
linkifyContainer(mutation.addedNodes)
The second case is a NodeList
, not a single DOM node, as indicated by the plural property name addedNodes.
Simply use mutation.addedNodes[0]
, or a loop over mutation.addedNodes
:
for(var i=0; i<mutation.addedNodes; ++i) {
linkifyContainer(mutation.addedNodes[i]);
}