From 10901f7d9fa6be01cc6b88cd94d279760b42a069 Mon Sep 17 00:00:00 2001 From: Elijah Manor Date: Wed, 22 Aug 2012 21:23:50 -0400 Subject: Fix #12266. IE9/10 says document[0] is document.frames[0]? Close gh-903. --- src/manipulation.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index 3cfc97c3b..f87e3ca94 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -489,15 +489,11 @@ jQuery.buildFragment = function( args, context, scripts ) { first = args[ 0 ]; // Set context from what may come in as undefined or a jQuery collection or a node + // Updated to fix #12266 where accessing context[0] could throw an exception in IE9/10 & + // also doubles as fix for #8950 where plain objects caused createDocumentFragment exception context = context || document; - context = (context[0] || context).ownerDocument || context[0] || context; - - // Ensure that an attr object doesn't incorrectly stand in as a document object - // Chrome and Firefox seem to allow this to occur and will throw exception - // Fixes #8950 - if ( typeof context.createDocumentFragment === "undefined" ) { - context = document; - } + context = !context.nodeType && context[0] || context; + context = context.ownerDocument || context; // Only cache "small" (1/2 KB) HTML strings that are associated with the main document // Cloning options loses the selected state, so don't cache them -- cgit v1.2.3