Use instanceof check instead of tagName