If I call document.getElementsByClassName('cl')
, I get a HTMLCollection. It seems to contain Element objects instead of HTMLElement objects, see Flow source, or Mozilla doc citing that it contains elements which are not HTMLElements. The W3C specification writes that HTMLCollection is a historical artifact, although I cannot seem to find any suggested alternative (what is 'Elements'?).
So should I check if returned object is indeed a HTMLElement? What else could it be and when? Or is there a better way to do what getElementsByClassName
and similar methods do? (without using external libraries)
Thanks in advance!