{"action":"closed","issue":{"url":"https://api.github.com/repos/yannickoo/menu_link_attributes/issues/20","repository_url":"https://api.github.com/repos/yannickoo/menu_link_attributes","labels_url":"https://api.github.com/repos/yannickoo/menu_link_attributes/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/yannickoo/menu_link_attributes/issues/20/comments","events_url":"https://api.github.com/repos/yannickoo/menu_link_attributes/issues/20/events","html_url":"https://github.com/yannickoo/menu_link_attributes/issues/20","id":176911519,"number":20,"title":"Empty attributes arent properly removed (e.g. empty target attribute)","user":{"login":"rgpublic","id":17726950,"avatar_url":"https://avatars0.githubusercontent.com/u/17726950?v=4","gravatar_id":"","url":"https://api.github.com/users/rgpublic","html_url":"https://github.com/rgpublic","followers_url":"https://api.github.com/users/rgpublic/followers","following_url":"https://api.github.com/users/rgpublic/following{/other_user}","gists_url":"https://api.github.com/users/rgpublic/gists{/gist_id}","starred_url":"https://api.github.com/users/rgpublic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgpublic/subscriptions","organizations_url":"https://api.github.com/users/rgpublic/orgs","repos_url":"https://api.github.com/users/rgpublic/repos","events_url":"https://api.github.com/users/rgpublic/events{/privacy}","received_events_url":"https://api.github.com/users/rgpublic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-14T13:45:22Z","updated_at":"2017-10-03T20:05:24Z","closed_at":"2017-10-03T20:05:24Z","author_association":"NONE","body":"The problem is in line #173 of menu_link_attributes.module:\n\n```\n     // Remove empty attributes by checking their string length.\n      foreach ($attributes as &$attribute) {\n        if (!is_array($attribute) && Unicode::strlen($attribute) === 0) {\n          unset($attribute);\n        }\n      }\n```\n\nUnset on a reference doesnt work that way. Only the reference is \"unreferenced\" in this case. The original value stays the same. You need to unset the key: \n\n```\n     // Remove empty attributes by checking their string length.\n      foreach ($attributes as $key=>$attribute) {\n        if (!is_array($attribute) && Unicode::strlen($attribute) === 0) {\n          unset($attributes[$key]);\n        }\n      }\n```\n"}}
{"actor":{"display_login":"yannickoo"}}