Make sure elem.attribs exists

before calling hasOwnProperty on it
No spaces around function arguments please. LGTM otherwise.