Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering deeper changes fails to update text nodes #4174

Closed
Reinmar opened this issue Sep 5, 2017 · 4 comments · Fixed by ckeditor/ckeditor5-engine#1366
Closed

Rendering deeper changes fails to update text nodes #4174

Reinmar opened this issue Sep 5, 2017 · 4 comments · Fixed by ckeditor/ckeditor5-engine#1366
Assignees
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Sep 5, 2017

Example:

  1. Starting view and DOM: <p><a>Text<b>X</b></a></p>.
  2. Let's say that you type something at the end of this content which makes browser to create a lot of mutations and inserting the text in the wrong place (at the end of <p>) instead of at the end of <b> where we want to render it. It means that at this point we have the <p>'s children marked to be re-rendered.
  3. Now, in the model everything is fine so we end up with such a view to be rendered: <p><a>Text<b>XY</b></a></p>.
  4. What happens now is that the renderer tries to update first <a>'s children and then <p>'s children. It also wants to update "X" text node but since <a> will be rendered anyway, this is blocked.
  5. _updateChildren( <a> ) is executed but it takes <b> through viewToDom() which then uses mapViewToDom() (because in the view that's still the same element) and we get the old... <b>X</b> DOM element.
  6. This leaves us with an "X" instead of "XY".

This needs to be fixed in viewToDom() – it seems that it needs to somehow update the entire tree (not only take the element from the mapper) or mark its contents to be re-rendered by the renderer after it does its job.

Causes the following issues:

@Reinmar
Copy link
Member Author

Reinmar commented Sep 6, 2017

I also encountered a simillar issue in ckeditor/ckeditor5-basic-styles#55 (comment). It's worth checking when we'll be working on this fix.

@scofalik scofalik self-assigned this Sep 27, 2017
@scofalik
Copy link
Contributor

There are two bugs connected with this and related tickets. Both are caused by the fact that DomConverter sometimes returns references (when elements are already bound) and sometimes create new elements. It's also confusing for the programmer, because it is hard to say what you can do with the results got from DomConverter. For example, you should not append returned elements to other elements - if those were already in DOM/View tree, you mess up the current structure. Another problem is that this indirectly mixes responsibilities of Renderer and DomConverter. If we go with the original idea to refresh nodes in viewToDom then why we need a Renderer in the first place -- the refreshed changes will be already applied in DOM.

@scofalik
Copy link
Contributor

I've also pushed t/1125-wip which solves bugs described in:

But I am not sure I like those solutions and I think that we need to discuss how DomConverter and Renderer should behave and how other parts of code should use DomConverter.

@f1ames f1ames assigned f1ames and unassigned scofalik Mar 14, 2018
@f1ames
Copy link
Contributor

f1ames commented Mar 15, 2018

The https://github.com/ckeditor/ckeditor5-typing/issues/120 issue is just solved by adjusting mutations observer as in WIP branch ckeditor/ckeditor5-engine@669ff4f#diff-57e194ad013563b5752afa147f447d67R209.

In this case the typed letter is placed outside of the link like:

<span class="ck-link_selected">
    <a href="https://ckeditor.com">
        Lin
        <strong>k</strong>
    </a>
    a
</span>

Which causes inconsistency with the model. And then trying to map the a text throws an error. In case of:

const newViewChildren = Array.from( domConverter.domChildrenToView( domElement, { withChildren: false } ) );

the a text child is not mapped as it was not fetched from domConverter.

scofalik referenced this issue in ckeditor/ckeditor5-engine Mar 28, 2018
Other: Introduced deep children text nodes rerendering. Closes #1125. Closes #1093. Closes ckeditor/ckeditor5-typing#120.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-engine Oct 9, 2019
@mlewand mlewand added this to the iteration 15 milestone Oct 9, 2019
@mlewand mlewand added module:view type:bug This issue reports a buggy (incorrect) behavior. package:engine labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants