From: dcooper Date: Fri, 7 Sep 2012 18:12:24 +0000 (-0400) Subject: Fix #9960, allow manipulation for parent document nodes. Close gh-924. X-Git-Tag: 1.9.0b1~92 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=78c1560065e664213ac0cbea7518d442a58b0018;p=jquery.git Fix #9960, allow manipulation for parent document nodes. Close gh-924. --- diff --git a/AUTHORS.txt b/AUTHORS.txt index dea7ef995..834b1163a 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -154,3 +154,4 @@ Allen J Schmidt Jr Marcel Greter Matthias Jäggli Yiming He +Devin Cooper diff --git a/src/manipulation.js b/src/manipulation.js index b179dab2e..509daa6e5 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -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 ); } }); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 1d0dc4538..3a1d598d2 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -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(""), + xmlDoc2 = jQuery.parseXML(""), + 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));