Skip to content

Commit

Permalink
Fix addClassToAnchors to not loop outside of editor or body
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Feb 8, 2017
1 parent edc0bbb commit a6c5c71
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions spec/anchor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ describe('Anchor Button TestCase', function () {
expect(editor.createLink).toHaveBeenCalledWith(opts);

link = editor.elements[0].querySelector('a');
expect(link).not.toBeNull();
expect(link.classList.contains('btn')).toBe(true);
expect(link.classList.contains('btn-default')).toBe(true);
expect(link).not.toBeNull('Link does not exist');
expect(link.classList.contains('btn')).toBe(true, 'Link does not contain class btn');
expect(link.classList.contains('btn-default')).toBe(true, 'Link does not contain class btn-default');
});

it('should remove the target _blank from the anchor tag when the open in a new window checkbox,' +
Expand Down
6 changes: 2 additions & 4 deletions src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,8 @@
} else {
var aChildren = el.getElementsByTagName('a');
if (aChildren.length === 0) {
while (el.nodeName.toLowerCase() !== 'a') {
el = el.parentNode;
}
el = [el];
var parentAnchor = Util.getClosestTag(el, 'a');
el = parentAnchor ? [parentAnchor] : [];
} else {
el = aChildren;
}
Expand Down

0 comments on commit a6c5c71

Please sign in to comment.