Make sure elem.attribs exists

before calling hasOwnProperty on it