Return to Snippet

Revision: 40105
at January 26, 2011 06:26 by localhorst

Initial Code
// | WTFPL License
window.innerShiv = (function() {
	var d, r;
	return function(h, u) {
		if (!d) {
			d = document.createElement('div');
			r = document.createDocumentFragment();
			/*@cc_on = 'none';@*/
		var e = d.cloneNode(true);
		/*@cc_on document.body.appendChild(e);@*/
		e.innerHTML = h.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
		/*@cc_on document.body.removeChild(e);@*/
		if (u === false) return e.childNodes;
		var f = r.cloneNode(true), i = e.childNodes.length;
		while (i--) f.appendChild(e.firstChild);
		return f;

Initial URL

Initial Description
If you try to access innerHTML of HTML5 elements like <section> or <article> or even just the #foo id then IE returns nothing
innerShiv solves this.

Initial Title
html5 / jQuery innerHTML fix for IE

Initial Tags

Initial Language