Re: [dom] Consider new method: getNodesByType (#37)

> To say that no technology should be considered if alternate to the popular querySelector method is a halting conservative position for a group tasked with maintaining and improving upon an important technology. There are access means that querySelector does not solve for, and still require walking the tree.

You continue to hyperbolize my position to the point of ridiculousness.  This is not a useful argument technique.

What I *actually* said, repeatedly, was that we can't add API for every possible convenience someone can come up with; we have to prioritize for those usage patterns that are common.  querySelector() was added because tree-walking to find element nodes that matched Selector-compatible patterns was extremely common, and fairly annoying to do.  Adding API to make it simpler was a big usability win.

Since the introduction of querySelector(), tree-walking has become much more rare.  That suggests that the other tree-walking use-cases that querySelector() can't solve (looking for comments or text nodes) were only ever a small percentage of all the tree-walking cases, and so it's much less compelling to try and add more API surface for them.

> The code you provided is hardly trivial though.

It really is.  It's a `querySelector()` and a `forEach()` call, both staples of JS programming.  (If you're not comfortable with basic functional programming, the `forEach()` can be translated into a trivial `for` loop.) The `[].slice.call()` is a common and well-known hack to translate a NodeList into an Array.

> Attributes appear to only be a name value pair and are accessed as such, however attributes are described and constricted by property definitions.

Not in browsers.  XMLSchema is not implemented by browsers, and is thus irrelevant for this discussion.

> If we were only talking about HTML and ignored both forms and accessibility generally then I would say you are less wrong on this point. The DOM has wider use cases than either HTML or XML.

In practice, it does not.  The vast, **vast** majority of DOM usage in browsers is over HTML or its related languages (SVG and MathML); anything else is a rounding error.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/37#issuecomment-106647688

Received on Friday, 29 May 2015 01:18:17 UTC