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 ) )
|
||||
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;
|
||||
|
||||
|
@ -81,6 +81,11 @@ test("selector state", function() {
|
|||
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" );
|
||||
equals( test.context, document.body, "#main find Context" );
|
||||
|
|
Loading…
Reference in a new issue