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

Commit

Permalink
Fix: Selection attribute is not updated on consecutive `HighlightComm…
Browse files Browse the repository at this point in the history
…and#execute()` calls.
  • Loading branch information
jodator committed Feb 20, 2018
1 parent 7ddd2ea commit 943d665
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/highlightcommand.js
Expand Up @@ -84,6 +84,7 @@ export default class HighlightCommand extends Command {
} else {
// ...update `highlight` value.
writer.setAttribute( 'highlight', highlighter, highlightRange );
writer.setSelectionAttribute( 'highlight', highlighter );
}
} else if ( highlighter ) {
writer.setSelectionAttribute( 'highlight', highlighter );
Expand Down
16 changes: 16 additions & 0 deletions tests/highlightcommand.js
Expand Up @@ -172,6 +172,22 @@ describe( 'HighlightCommand', () => {
expect( command.value ).to.be.undefined;
expect( doc.selection.hasAttribute( 'highlight' ) ).to.be.false;
} );

it( 'should change selection attribute on consecutive calls', () => {
setData( model, '<p>abcfoobar[] foobar</p>' );

expect( command.value ).to.be.undefined;

command.execute( { value: 'greenMarker' } );

expect( command.value ).to.equal( 'greenMarker' );
expect( doc.selection.hasAttribute( 'highlight' ) ).to.be.true;

command.execute( { value: 'pinkMarker' } );

expect( command.value ).to.equal( 'pinkMarker' );
expect( doc.selection.hasAttribute( 'highlight' ) ).to.be.true;
} );
} );

describe( 'on not collapsed range', () => {
Expand Down

0 comments on commit 943d665

Please sign in to comment.