|
|
@@ -341,7 +341,7 @@ describe( 'Selection', () => {
|
|
|
} );
|
|
|
} );
|
|
|
|
|
|
- describe( 'setFocus()', () => {
|
|
|
+ describe( 'moveFocusTo()', () => {
|
|
|
it( 'keeps all existing ranges and fires no change:range when no modifications needed', () => {
|
|
|
selection.addRange( range );
|
|
|
selection.addRange( liveRange );
|
|
|
@@ -349,7 +349,7 @@ describe( 'Selection', () => {
|
|
|
const spy = sinon.spy();
|
|
|
selection.on( 'change:range', spy );
|
|
|
|
|
|
- selection.setFocus( selection.focus );
|
|
|
+ selection.moveFocusTo( selection.focus );
|
|
|
|
|
|
expect( count( selection.getRanges() ) ).to.equal( 2 );
|
|
|
expect( spy.callCount ).to.equal( 0 );
|
|
|
@@ -361,7 +361,7 @@ describe( 'Selection', () => {
|
|
|
const spy = sinon.spy();
|
|
|
selection.on( 'change:range', spy );
|
|
|
|
|
|
- selection.setFocus( Position.createAt( root, 'end' ) );
|
|
|
+ selection.moveFocusTo( Position.createAt( root, 'end' ) );
|
|
|
|
|
|
expect( spy.calledOnce ).to.be.true;
|
|
|
} );
|
|
|
@@ -370,8 +370,8 @@ describe( 'Selection', () => {
|
|
|
const endPos = Position.createAt( root, 'end' );
|
|
|
|
|
|
expect( () => {
|
|
|
- selection.setFocus( endPos );
|
|
|
- } ).to.throw( CKEditorError, /model-selection-setFocus-no-ranges/ );
|
|
|
+ selection.moveFocusTo( endPos );
|
|
|
+ } ).to.throw( CKEditorError, /model-selection-moveFocusTo-no-ranges/ );
|
|
|
} );
|
|
|
|
|
|
it( 'modifies existing collapsed selection', () => {
|
|
|
@@ -380,7 +380,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.setCollapsedAt( startPos );
|
|
|
|
|
|
- selection.setFocus( endPos );
|
|
|
+ selection.moveFocusTo( endPos );
|
|
|
|
|
|
expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
|
|
|
expect( selection.focus.compareWith( endPos ) ).to.equal( 'same' );
|
|
|
@@ -392,7 +392,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.setCollapsedAt( startPos );
|
|
|
|
|
|
- selection.setFocus( endPos );
|
|
|
+ selection.moveFocusTo( endPos );
|
|
|
|
|
|
expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
|
|
|
expect( selection.focus.compareWith( endPos ) ).to.equal( 'same' );
|
|
|
@@ -406,7 +406,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.addRange( new Range( startPos, endPos ) );
|
|
|
|
|
|
- selection.setFocus( newEndPos );
|
|
|
+ selection.moveFocusTo( newEndPos );
|
|
|
|
|
|
expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
|
|
|
expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
|
|
|
@@ -419,7 +419,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.addRange( new Range( startPos, endPos ) );
|
|
|
|
|
|
- selection.setFocus( newEndPos );
|
|
|
+ selection.moveFocusTo( newEndPos );
|
|
|
|
|
|
expect( selection.anchor.compareWith( startPos ) ).to.equal( 'same' );
|
|
|
expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
|
|
|
@@ -433,7 +433,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.addRange( new Range( startPos, endPos ), true );
|
|
|
|
|
|
- selection.setFocus( newEndPos );
|
|
|
+ selection.moveFocusTo( newEndPos );
|
|
|
|
|
|
expect( selection.anchor.compareWith( endPos ) ).to.equal( 'same' );
|
|
|
expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
|
|
|
@@ -447,7 +447,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.addRange( new Range( startPos, endPos ), true );
|
|
|
|
|
|
- selection.setFocus( newEndPos );
|
|
|
+ selection.moveFocusTo( newEndPos );
|
|
|
|
|
|
expect( selection.anchor.compareWith( endPos ) ).to.equal( 'same' );
|
|
|
expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
|
|
|
@@ -470,7 +470,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.on( 'change:range', spy );
|
|
|
|
|
|
- selection.setFocus( newEndPos );
|
|
|
+ selection.moveFocusTo( newEndPos );
|
|
|
|
|
|
const ranges = Array.from( selection.getRanges() );
|
|
|
|
|
|
@@ -491,7 +491,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.addRange( new Range( startPos, endPos ) );
|
|
|
|
|
|
- selection.setFocus( startPos );
|
|
|
+ selection.moveFocusTo( startPos );
|
|
|
|
|
|
expect( selection.focus.compareWith( startPos ) ).to.equal( 'same' );
|
|
|
expect( selection.isCollapsed ).to.be.true;
|
|
|
@@ -505,7 +505,7 @@ describe( 'Selection', () => {
|
|
|
|
|
|
selection.addRange( new Range( startPos, endPos ) );
|
|
|
|
|
|
- selection.setFocus( root, 'end' );
|
|
|
+ selection.moveFocusTo( root, 'end' );
|
|
|
|
|
|
expect( spy.calledOnce ).to.be.true;
|
|
|
expect( selection.focus.compareWith( newEndPos ) ).to.equal( 'same' );
|