Optimize hasTagName when called on an HTMLElement