Skip to content

Instantly share code, notes, and snippets.

@markelog
Created August 28, 2012 07:53
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 markelog/3495987 to your computer and use it in GitHub Desktop.
Save markelog/3495987 to your computer and use it in GitHub Desktop.
#12346 – fn.append not working correctly
// In previous versions of jQuery, on every for iteration new div was created in jQuery.clean,
// now, on every iteration only one div is used, which created some problems –
// Illustration of WebKit bug
div = document.createElement("div");
div.innerHTML = "1";
nodes = jQuery.merge( [], div.childNodes );
div.innerHTML = "2";
console.log( nodes[ 0 ].textContent ) // 2
// easially fixable, if before
div.innerHTML = "2";
// will be
div.innerHTML = "";
// but IE case more complex
div.innerHTML = "<span>content</span>";
element = div.childNodes[ 0 ];
div.innerHTML = "something";
console.log( element.textContent ); // empty
// same goes for html-entites
div.innerHTML = "&amp;";
element = div.childNodes[ 0 ];
div.innerHTML = "something";
console.log( element.textContent ); // Error
//but it would be OK if element was removed thorough removeChild method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment