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

xtag.queryChildren #166

Open
positlabs opened this issue Nov 30, 2016 · 4 comments
Open

xtag.queryChildren #166

positlabs opened this issue Nov 30, 2016 · 4 comments
Assignees

Comments

@positlabs
Copy link

What does xtag.queryChildren do?

Query only the direct children of an element with a provided selector.

<div id="dave">
	<div class="a">
		<div class="a sub"></div>
	</div>
</div>

If I did xtag.queryChildren(daveElement, '.a'), would it only select <div class="a"> and not <div class="a sub">?

I think the method name could be something like xtag.queryShallow()

OR...

It could be an internal method that is used by xtag.query(ELEMENT, SELECTOR, DEEP=true) when a boolean is passed. e.g. xtag.query(daveElement, '.a', false). This would simplify the API a bit.

@csuwildcat
Copy link
Member

the queryChildren method was specifically for querying for selector matches among the immediate children of an element.

@positlabs
Copy link
Author

@csuwildcat I get that, after typing it out. What do you think about simplifying the API, though?

I'm proposing we use xtag.query(ELEMENT, SELECTOR, DEEP=true), and removing xtag.queryChildren

@csuwildcat
Copy link
Member

OK, here's how we could do this:

  1. I can't ax the queryChildren method altogether in 1.x, because that's a breaking change
  2. We can either redo queryChildren, or add functionality to query and use it within queryChildren to maintain its support
  3. If we mod query, the last arg would be SHALLOW=FALSE by default, because the way you wrote it would default query to being child-level, which would break people using it the way it is now.

Thoughts?

@positlabs
Copy link
Author

I like that approach. DEEP=true is the same as SHALLOW=false :)

I think SHALLOW=false is more explicit. Makes more sense to enable the shallow functionality, rather than disable the default.

@csuwildcat csuwildcat self-assigned this Dec 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants