Fix #13974: XML .attr("type")
Avoid jQuery(this) and a closure for .toggle(Boolean), close gh-1271.
(cherry picked from commit e53a91909061c7a7280a274990db179b94db81b6)