Hacker News new | ask | show | jobs
by joesb 4697 days ago
> The DOM gives you NodeList for querySelectorAll and an Element for querySelector.

Because querySelector and querySelectorAll is not the same function, it can return different things.

I don't know how this apply to your case where same dot traversal return different things.

1 comments

If you want to use those, use them, then HTML.ify() the results or not. Either way, the point here is to encourage DOM use and eschew wrapper APIs.

If you want to use HTML.js's find() or dot-traversal, you must accept that your decision point was moved to how you handle the return value. And that you can use each() and only() to write code that safely abstracts the difference in results. Not an increase in complexity, just a shifting of it to somewhere i currently prefer.