Skip to content

Commit

Permalink
Merge pull request #9746 from ckeditor/ck/9338
Browse files Browse the repository at this point in the history
Feature (engine): Introduced `'mouseover'` and `'mouseout'` events in the `MouseObserver` class. Closes #9338.
  • Loading branch information
pomek committed May 25, 2021
2 parents b503441 + 794ced3 commit 79454f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class MouseObserver extends DomEventObserver {
constructor( view ) {
super( view );

this.domEventType = [ 'mousedown', 'mouseup' ];
this.domEventType = [ 'mousedown', 'mouseup', 'mouseover', 'mouseout' ];
}

onDomEvent( domEvent ) {
Expand Down
28 changes: 27 additions & 1 deletion packages/ckeditor5-engine/tests/view/observer/mouseobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe( 'MouseObserver', () => {
} );

it( 'should define domEventType', () => {
expect( observer.domEventType ).to.deep.equal( [ 'mousedown', 'mouseup' ] );
expect( observer.domEventType ).to.deep.equal( [ 'mousedown', 'mouseup', 'mouseover', 'mouseout' ] );
} );

describe( 'onDomEvent', () => {
Expand Down Expand Up @@ -52,5 +52,31 @@ describe( 'MouseObserver', () => {
const data = spy.args[ 0 ][ 1 ];
expect( data.domTarget ).to.equal( document.body );
} );

it( 'should fire mouseover with the right event data', () => {
const spy = sinon.spy();

viewDocument.on( 'mouseover', spy );

observer.onDomEvent( { type: 'mouseover', target: document.body } );

expect( spy.calledOnce ).to.be.true;

const data = spy.args[ 0 ][ 1 ];
expect( data.domTarget ).to.equal( document.body );
} );

it( 'should fire mouseout with the right event data', () => {
const spy = sinon.spy();

viewDocument.on( 'mouseout', spy );

observer.onDomEvent( { type: 'mouseout', target: document.body } );

expect( spy.calledOnce ).to.be.true;

const data = spy.args[ 0 ][ 1 ];
expect( data.domTarget ).to.equal( document.body );
} );
} );
} );

0 comments on commit 79454f8

Please sign in to comment.