Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #245 from ckeditor/t/241
Browse files Browse the repository at this point in the history
Fix: Add missing return value for link post-fixer. Closes #241.
  • Loading branch information
jodator authored Aug 1, 2019
2 parents d6c45df + f1eb91e commit 14e5803
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/linkediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export default class LinkEditing extends Plugin {
// Adding the class.
view.document.registerPostFixer( writer => {
const selection = editor.model.document.selection;
let changed = false;

if ( selection.hasAttribute( 'linkHref' ) ) {
const modelRange = findLinkRange( selection.getFirstPosition(), selection.getAttribute( 'linkHref' ), editor.model );
Expand All @@ -206,12 +207,15 @@ export default class LinkEditing extends Plugin {
// There might be multiple `a` elements in the `viewRange`, for example, when the `a` element is
// broken by a UIElement.
for ( const item of viewRange.getItems() ) {
if ( item.is( 'a' ) ) {
if ( item.is( 'a' ) && !item.hasClass( HIGHLIGHT_CLASS ) ) {
writer.addClass( HIGHLIGHT_CLASS, item );
highlightedLinks.add( item );
changed = true;
}
}
}

return changed;
} );

// Removing the class.
Expand Down

0 comments on commit 14e5803

Please sign in to comment.