-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.is() function #202
.is() function #202
Conversation
if (selector) { | ||
return this.filter(selector).length > 0; | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !!(selector && this.filter(selector).length);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this method more performant or just more terse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter. I'll take one line over four just about every time. ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I have to change it for it to get merged or is this just a style preference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave it as is if you prefer it that way. :)
I'm going to leave this pull request for @matthewmueller, since it's an API addition rather than a bug fix.
Ran into an opportunity where I could have used this. @matthewmueller , @davidchambers already agreed with this. Can we get it pulled in? |
Is this going to be merged in at any point, @matthewmueller? |
Bump. |
added: .is(selector) [zero21xxx]
looks good, sorry for the delay. |
.is()
function similar to jQuery implementation. You can use a selector or a function, just like.filter()
.Closes #168.
Thanks to @walling for the implementation suggestion.