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

Add CKEDITOR.dom.documentFragment.find and CKEDITOR.dom.documentFragment.findOne #2701

Merged
merged 7 commits into from
Dec 28, 2018

Conversation

Comandeer
Copy link
Member

What is the purpose of this pull request?

New feature

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?

I've added find and findOne methods to the CKEDITOR.dom.documentFragment.

Closes #2021.

@mlewand mlewand self-requested a review December 28, 2018 12:29
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.

The solution is nice. There are minor issues with tests maintainability and a single thing in changelog.

CHANGES.md Outdated
@@ -6,7 +6,7 @@
API Changes:

* [#1496](https://github.com/ckeditor/ckeditor-dev/issues/1496): [Balloon Toolbar](https://ckeditor.com/cke4/addon/balloontoolbar) exposed methods [CKEDITOR.ui.balloonToolbar.repositon](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_balloonToolbar.html#reposition) and [CKEDITOR.ui.balloonToolbarView.reposition](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_ui_balloonToolbarView.html#reposition).

* [#2021]: Add [`CKEDITOR.dom.documentFragment.find`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_documentFragment.html#find) and [`CKEDITOR.dom.documentFragment.findOne`](https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_documentFragment.html#findOne) methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the links are valid, they should be prefixed with method- string, like this example:

https://ckeditor.com/docs/ckeditor4/latest/api/CKEDITOR_dom_documentFragment.html#method-append

found = frag.find( 'b' );
assert.areEqual( 2, found.count() );
assert.isTrue( b1.equals( found.getItem( 0 ) ) );
assert.isTrue( b2.equals( found.getItem( 1 ) ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

There are no fail messages for 2 identically reported (if failed) assertions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Remember that we have this customization of assert.areEqual that works with our DOM wrappers too.

assert.areEqual( b2, found.getItem( 1 ), 'Item #1' );

frag.append( em );

found = frag.findOne( 'b' );
assert.isTrue( b1.equals( found ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

While found var makes perfect sense for the previous case, it is not needed here.

It could be just simplified down to

assert.areEqual( b1, frag.findOne( 'b' ) );

Just a single line instead of three.

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.

Looking good 👌

@mlewand mlewand merged commit 53fcf89 into major Dec 28, 2018
@CKEditorBot CKEditorBot deleted the t/2021 branch December 28, 2018 13:18
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