Skip to content

Commit

Permalink
Fixes #9960, Append function not working for parent nodes that are no…
Browse files Browse the repository at this point in the history
…deType === 9
  • Loading branch information
dcooper committed Sep 7, 2012
1 parent 2a1e5ec commit c1aeb71
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/manipulation.js
Expand Up @@ -127,15 +127,15 @@ 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 );
}
});
},

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 );
}
});
Expand Down
16 changes: 16 additions & 0 deletions test/unit/manipulation.js
Expand Up @@ -530,6 +530,22 @@ test("append(Function) with incoming value", function() {
QUnit.reset();
});

test("Append not working on XML document, see #9960", function () {
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));
Expand Down

0 comments on commit c1aeb71

Please sign in to comment.