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

Commit

Permalink
Add a description in a code for the fix. Improve name of the unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Samsel committed Jun 6, 2019
1 parent 2a8fc67 commit d7ec424
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/model/utils/insertcontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,14 @@ class Insertion {
this.position = this.writer.createPositionBefore( parent );

// Special case – parent is empty (<p>^</p>).
//
// 1. parent.isEmpty
// We can remove the element after moving insertion position out of it.
//
// 2. parent.parent === allowedIn
// However parent should remain in place when allowed element is above limit element in document tree.
// For example there shouldn't be allowed to remove empty paragraph from tableCell, when is pasted
// content allowed in $root.
if ( parent.isEmpty && parent.parent === allowedIn ) {
this.writer.remove( parent );
}
Expand Down
2 changes: 1 addition & 1 deletion tests/model/utils/insertcontent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ describe( 'DataController utils', () => {
expect( stringify( root, affectedRange ) ).to.equal( '<limit>[ab]foo</limit>' );
} );

describe( 'when allowed elements is somewhere above limit', () => {
describe( 'when allowed element is above limit element in document tree', () => {
// $root > table > tableRow > tableCell > paragraph
// After inserting new table ( allowed in root ), empty paragraph shouldn't be removed from current tableCell.
beforeEach( () => {
Expand Down

0 comments on commit d7ec424

Please sign in to comment.