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