Open positlabs opened 7 years ago
the queryChildren method was specifically for querying for selector matches among the immediate children of an element.
@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
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?
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.
What does
xtag.queryChildren
do?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.