Add !== undefined to .attr to make equivalent to hasAttribute