From 0f8731d821ac49d972c3470cde94deff6a3039df Mon Sep 17 00:00:00 2001 From: rma4ok Date: Thu, 28 Jun 2012 20:26:36 -0400 Subject: [PATCH] Add support for createContextualFragment for IE9 --- lib/index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/index.js b/lib/index.js index 90d1441..b36cdcc 100644 --- a/lib/index.js +++ b/lib/index.js @@ -41,3 +41,20 @@ if (!doc.body.insertAdjacentHTML) { } } } + +// 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