diff --git a/lib/index.js b/lib/index.js index 935ac64..248754d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -43,7 +43,25 @@ if (!doc.body.insertAdjacentHTML) { } elementProto.matches = - elementProto.webkitMatchesSelector || - elementProto.mozMatchesSelector || - elementProto.oMatchesSelector || - elementProto.msMatchesSelector + elementProto.webkitMatchesSelector || + elementProto.mozMatchesSelector || + elementProto.oMatchesSelector || + elementProto.msMatchesSelector + + +// Add support for createContextualFragment for IE9 +if (typeof Range.prototype.createContextualFragment == "undefined") { + Range.prototype.createContextualFragment = function(html) { + var startNode = this.startContainer + , doc = startNode.nodeType == 9 ? startNode : startNode.ownerDocument + , container = doc.createElement("div") + , frag, n; + + container.innerHTML = html; + frag = doc.createDocumentFragment(); + while (n = container.firstChild) { + frag.appendChild(n); + } + return frag; + }; +} \ No newline at end of file