aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/traversing.js6
-rw-r--r--test/unit/traversing.js4
2 files changed, 9 insertions, 1 deletions
diff --git a/src/traversing.js b/src/traversing.js
index dff108754..f57819d86 100644
--- a/src/traversing.js
+++ b/src/traversing.js
@@ -4,11 +4,17 @@ var runtil = /Until$/,
rparentsprev = /^(?:parents|prevUntil|prevAll)/,
// Note: This RegExp should be improved, or likely pulled from Sizzle
rmultiselector = /,/,
+ rchild = /^\s*>/,
isSimple = /^.[^:#\[\.,]*$/,
slice = Array.prototype.slice;
jQuery.fn.extend({
find: function( selector ) {
+ // Handle "> div" child selectors and pass them to .children()
+ if ( typeof selector === "string" && rchild.test( selector ) ) {
+ return this.children( selector.replace( rchild, "" ) );
+ }
+
var ret = this.pushStack( "", "find", selector ), length = 0;
for ( var i = 0, l = this.length; i < l; i++ ) {
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index f5c88e42c..0636f0c33 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -1,12 +1,14 @@
module("traversing");
test("find(String)", function() {
- expect(2);
+ expect(3);
equals( 'Yahoo', jQuery('#foo').find('.blogTest').text(), 'Check for find' );
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
equals( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
+
+ same( jQuery("#main").find("> div").get(), q("foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest"), "find child elements" );
});
test("is(String)", function() {