]> source.dussan.org Git - jquery.git/commitdiff
Fix #9960, allow manipulation for parent document nodes. Close gh-924.
authordcooper <dcooper@snap-interactive.com>
Fri, 7 Sep 2012 18:12:24 +0000 (14:12 -0400)
committerDave Methvin <dave.methvin@gmail.com>
Sat, 24 Nov 2012 21:53:27 +0000 (16:53 -0500)
AUTHORS.txt
src/manipulation.js
test/unit/manipulation.js

index dea7ef9956bcaa4a46c0f4ad60719b5205ad6b54..834b1163ab5802767af19fb9acf5cd050e70e383 100644 (file)
@@ -154,3 +154,4 @@ Allen J Schmidt Jr <cobrasoft@gmail.com>
 Marcel Greter <marcel.greter@ocbnet.ch>
 Matthias Jäggli <matthias.jaeggli@gmail.com>
 Yiming He <yiminghe@gmail.com>
+Devin Cooper <cooper.semantics@gmail.com>
index b179dab2eff90172d43e5c5396ecc9e2238a8916..509daa6e5dcf72fcfe2b4caa990fca414662d54c 100644 (file)
@@ -126,7 +126,7 @@ jQuery.fn.extend({
 
        append: function() {
                return this.domManip(arguments, true, function( elem ) {
-                       if ( this.nodeType === 1 || this.nodeType === 11 ) {
+                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
                                this.appendChild( elem );
                        }
                });
@@ -134,7 +134,7 @@ jQuery.fn.extend({
 
        prepend: function() {
                return this.domManip(arguments, true, function( elem ) {
-                       if ( this.nodeType === 1 || this.nodeType === 11 ) {
+                       if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
                                this.insertBefore( elem, this.firstChild );
                        }
                });
index 1d0dc453877604b22ba61ceb339b1f56182f01f8..3a1d598d20cb18a32888ce48301182f006648ac5 100644 (file)
@@ -527,6 +527,24 @@ test("append(Function) with incoming value", function() {
        QUnit.reset();
 });
 
+test("replaceWith on XML document (#9960)", function () {
+       expect( 1 );
+
+       var newNode,
+               xmlDoc1 = jQuery.parseXML("<scxml xmlns='http://www.w3.org/2005/07/scxml' version='1.0'><state x='100' y='100' initial='actions' id='provisioning'></state><state x='100' y='100' id='error'></state><state x='100' y='100' id='finished' final='true'></state></scxml>"),
+               xmlDoc2 = jQuery.parseXML("<scxml xmlns='http://www.w3.org/2005/07/scxml' version='1.0'><state id='provisioning3'></state></scxml>"),
+               xml1 = jQuery( xmlDoc1 ),
+               xml2 = jQuery( xmlDoc2 ),
+               scxml1 = jQuery( ":first", xml1 ),
+               scxml2 = jQuery( ":first", xml2 );
+       
+       scxml1.replaceWith( scxml2 );
+       
+       newNode = jQuery( ":first>state[id='provisioning3']", xml1 );
+       
+       equal( newNode.length, 1, "ReplaceWith not working on document nodes." );
+});
+
 test("append the same fragment with events (Bug #6997, 5566)", function () {
        var doExtra = !jQuery.support.noCloneEvent && document["fireEvent"];
        expect(2 + (doExtra ? 1 : 0));