Node.replacechild removes identical elements #444

JoshRagem opened this Issue May 3, 2012 · 0 comments


None yet

2 participants


If two references of one element are passed to replaceChild, the element will be removed from the document.

var el1 = document.getElementByID('blah');
var el2 = el1;
var thisIsUndefined = document.getElementByID('blah');
var h = thisIsUndefined.innerHTML; //this is an error.

This happens because the replaceChild method calls insertBefore and then removeChild; the insertBefore has a check, el1===el2, that returns without altering the node list, then removeChild removes the element entirely.

@domenic domenic removed this from the Contemplating milestone Jul 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment