Well, I guess you would be in favor of throwing away maybe half of all the api then that’s already built into the browser? Or at least think it was a mistake? Should the browser never have attempted to incorporate JQuery’s popular features into the browser?
I agree with you that use of the name next(), as JQuery uses, would be confusing.
It’s kind of interesting that the browser incorporated JQuery’s “closest” method (at least a subset of it), even sticking to the name. It’s not clear to me that implementing “closest” saved that many lines of code either, when looked at from the point of view of a single application. Was that a mistake? It seems like there’s some mathematical formula that would ideal to be able determine what is worth adding to the browser: (lines of code needed to implemented) * (number of web sites that use this functionality). The big problem is there doesn’t seem to be a scientific way of determining the second factor.
I think it’s kind of confusing to have “closest” that only matches going up, and querySelector that only matches going down, and nothing that matches going sideways. Has anyone scientifically determined that searching sideways is significantly less needed than the other two directions? My guess ( in terms of volume of use) would be down => sideways => up, so having jquery’s “closest” but not “next” is a travesty of justice
My vote would be to simplify the learning curve, and enhance “closest” with a second parameter, to be able to specify what direction to search in, which would effectively cause querySelector to be redundant (I think). Directions could be ancestor, descendant, previousSibling, nextSibling (and maybe some combinations?). For backwards compatibility, ancestor would have to be the default. “Closest” is a lot easier to understand than “QuerySelector.” Plus it’s shorter (especially if that second parameter could be made small, like ‘^’, ‘>’, ‘<’, ‘v’).
I also wonder whether when browsers implement these features natively, they might have any fancy techniques for caching results?
There are other precedents for duplicate functionality being provided in the browser api as the browser evolves…
Just my two cents