Opened 10 years ago
Closed 8 years ago
#14603 closed Bug (fixed)
Function "contains " in elementpath don't exclude root element if it is search from top
| Reported by: | Ben Ng | Owned by: | |
|---|---|---|---|
| Priority: | Normal | Milestone: | |
| Component: | General | Version: | 4.0 |
| Keywords: | Cc: |
Description
Steps to reproduce
- Call the contains function of a elementpath with excludeRoot and fromTop are both TRUE
Expected result
The root element should be excluded.
Actual result
The deepest element is excluded. It is because the elements array is reversed when fromTop is true. The root element is moved to the first element of the array instead of the last one. The for loop exclude the last element if excludeRoot is true.
Change History (3)
comment:1 Changed 9 years ago by
| Keywords: | elementpath contains removed |
|---|---|
| Status: | new → confirmed |
| Version: | 4.5.9 (GitHub - master) → 4.0 |
comment:2 Changed 8 years ago by
Faced the same issue, reported in to the GitHub in https://github.com/ckeditor/ckeditor-dev/issues/684 so it can be tracked there.
comment:3 Changed 8 years ago by
| Resolution: | → fixed |
|---|---|
| Status: | confirmed → closed |

Problem can be reproduced at least from CKEditor 4.0.
HTML page:
<div id="test1"> test text </div>JS Code:var editor = CKEDITOR.replace( 'editor1', {}); editor.on( "instanceReady", function( event ) { var rootEl = editor.document.getById('test1'); var elPath = new CKEDITOR.dom.elementPath( rootEl, rootEl.getParent() ); console.log( elPath.contains( 'body', true, true ) ); });Result: According to documentation root elopement should be excluded and
nullshould be logged. Instead body element is found.