Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
why doesn't the DOM spec include an insertAfter method, srsly guys
/** Inserts a new node after a given reference node. Basically it is the complement to the DOM specification's
* insertBefore() function.
* @param \DOMNode $newNode The node to be inserted.
* @param \DOMNode $referenceNode The reference node after which the new node should be inserted.
* @return \DOMNode The node that was inserted.
function insertAfter(\DOMNode $newNode, \DOMNode $referenceNode)
if($referenceNode->nextSibling === null) {
return $referenceNode->parentNode->appendChild($newNode);
} else {
return $referenceNode->parentNode->insertBefore($newNode, $referenceNode->nextSibling);

This comment has been minimized.

Copy link

Wargog commented Nov 1, 2018

Is there any chance you could MIT or Apache 2 license this snippet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.