git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
49d0d5b
)
Selector state wasn't being passed along on a cloned jQuery object.
author
John Resig
<jeresig@gmail.com>
Thu, 8 Jan 2009 21:41:58 +0000
(21:41 +0000)
committer
John Resig
<jeresig@gmail.com>
Thu, 8 Jan 2009 21:41:58 +0000
(21:41 +0000)
src/core.js
patch
|
blob
|
history
test/unit/core.js
patch
|
blob
|
history
diff --git
a/src/core.js
b/src/core.js
index
61a9bd9
..
fe5dbc6
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-73,6
+73,12
@@
jQuery.fn = jQuery.prototype = {
} else if ( jQuery.isFunction( selector ) )
return jQuery( document ).ready( selector );
} 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));
},
return this.setArray(jQuery.makeArray(selector));
},
diff --git
a/test/unit/core.js
b/test/unit/core.js
index
ee5f805
..
98a161f
100644
(file)
--- a/
test/unit/core.js
+++ b/
test/unit/core.js
@@
-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);
equals( test.selector, "#main", "#main Selector" );
equals( test.context, document.body, "#main Context" );
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" );
test = jQuery(document.body).find("#main");
equals( test.selector, "#main", "#main find Selector" );