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

DomConverter throws an error when found <!-- comment --> #3860

Closed
pomek opened this issue Oct 21, 2016 · 6 comments · Fixed by ckeditor/ckeditor5-engine#935
Closed

DomConverter throws an error when found <!-- comment --> #3860

pomek opened this issue Oct 21, 2016 · 6 comments · Fixed by ckeditor/ckeditor5-engine#935
Assignees
Labels
package:engine type:bug This issue reports a buggy (incorrect) behavior.
Milestone

Comments

@pomek
Copy link
Member

pomek commented Oct 21, 2016

This line throws an error: Uncaught TypeError: Cannot read property 'toLowerCase' of undefined when domNode is a Comment.

I figured out it during our new testing environment (Karma & Webpack). Karma inserts a comment to body tag. DomConverter assumes that found domNode is an instance of HTMLElement.

For the first iteration, domNode is a document.body. For the second iteration, domNode is an instance of Comment.

image

I also reproduced this error in Bender.

Steps to reproduce:

  1. Add to this file - tests/view/observer/__template__.html - some HTML comment: <!-- some comment -->
  2. Run the test: tests/engine/view/observer/domeventdata

I know this issue is like "edge case" but we should prevent it.

@Reinmar Reinmar self-assigned this Nov 1, 2016
@Reinmar
Copy link
Member

Reinmar commented Nov 1, 2016

@Reinmar Reinmar removed their assignment Feb 2, 2017
@Reinmar
Copy link
Member

Reinmar commented Apr 10, 2017

What do we actually want to do with this? Do we want to convert comments to view? I guess we'll need to support comments in the view cause otherwise you wouldn't be able to easily produce data with comments.

However, if we'd need to work on converting comments to the model and back... that would be crazy. Of course, we're not going to introduce comments in the model, but one might want to convert comments to some elements or attrs. This would be quite a lot of work.

@Reinmar
Copy link
Member

Reinmar commented Apr 10, 2017

cc @pjasiun @szymonkups could this method return null for comments for now? Or will it break something?

@pjasiun
Copy link

pjasiun commented Apr 11, 2017

I agree with both: we should, at some point, handle comments conversion, to stop trimming all comments (I already see these SO issues: "CKE5 remove my comments!"). But that's also true that it will be some work to be done: view element, model element, converters, both tree walkers improvements and all function which use tree walkers.

For now, returning null should work fine. We need to handle null anyways for empty text nodes which have no view representation, so it should work for comments too.

@scofalik
Copy link
Contributor

Maybe it would be most safe to convert comments to collapsed markers? There are a lot of advantages to it.

@Reinmar
Copy link
Member

Reinmar commented Apr 18, 2017

Maybe it would be most safe to convert comments to collapsed markers? There are a lot of advantages to it.

In the future, this may be some idea. But I'd just ignore comments now.

@Reinmar Reinmar self-assigned this Apr 24, 2017
scofalik referenced this issue in ckeditor/ckeditor5-engine Apr 25, 2017
Fix: `DomConverter#domToView()` will not throw when converting a comment. Closes #647.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-engine Oct 9, 2019
@mlewand mlewand added this to the iteration 10 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed 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.

5 participants