Skip to content
Permalink
Browse files

Update Sizzle: allows disconnected sorting. Change add to always sort…

… with added nodes, even when disconnected.
  • Loading branch information...
timmywil committed Oct 16, 2012
1 parent ce5784a commit 420dcc58423dcfd3848fb62586da184b914cff22
Showing with 5 additions and 10 deletions.
  1. +1 −1 src/sizzle
  2. +1 −3 src/traversing.js
  3. +3 −6 test/unit/traversing.js
Submodule sizzle updated 3 files
+96 −74 sizzle.js
+43 −8 test/unit/selector.js
+44 −1 test/unit/utilities.js
@@ -132,9 +132,7 @@ jQuery.fn.extend({
jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
all = jQuery.merge( this.get(), set );

return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
all :
jQuery.unique( all ) );
return this.pushStack( jQuery.unique(all) );
},

addBack: function( selector ) {
@@ -582,7 +582,7 @@ test("contents()", function() {
});

test("add(String|Element|Array|undefined)", function() {
expect(16);
expect( 15 );
deepEqual( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
deepEqual( jQuery("#sndp").add( jQuery("#en")[0] ).add( jQuery("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );

@@ -597,13 +597,10 @@ test("add(String|Element|Array|undefined)", function() {
//equal( jQuery([]).add(jQuery("#form")[0].elements).length, jQuery(jQuery("#form")[0].elements).length, "Array in constructor must equals array in add()" );

var divs = jQuery("<div/>").add("#sndp");
ok( !divs[0].parentNode, "Make sure the first element is still the disconnected node." );

divs = jQuery("<div>test</div>").add("#sndp");
equal( divs[0].parentNode.nodeType, 11, "Make sure the first element is still the disconnected node." );
ok( divs[0].parentNode, "Sort with the disconnected node last (started with disconnected first)." );

divs = jQuery("#sndp").add("<div/>");
ok( !divs[1].parentNode, "Make sure the first element is still the disconnected node." );
ok( !divs[1].parentNode, "Sort with the disconnected node last." );

var tmp = jQuery("<div/>");

0 comments on commit 420dcc5

Please sign in to comment.
You can’t perform that action at this time.