diff options
author | jeresig <jeresig@gmail.com> | 2010-02-13 03:14:00 -0500 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-02-13 03:14:00 -0500 |
commit | 99e7560808679b5044dbefb2b7124bb019fdbda2 (patch) | |
tree | a034f2f1b79b189ffebbcb122d594b94ff40c1a6 | |
parent | 726fda08bea7bbd72d73be4563aba855c63966fe (diff) | |
download | jquery-99e7560808679b5044dbefb2b7124bb019fdbda2.tar.gz jquery-99e7560808679b5044dbefb2b7124bb019fdbda2.zip |
Make sure that we don't try to use a detached node (that was in a fragment) as a fragment in IE. Fixes #5829.
-rw-r--r-- | src/manipulation.js | 2 | ||||
-rw-r--r-- | src/support.js | 2 | ||||
-rw-r--r-- | test/unit/manipulation.js | 12 |
3 files changed, 14 insertions, 2 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index 1453f98c5..a10feae93 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -321,7 +321,7 @@ jQuery.fn.extend({ parent = value && value.parentNode; // If we're in a fragment, just use that instead of building a new one - if ( parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { + if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { results = { fragment: parent }; } else { diff --git a/src/support.js b/src/support.js index befc53272..c9ff58c36 100644 --- a/src/support.js +++ b/src/support.js @@ -56,6 +56,8 @@ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected, + parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null, + // Will be defined later checkClone: false, scriptEval: false, diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 2492ca5d8..eafbf25fc 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -376,7 +376,8 @@ test("append(Function) with incoming value", function() { }); test("appendTo(String|Element|Array<Element>|jQuery)", function() { - expect(13); + expect(14); + var defaultText = 'Try them out:' jQuery('<b>buga</b>').appendTo('#first'); equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' ); @@ -429,6 +430,15 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() { jQuery("<span>a</span><b>b</b>").filter("span").appendTo( div ); equals( div.children().length, 1, "Make sure the right number of children were inserted." ); + + div = jQuery("#moretests div"); + + var num = jQuery("#main div").length; + div.remove().appendTo("#main"); + + equals( jQuery("#main div").length, num, "Make sure all the removed divs were inserted." ); + + reset(); }); var testPrepend = function(val) { |