Selector state wasn't being passed along on a cloned jQuery object.
This commit is contained in:
parent
49d0d5b7a3
commit
c6f189ac73
|
@ -73,6 +73,12 @@ jQuery.fn = jQuery.prototype = {
|
||||||
} else if ( jQuery.isFunction( selector ) )
|
} else if ( jQuery.isFunction( selector ) )
|
||||||
return jQuery( document ).ready( 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));
|
return this.setArray(jQuery.makeArray(selector));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ test("jQuery()", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("selector state", function() {
|
test("selector state", function() {
|
||||||
expect(26);
|
expect(28);
|
||||||
|
|
||||||
var test;
|
var test;
|
||||||
|
|
||||||
|
@ -80,6 +80,11 @@ test("selector state", function() {
|
||||||
test = jQuery("#main", document.body);
|
test = jQuery("#main", document.body);
|
||||||
equals( test.selector, "#main", "#main Selector" );
|
equals( test.selector, "#main", "#main Selector" );
|
||||||
equals( test.context, document.body, "#main Context" );
|
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");
|
test = jQuery(document.body).find("#main");
|
||||||
equals( test.selector, "#main", "#main find Selector" );
|
equals( test.selector, "#main", "#main find Selector" );
|
||||||
|
|
Loading…
Reference in a new issue