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

Document the difference between queries and predicates #213

Open
benshine opened this issue Jul 6, 2016 · 3 comments
Open

Document the difference between queries and predicates #213

benshine opened this issue Jul 6, 2016 · 3 comments

Comments

@benshine
Copy link

benshine commented Jul 6, 2016

The doc has sections for queries and predicates, but it's not clear to me exactly what the difference is. It seems important though. Something about how they are called, maybe?

Some documentation would help here -- or does it already exist and I'm missing it?

@benshine
Copy link
Author

benshine commented Jul 6, 2016

I think I understand this now, and I can clarify my confusion, at least:
predicates return a function that must be called. queries simply return data.
If we want to know whether text inside an element with selector AwesomeLabel matches some string, we can ask for that in two ways.

  1. Query the text and then check whether it matches ourselves: labelText: text('.AwesomeLabel'),
  2. with a contains function: labelContains: contains('.AwesomeLabel')

The big difference here is how we'd use those two functions.

console.log(el.labelText); // Just a get
console.log("text matches 'Alison'?", el.labelContains("Alison"));

@san650
Copy link
Owner

san650 commented Jul 6, 2016

@benshine that's correct, contains generates a function you can use to test elements for content. We need to improve the documentations a lot here to make it easy to understand how it works.

@san650
Copy link
Owner

san650 commented Jul 6, 2016

Also note that predicates always return true / false values as opposed to queries which return values from the DOM element (text content, attribute values, etc.).

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

No branches or pull requests

2 participants