-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Conversation
There was a problem hiding this 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. |
There was a problem hiding this comment.
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
tests/core/dom/documentfragment.js
Outdated
found = frag.find( 'b' ); | ||
assert.areEqual( 2, found.count() ); | ||
assert.isTrue( b1.equals( found.getItem( 0 ) ) ); | ||
assert.isTrue( b2.equals( found.getItem( 1 ) ) ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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' );
tests/core/dom/documentfragment.js
Outdated
frag.append( em ); | ||
|
||
found = frag.findOne( 'b' ); | ||
assert.isTrue( b1.equals( found ) ); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good 👌
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
What changes did you make?
I've added
find
andfindOne
methods to theCKEDITOR.dom.documentFragment
.Closes #2021.