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 #1744 from ckeditor/t/1743
Browse files Browse the repository at this point in the history
Internal: Fixed `Writer` `model-writer-insert-forbidden-move` error usage. Closes #1743.
  • Loading branch information
Piotr Jasiun authored Jun 10, 2019
2 parents ab15b17 + b2ab13e commit f70cf35
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,16 @@ export default class Writer {
// If it isn't the same root.
else {
if ( item.root.document ) {
// It is forbidden to move a node that was already in a document outside of it.
throw new Error( 'model-writer-insert-forbidden-move: Cannot move a node from a document to a different tree.' );
/**
* Cannot move a node from a document to a different tree.
* It is forbidden to move a node that was already in a document outside of it.
*
* @error model-writer-insert-forbidden-move
*/
throw new CKEditorError(
'model-writer-insert-forbidden-move: ' +
'Cannot move a node from a document to a different tree. ' +
'It is forbidden to move a node that was already in a document outside of it.' );
} else {
// Move between two different document fragments or from document fragment to a document is possible.
// In that case, remove the item from it's original parent.
Expand Down
4 changes: 2 additions & 2 deletions tests/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe( 'Writer', () => {

expect( () => {
insert( node, docFrag );
} ).to.throw();
} ).to.throw( CKEditorError, /^model-writer-insert-forbidden-move/ );
} );

it( 'should transfer markers from given DocumentFragment', () => {
Expand Down Expand Up @@ -716,7 +716,7 @@ describe( 'Writer', () => {

expect( () => {
append( node, docFrag );
} ).to.throw();
} ).to.throw( CKEditorError, /^model-writer-insert-forbidden-move/ );
} );
} );

Expand Down

0 comments on commit f70cf35

Please sign in to comment.