Skip to content
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

Merged
merged 3 commits into from
Jun 6, 2013
Merged

.is() function #202

merged 3 commits into from
Jun 6, 2013

Conversation

arb
Copy link
Contributor

@arb arb commented May 5, 2013

  • Added the .is() function similar to jQuery implementation. You can use a selector or a function, just like .filter().
  • Added unit tests
  • Updated the Readme

Closes #168.

Thanks to @walling for the implementation suggestion.

if (selector) {
return this.filter(selector).length > 0;
}
return false;
Copy link
Contributor

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);

Copy link
Contributor Author

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?

Copy link
Contributor

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. ;)

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@jeremy-dentel
Copy link

Ran into an opportunity where I could have used this. @matthewmueller , @davidchambers already agreed with this. Can we get it pulled in?

@jeremy-dentel
Copy link

@arb
Copy link
Contributor Author

arb commented May 29, 2013

Is this going to be merged in at any point, @matthewmueller?

@arb
Copy link
Contributor Author

arb commented Jun 6, 2013

Bump.

matthewmueller added a commit that referenced this pull request Jun 6, 2013
@matthewmueller matthewmueller merged commit 74ddd00 into cheeriojs:master Jun 6, 2013
@matthewmueller
Copy link
Member

looks good, sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support for jQuery .is()
4 participants