Return True if this node has ``attr``.

def hasAttribute(self, attr: str) -> bool:
        """Return True if this node has ``attr``."""
        if attr == 'class':
            return bool(self.classList)
        return attr in self.attributes