Skip to content
Permalink
Browse files

Selector state wasn't being passed along on a cloned jQuery object.

  • Loading branch information
jeresig committed Jan 8, 2009
1 parent 49d0d5b commit c6f189ac73939c813bf3a2b848c492c8ba259807
Showing with 12 additions and 1 deletion.
  1. +6 −0 src/core.js
  2. +6 −1 test/unit/core.js
@@ -73,6 +73,12 @@ jQuery.fn = jQuery.prototype = {
} else if ( jQuery.isFunction( selector ) )
return jQuery( document ).ready( selector );

// Make sure that old selector state is passed along
if ( selector.selector && selector.context ) {
this.selector = selector.selector;
this.context = selector.context;
}

return this.setArray(jQuery.makeArray(selector));
},

@@ -53,7 +53,7 @@ test("jQuery()", function() {
});

test("selector state", function() {
expect(26);
expect(28);

var test;

@@ -80,6 +80,11 @@ test("selector state", function() {
test = jQuery("#main", document.body);
equals( test.selector, "#main", "#main Selector" );
equals( test.context, document.body, "#main Context" );

// Test cloning
test = jQuery(test);
equals( test.selector, "#main", "#main Selector" );
equals( test.context, document.body, "#main Context" );

test = jQuery(document.body).find("#main");
equals( test.selector, "#main", "#main find Selector" );

0 comments on commit c6f189a

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