Fix issue where element.id could return an invalid value.
In some cases, e.g. <div id='foo'><input name="id"></div>, div.id would return <input name="id"> instead of 'foo'