{"action":"opened","issue":{"url":"https://api.github.com/repos/yabwe/medium-editor/issues/1216","repository_url":"https://api.github.com/repos/yabwe/medium-editor","labels_url":"https://api.github.com/repos/yabwe/medium-editor/issues/1216/labels{/name}","comments_url":"https://api.github.com/repos/yabwe/medium-editor/issues/1216/comments","events_url":"https://api.github.com/repos/yabwe/medium-editor/issues/1216/events","html_url":"https://github.com/yabwe/medium-editor/issues/1216","id":177743138,"number":1216,"title":"CustomClassOption to complex anchor content not working","user":{"login":"annayafi","id":8353486,"avatar_url":"https://avatars.githubusercontent.com/u/8353486?v=3","gravatar_id":"","url":"https://api.github.com/users/annayafi","html_url":"https://github.com/annayafi","followers_url":"https://api.github.com/users/annayafi/followers","following_url":"https://api.github.com/users/annayafi/following{/other_user}","gists_url":"https://api.github.com/users/annayafi/gists{/gist_id}","starred_url":"https://api.github.com/users/annayafi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annayafi/subscriptions","organizations_url":"https://api.github.com/users/annayafi/orgs","repos_url":"https://api.github.com/users/annayafi/repos","events_url":"https://api.github.com/users/annayafi/events{/privacy}","received_events_url":"https://api.github.com/users/annayafi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-19T09:48:28Z","updated_at":"2016-09-19T09:48:28Z","closed_at":null,"body":"### Description\r\n\r\nIf you have a simple text that you wanna anchor, it works.\r\nIf you have a complex text, it's another story. Let's say something like :\r\n`<i><b>st te</b><strike><b>st t</b>es</strike></i><strike>t test</strike>`\r\nIf you have specified a button class to then function createLink, it won't be taken into account because it's going to handle the wrong node. The problem is the addClassToAnchors function, which won't traverse up to the parents node :+1: \r\n```\r\nif (el.nodeName.toLowerCase() === 'a') {\r\n                for (j = 0; j < classes.length; j += 1) {\r\n                    el.classList.add(classes[j]);\r\n                }\r\n            } else {\r\n                **el = el.getElementsByTagName('a');**\r\n                for (i = 0; i < el.length; i += 1) {\r\n                    for (j = 0; j < classes.length; j += 1) {\r\n                        el[i].classList.add(classes[j]);\r\n                    }\r\n                }\r\n            }\r\n```\r\n\r\n### Steps to reproduce\r\n\r\n1. Add style to your text\r\n2. Select some text crossing several styles.\r\n3. Call createLink on this selection, specifying a buttonClass option. \r\n\r\n**Expected behavior:** The button class you specified is added.\r\n**Actual behavior:** The button class is not added.\r\n\r\n**Link to an example:** https://jsfiddle.net/xgod0p9j/\r\n\r\n### Versions\r\n\r\n- medium-editor:\r\n- browser:\r\n- OS:\r\n"}}
{"actor":{"display_login":"annayafi"}}