More defensive tagName check.