Skip to content

Instantly share code, notes, and snippets.

@megawac
Last active January 2, 2016 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save megawac/8355978 to your computer and use it in GitHub Desktop.
Save megawac/8355978 to your computer and use it in GitHub Desktop.
IE textNode throws error

So far I've tested this in

IE 10 win8
IE 9 win7
IE 8 emulated by IE9 win7

Consider the following:

var x = document.createElement('div');
x.innerHTML = "a text node is here and intended <span>stuff</span>"; 
var y = x.childNodes[0];
y.nodeValue; //doesnt throw
x.innerHTML = "<div></div>";


// This will throw in IE
y.nodeValue; //Throws "invalid argument" in ie when accessing nodeValue or just about any other property

This wont throw in any other browser I've tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment