Do you really need to call element.parentNode btw ? I'm not sure the mutation observer will fire if the node is not part of the tree, but I can be wrong.