]> source.dussan.org Git - jquery.git/commitdiff
Make sure that we don't try to use a detached node (that was in a fragment) as a...
authorjeresig <jeresig@gmail.com>
Sat, 13 Feb 2010 08:14:00 +0000 (03:14 -0500)
committerjeresig <jeresig@gmail.com>
Sat, 13 Feb 2010 08:14:00 +0000 (03:14 -0500)
src/manipulation.js
src/support.js
test/unit/manipulation.js

index 1453f98c5c1424efbf47d174057088394231fee1..a10feae93c4f9b840f82ceecec53b044f01b3110 100644 (file)
@@ -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 {
index befc5327288da046cf5d209baeee1e03625c6780..c9ff58c368c36f25914126aa5b8c31e2ccb728d6 100644 (file)
@@ -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,
index 2492ca5d8e9063c58aa220de8744926da75cc6bb..eafbf25fc525478ee1c2212f7ca712e2bd840c6b 100644 (file)
@@ -376,7 +376,8 @@ test("append(Function) with incoming value", function() {
 });
 
 test("appendTo(String|Element|Array&lt;Element&gt;|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&lt;Element&gt;|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) {