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

Make sure the ID is always inserted if entered in the advanced dialog #1914

Merged
merged 1 commit into from
Aug 1, 2018

Conversation

nathansamson
Copy link

What is the purpose of this pull request?

Fixes issue #1046

Does your PR contain necessary tests?

Not yet - will add later

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?

When creating a new element based on style it would remote the ID attribute to prevent duplicates.
This bit of code was added in 2011 to prevent an issue with copying links (according to the git blame and git log 235dc2a) - I did not retest this use case as I did not know where to find this issue
I modified it so it only removes ID's if the chosen ID already exists in the targetDocument

@nathansamson
Copy link
Author

I have trouble understanding the test suite and how to write an appropriate test for this...

Copy link
Contributor

@mlewand mlewand left a comment

Choose a reason for hiding this comment

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

Proposed solution fixes only symptoms, while leaving the source of the problem unaddressed.

I outlined the issue as a comment.

On top of that the tests are missing.

@@ -1662,7 +1662,8 @@ CKEDITOR.STYLE_OBJECT = 3;

// Avoid ID duplication.
if ( targetDocument.getCustomData( 'doc_processing_style' ) && el.hasAttribute( 'id' ) )
el.removeAttribute( 'id' );
if ( targetDocument.getById(el.getAttribute('id')) != null )
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a proper fix for this. Actually the problem originates from bad doc_processing_style custom data management.

If you trace the code changes, you'll notice that it was moved from setupElement function to applyStyleOnSelection - and this is exactly when the bug was introduced.

This attribute was used to, sort of, mark a single transaction - but in case of editing an existing link this function wasn't even called, thus it didn't clear this "switch".

All that is needed here is to restore it and it should work correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also the code style is inconsistent, see spacing next to parenthesis.

@mlewand
Copy link
Contributor

mlewand commented Aug 1, 2018

Thanks for the contribution, since it has been a while since you pushed the PR we'll take it from here and add the missing parts in a follow-up pull request.

@mlewand mlewand changed the base branch from master to t/1046 August 1, 2018 13:16
@mlewand mlewand changed the title Fix issue 1046. Always insert the ID if entered in advanced dialog Make sure the ID is always inserted if entered in the advanced dialog Aug 1, 2018
@mlewand mlewand merged commit 3b91f1f into ckeditor:t/1046 Aug 1, 2018
mlewand added a commit that referenced this pull request Aug 1, 2018
…ialog"

This reverts commit 3b91f1f.

The propsed fixed is not needed, see #1914 (comment) for more details.
mlewand added a commit that referenced this pull request Aug 6, 2018
…ialog"

This reverts commit 3b91f1f.

The propsed fixed is not needed, see #1914 (comment) for more details.
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