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

Fix: Incomplete CSS margin parsing if "auto" or "0" without unit is used #4270

Merged
merged 15 commits into from
Oct 2, 2020

Conversation

hub33k
Copy link
Contributor

@hub33k hub33k commented Sep 11, 2020

What is the purpose of this pull request?

Bug fix

Does your PR contain necessary tests?

All patches that 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

Did you follow the CKEditor 4 code style guide?

Your code should follow the guidelines from the CKEditor 4 code style guide which helps keep the entire codebase consistent.

  • PR is consistent with the code style guide

What is the proposed changelog entry for this pull request?

* [#1330>](https://github.com/ckeditor/ckeditor4/issues/1330): Fix converting margin style shorthand to separate styles.

What changes did you make?

Changed regex for splitMarginShorthand function so it now converts margin shorthands correctly.

Which issues does your PR resolve?

Closes #1330.

@hub33k hub33k marked this pull request as ready for review September 15, 2020 12:41
@f1ames f1ames self-requested a review September 15, 2020 14:49
@f1ames f1ames self-assigned this Sep 15, 2020
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

I'm not sure if we need manual test here since it doesn't bring any additional value over unit tests. We just need to check input - output of this method. And since it is more an integration test than unit one (checking entire flow using editor instance) we have (almost) exactly the same execution flow as in manual test.

tests/core/filter/editor.js Outdated Show resolved Hide resolved
@hub33k hub33k requested a review from f1ames September 15, 2020 20:11
@f1ames f1ames self-assigned this Sep 16, 2020
Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

Looks good 👍 Unit tests are now where they should be too.

I only had some doubts related to used regex (both versions in fact), please see my comment.

core/filter.js Outdated Show resolved Hide resolved
@hub33k
Copy link
Contributor Author

hub33k commented Sep 22, 2020

Rebased onto latest master.

@hub33k hub33k requested a review from f1ames September 23, 2020 14:00
@hub33k
Copy link
Contributor Author

hub33k commented Sep 24, 2020

Red CI is caused by #4285.

@f1ames f1ames self-assigned this Sep 30, 2020
@f1ames
Copy link
Contributor

f1ames commented Sep 30, 2020

Rebased onto latest master.

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

I added two unit tests checking backwards compatibility for handling invalid (or partially invalid) values. It would be good to keep this behavior consistent since they may be some editor parts (hopefully not) which relays on this behavior. It turned out that || [ '0px' ] alternative (mentioned somewhere in #4270 (comment)) is still needed 🙈

Now it handles invalid values the same way it did before, but some tests fails on IEs. It would be good to check what's going on. Since also invalid values tests fails there it might be good to check how it behaved with the previous regexp version there.

IE8:

IE9/IE10/IE11:

@hub33k
Copy link
Contributor Author

hub33k commented Sep 30, 2020

One test is failing (checked on Chrome)

Now it works (had to clean cache).

@hub33k
Copy link
Contributor Author

hub33k commented Sep 30, 2020

It seems that IE completely removes any invalid styles that occurs in code 🤔

rem is  invalid in IE8, becouse it's supported from >= IE9 https://caniuse.com/rem

@f1ames, should we omit testing invalid values in IE?

@hub33k hub33k requested a review from f1ames October 1, 2020 08:35
@f1ames
Copy link
Contributor

f1ames commented Oct 1, 2020

It seems that IE completely removes any invalid styles that occurs in code

Yes, if IE just doesn't accept invalid values we may skip those tests 👍 Btw. have you checked if it works the same with the previous regexp (if it's a browser fault it should).

rem is  invalid in IE8, becouse it's supported from >= IE9 https://caniuse.com/rem

I assume it is also removed in IE8 as invalid value. Is there any unit we can use here instead of rem (apart from px and %) to work also on IE8? I guess pt would be sufficient for example?

Copy link
Contributor

@f1ames f1ames left a comment

Choose a reason for hiding this comment

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

@hub33k
Copy link
Contributor Author

hub33k commented Oct 1, 2020

With previous regexp on IE8 these tests fails:

With previous regexp on IE11 these tests fails:

image

@hub33k
Copy link
Contributor Author

hub33k commented Oct 1, 2020

I guess pt would be sufficient for example?

Yes, it works on IE8. I assume we want to change rem to pt?

@hub33k hub33k requested a review from f1ames October 1, 2020 09:19
@hub33k
Copy link
Contributor Author

hub33k commented Oct 1, 2020

@f1ames I've replaced `rem` with pt and ignored testing invalid values on IE.

@f1ames f1ames self-assigned this Oct 2, 2020
Copy link
Contributor

@f1ames f1ames 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