News for hackers. Stuff that matters.
Re:I loved jQuery, and still do (2019) by chrismorgan on Tuesday June 29, 2021 @12:08PM (#27677903)
> For example, natively getting a list of children is `el.children` but natively getting the parent is `el.parentNode`, not `el.parent`.

Actually, .children is the child elements; .childNodes is all the children (including comments and text as well as elements).

> Meanwhile, natively getting a list of classes is `el.classList`, but when I'm getting children I also get a list, so why not `el.childList` instead of `el.children`?

I’m not sure why they want with .classList instead of .classes, but I expect .className is a part of the history. If redesigning it from scratch and still retaining the functionality of .children, I’d rename it .childElements. Certainly not .childList.

And of course, the reasons for most of this stuff is the history. Some of the web’s APIs have aged well; others haven’t.

There are no comments on this comment yet.