Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Make sure that .find() with multiple direct child selectors is handle…
…d correctly. Fixes #7144.
- Loading branch information
Showing
2 changed files
with
4 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ var runtil = /Until$/, | ||
rparentsprev = /^(?:parents|prevUntil|prevAll)/, | ||
// Note: This RegExp should be improved, or likely pulled from Sizzle | ||
rmultiselector = /,/, | ||
rchild = /^\s*>/, | ||
rchild = /(^|,)\s*>/g, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jeresig
Author
Member
|
||
isSimple = /^.[^:#\[\.,]*$/, | ||
slice = Array.prototype.slice, | ||
POS = jQuery.expr.match.POS; | ||
@@ -13,7 +13,7 @@ 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, "" ) ); | ||
return this.children( selector.replace( rchild, "$1" ) ); | ||
} | ||
|
||
var ret = this.pushStack( "", "find", selector ), length = 0; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Why not just match selector strings that contain just one child (
>
) selector? Something like:/^\s*>([^>]*)$/
? The> div >
case is not nearly as common as>
or> div
.