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 #1524 from ckeditor/t/1474
Browse files Browse the repository at this point in the history
Other: Added new OT tests, reached 100% code coverage, fixed multiple OT scenarios, removed unreachable code. Closes #1474.
  • Loading branch information
Piotr Jasiun authored Sep 4, 2018
2 parents bf67c03 + f2c668b commit 6c2151a
Show file tree
Hide file tree
Showing 27 changed files with 2,462 additions and 339 deletions.
4 changes: 2 additions & 2 deletions src/model/operation/mergeoperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ export default class MergeOperation extends Operation {
const targetElement = this.targetPosition.parent;

// Validate whether merge operation has correct parameters.
if ( !sourceElement || !sourceElement.is( 'element' ) ) {
if ( !sourceElement || !sourceElement.is( 'element' ) || !sourceElement.parent ) {
/**
* Merge source position is invalid.
*
* @error merge-operation-source-position-invalid
*/
throw new CKEditorError( 'merge-operation-source-position-invalid: Merge source position is invalid.' );
} else if ( !targetElement || !targetElement.is( 'element' ) ) {
} else if ( !targetElement || !targetElement.is( 'element' ) || !targetElement.parent ) {
/**
* Merge target position is invalid.
*
Expand Down
14 changes: 14 additions & 0 deletions src/model/operation/splitoperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,27 @@ export default class SplitOperation extends Operation {
* @error split-operation-position-invalid
*/
throw new CKEditorError( 'split-operation-position-invalid: Split position is invalid.' );
} else if ( !element.parent ) {
/**
* Cannot split root element.
*
* @error split-operation-split-in-root
*/
throw new CKEditorError( 'split-operation-split-in-root: Cannot split root element.' );
} else if ( this.howMany != element.maxOffset - this.position.offset ) {
/**
* Split operation specifies wrong number of nodes to move.
*
* @error split-operation-how-many-invalid
*/
throw new CKEditorError( 'split-operation-how-many-invalid: Split operation specifies wrong number of nodes to move.' );
} else if ( this.graveyardPosition && !this.graveyardPosition.nodeAfter ) {
/**
* Graveyard position invalid.
*
* @error split-operation-graveyard-position-invalid
*/
throw new CKEditorError( 'split-operation-graveyard-position-invalid: Graveyard position invalid.' );
}
}

Expand Down
Loading

0 comments on commit 6c2151a

Please sign in to comment.