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

Fixed issues with applying inline styles to HTML comments #2381

Merged
merged 13 commits into from
Sep 6, 2018
Merged

Conversation

mlewand
Copy link
Contributor

@mlewand mlewand commented Sep 5, 2018

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.

This PR contains

  • Unit tests
  • Manual tests

What changes did you make?

While checking #2294 bug I found that HTML comments are badly handled.

First I had a fix in 85b89ec - which fixed the issue requested in #2294 but I wasn't quite happy about the way how it did it. For instance, applying strong to the following HTML:

<p>foo</p>
<!--/end logo -->
<p> </p>
<!-- Begin: Body -->
<p>a<br />a</p>

Would result with:

<p><strong>foo</strong></p>
<strong><!--/end logo --></strong>
<p><strong>&nbsp;</strong></p>
<strong><!-- Begin: Body --></strong>
<p><strong>a<br />a</strong></p>

It could be acceptable to some extend, but it's pretty dirty HTML nontheless so I dig deeper, and after some further checking I was able to create a more clean result:

<p><strong>foo</strong></p>
<!--/end logo -->
<p><strong>&nbsp;</strong></p>
<!-- Begin: Body -->
<p><strong>a<br />a</strong></p>

Also you might note that in 7da825e I have reverted some refactoring. Imho name checkIfTextOrReadonlyOrEmptyElement is not the prettiest, personally I'd use sth like if ( isText( foo ) || isReadonly( foo ) || ( isEmpty( foo ) and isElement( foo ) ) ) - but decided to revert it, to make just essential changes (except some doc typos cleanup).

Closes #2294 and closes #2380.

@Comandeer Comandeer self-requested a review September 6, 2018 08:22
@Comandeer Comandeer self-assigned this Sep 6, 2018
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

There is no manual test for #2380. It could be even added as additional step to existing one as it's basically checking the source of the editor.

@@ -0,0 +1,20 @@
@bender-tags: bug, 2296, 4.10.1
Copy link
Member

Choose a reason for hiding this comment

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

Please update version tag. Also note that this is fix for #2294, not #2296!

Copy link
Contributor Author

@mlewand mlewand Sep 6, 2018

Choose a reason for hiding this comment

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

I suppose I'm going to mix these two till the end of time. 😉 Fixed in 586cf64.

test_inline_nobreak1: function() {
playground.setHtml( 'this is <a href="http://example.com/">some sample</a> text' );

var range = new CKEDITOR.dom.range( doc );
range.setStart( playground, 0 );
range.setEnd( playground.getChild( 1 ).getFirst(), 4 );

playground.trim();
Copy link
Member

Choose a reason for hiding this comment

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

Is this change needed? Checked in Chrome, Firefox, Safari and IE 8 – nothing failed without it.

Copy link
Contributor Author

@mlewand mlewand Sep 6, 2018

Choose a reason for hiding this comment

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

No, it's no longer needed. It was just a leftover I made when cleaning up markup for IE8. Several tests required to strip bounding whitespaces, as otherwise extra paragraphs were created. Dropped in 5fca69d.

@Comandeer Comandeer removed their assignment Sep 6, 2018
@mlewand mlewand self-assigned this Sep 6, 2018
@mlewand mlewand removed their assignment Sep 6, 2018
@Comandeer Comandeer self-assigned this Sep 6, 2018
Copy link
Member

@Comandeer Comandeer left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants