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 #1455 from ckeditor/t/1451-2
Browse files Browse the repository at this point in the history
Internal: Added `withChildren: false` parameter missing after refactoring and unit test covering that case. Closes #1451. Closes #1452.
  • Loading branch information
Reinmar authored Jul 4, 2018
2 parents e23742c + fde5971 commit d710524
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export default class Renderer {

const actualDomChildren = this.domConverter.mapViewToDom( viewElement ).childNodes;
const expectedDomChildren = Array.from(
this.domConverter.viewChildrenToDom( viewElement, domElement.ownerDocument )
this.domConverter.viewChildrenToDom( viewElement, domElement.ownerDocument, { withChildren: false } )
);
const diff = this._diffNodeLists( actualDomChildren, expectedDomChildren );
const actions = this._findReplaceActions( diff, actualDomChildren, expectedDomChildren );
Expand Down
30 changes: 30 additions & 0 deletions tests/view/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,36 @@ describe( 'Renderer', () => {
);
} );

// #1451
it( 'should correctly render changed children even if direct parent is not marked to sync', () => {
const inputView =
'<container:ul>' +
'<container:li>Foo</container:li>' +
'<container:li><attribute:b>Bar</attribute:b></container:li>' +
'</container:ul>';

const view = parse( inputView );

viewRoot._appendChild( view );

renderer.markToSync( 'children', viewRoot );
renderer.render();

expect( domRoot.innerHTML ).to.equal( '<ul><li>Foo</li><li><b>Bar</b></li></ul>' );

const viewLi = view.getChild( 0 );
const viewLiIndented = view._removeChildren( 1, 1 ); // Array with one element.
viewLiIndented[ 0 ]._appendChild( parse( '<attribute:i>Baz</attribute:i>' ) );
const viewUl = new ViewContainerElement( 'ul', null, viewLiIndented );
viewLi._appendChild( viewUl );

renderer.markToSync( 'children', view );
renderer.markToSync( 'children', viewLi );
renderer.render();

expect( domRoot.innerHTML ).to.equal( '<ul><li>Foo<ul><li><b>Bar</b><i>Baz</i></li></ul></li></ul>' );
} );

describe( 'fake selection', () => {
beforeEach( () => {
const { view: viewP, selection: newSelection } = parse(
Expand Down

0 comments on commit d710524

Please sign in to comment.