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

Unit test covering edge case related to 'withChildren' parameter inside Renderer added #1455

Merged
merged 2 commits into from
Jul 4, 2018

Conversation

f1ames
Copy link
Contributor

@f1ames f1ames commented Jul 2, 2018

Suggested merge commit message (convention)

Internal: Added withChildren: false parameter missing after refactoring and unit test covering that case. Closes ckeditor/ckeditor5#4370. Closes #1452.


Additional information

What happens depending on withChildren value is described in more details in https://github.com/ckeditor/ckeditor5-engine/issues/1451#issuecomment-401356437. Added unit test shows the situation in which withChildren: true behaviour results in incorrect DOM structure after rendering.

I have added Closes ckeditor/ckeditor5#4353 as #1452 is a previous PR related to this topic, so if we decided to merge this one, #1452 should be closed.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 100.0% when pulling fde5971 on t/1451-2 into 66bf132 on master.

@f1ames f1ames requested a review from Reinmar July 2, 2018 11:29

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

const viewLi = view.getChild( 0 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viewLi of viewUl?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, view == <ul>. Sorry.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what this line does. Which <li> does it remove? There's no indented <li> at this stage.


const viewLi = view.getChild( 0 );
const viewLiIndented = view._removeChildren( 1, 1 ); // Array with one element.
viewLiIndented[ 0 ]._appendChild( parse( '<attribute:i>Baz</attribute:i>' ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the problem here that we use appendChild() on a detached node? That breaks automatic markToSync() calls, am I right?

I have a bad feeling about this – should renderer handle such cases? Shouldn't it be able to assume that markToSync is called for all nodes which are finally in the tree? That seems much easier than having markToSync used for half of the nodes in the tree.

cc @pjasiun

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it is View class who binds the view structure and the renderer. I think that render should be tested together with the view and even with the view writer. Integration tests FTW! ;)

@@ -1683,6 +1683,36 @@ describe( 'Renderer', () => {
);
} );

// #1451
it( 'should correctly render changed children even if direct parent is not marked to sync', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a bit too hard to read. Better variable naming + a comment what's happening inside it would help.

@Reinmar Reinmar force-pushed the t/1451-2 branch 2 times, most recently from 9fb3384 to fde5971 Compare July 4, 2018 09:48
@Reinmar
Copy link
Member

Reinmar commented Jul 4, 2018

I extracted the issue I found to https://github.com/ckeditor/ckeditor5-engine/issues/1456. Let's fix CC here and move forward because what we found is that we need to redesign this part of the engine :D

@Reinmar Reinmar merged commit d710524 into master Jul 4, 2018
@Reinmar Reinmar deleted the t/1451-2 branch July 4, 2018 09:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants