-
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
Changing list type wont throw error for empty list elements #2440
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.
Checks in your patch are bit too loose, you can still get the error which is a subject of this issue by following a manual test but putting following markup as input:
<ul>
<li>
<div>test<ul>
<!-- I'm a sneaky little comment -->
</ul>
</div>
</li>
<li>test</li>
</ul>
Good job with covering existing functionality (that has not been covered with unit tests yet).
@@ -0,0 +1,30 @@ | |||
<h2>Markup 1:</h2> | |||
<input type="text" value="<ul><li><div>test<ul></ul></div></li><li>test</li></ul>"> |
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.
it would be helpful to mark these inputs as readonly.
|
||
## Expected: | ||
There is no error in console. | ||
However content might look strange and this is not a bug, situation is reportd as list plugin improvement. |
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.
reportd
-> reported
Actually it would be nice to link mentioned issue.
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.
might look strange and this is not a bug
This actually is a buggy content, but it is to be fixed in mentioned issue 😕
</ul> | ||
|
||
<ul> | ||
<li><a href="https://powerusers.microsoft.com/plugins/common/feature/oauth2sso/sso_login_redirect?referer=https%3A%2F%2Fpowerusers.microsoft.com%2Ft5%2FPowerApps-Community%2Fct-p%2FPowerApps1">Register</a></li> |
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.
Please, use dummy links.
plugins/list/plugin.js
Outdated
function isEmptyList( groupObj ) { | ||
// If list is without any li item, then ignore such element from transformation, becasue it throws errors in console. | ||
// Hack for situation described in #2411, #2438. | ||
return groupObj.root.is( 'ul', 'ol' ) && groupObj.root.getChildCount() === 0; |
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.
Reuse listNodeNames
to identify list tag names.
Actually in my opinion we should use DTD here (CKEDITOR.dtd.$list
) but for some reason it was skipped. Maybe because it should handle only lists, and not description list.
|
||
var tests = { | ||
'test conversion of embedded unordered list and paragraphs to numbered list': function( editor, bot ) { // Strange test result for: 0, 8 | ||
var testesLength = 9; |
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.
Subsequent var
declarations/initialization should be contained within a single var
statement.
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.
This issue appears later on, please correct each occurence.
@@ -0,0 +1,468 @@ | |||
<!-- | |||
|
|||
Strange output markup for tests: |
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.
Avoid information duplication. You have already provided this info in blockconversion.js
.
blockconversion.js
is where the logic of tests are so it is the best place to put this information. Here it's not needed, as it is only a resource file for the logic.
}; | ||
|
||
var tests = { | ||
'test conversion of embedded unordered list and paragraphs to numbered list': function( editor, bot ) { // Strange test result for: 0, 8 |
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.
Strange test result for: 0, 8
comment will look much better in a line below. Here it exceeds 120 chars which, if convenient, we like to avoid.
84284d2
to
59d2ff2
Compare
I have rebased the branch (resolved conflict in |
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.
childCountWithoutComments
method is a blocker for this fix
core/tools.js
Outdated
* @param {CKEDITOR.dom.element} node Element whos children will be counted. | ||
* @returns {Number} Amount of node's children without counting comments. | ||
*/ | ||
childCountWithoutComments: function( node ) { |
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.
We can't add a method like that, it doesn't belong here.
- Logically it belongs to
CKEDITOR.dom.element
type - this is where it should be added. - It's too specific to your particular use case. Having a method like that would be excuse for getChildCountWithoutNodes, getChildCountWithoutElements etc. Instead
getChildCount
method should be modified to acceptoptions
param, that allows to specifyoptions.exclude
oroptions.include
. So you'd call it likeelem.getChildCount( { exclude: [ CKEDITOR.NODE_COMMENT ] } );
. - Name is not aligned with existing
getChildCount
method.
Finally there's a minor naming issue, node
can not have children so the arg should be called element
just like you described in @param
's description.
I should have pointed this out in previous review.
I have fixed the issue that I raised during the review by simply inlining the function. Ideally I'd like CKEDITOR.dom.element methods to get |
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
What changes did you make?
ul
list was changed to different list type.Close #2411
Related also to #2438