Opened 9 years ago

Closed 8 years ago

#12727 closed Bug (fixed)

IndexSizeError on using plugins 'Div Editing Area' and 'Content Templates'

Reported by: Owned by:
Priority: Normal Milestone: CKEditor 4.5.7
Component: General Version: 4.4.6
Keywords: Blink Cc: jacobvanlingen@…, glen.84@…


This error occurs in Chrome (Version 39.0.2171.71) running on Windows 7 x64.

I created a basic CKEditor and added Div Editing Area, Image and Content Templates as plugins.

Reproduce the error:

  1. Open the template dialog and select the first default template ('Image and Title'). The dialog closes an the template gets displayed.
  2. Open the template dialog again and select the second template ('Strange Template'). The dialog stays visible.

The developer console shows the following error:
Uncaught IndexSizeError: Failed to execute 'extend' on 'Selection': 1 is larger than the given node's length. (in ckeditor.js)

Attachments (1)

build-config.js (2.8 KB) - added by 9 years ago.

Download all attachments as: .zip

Change History (19)

Changed 9 years ago by

Attachment: build-config.js added

comment:1 Changed 9 years ago by Jakub Ś

Keywords: Blink added
Status: newconfirmed

Problem can be reproduced from CKEditor 4.4.6 in Blink Browsers. Divarea is also required to reproduce this problem.

comment:2 Changed 9 years ago by Encaitar

Cc: jacobvanlingen@… added

comment:3 Changed 9 years ago by Daniel López

I have the same problem.

I found that this error occurs when the moveNativeSelectionToBookmark() function calls to selection.extend() with the offset longer than node.length.

If I surround the extend call with a "try/catch" block or an "if" block checking the parameters, it avoids this error.

comment:4 Changed 9 years ago by Tobias Hößl

I had several complaints as well, and it seems like the workaround suggested by dlopezp helped.

comment:5 Changed 9 years ago by Will Hitchcock

I'm running into this same problem now with a fresh install of v4.4.7. I'd like to try out dlopezp's suggested fix, but can't find the moveNativeSelectionToBookmark function. Is that in the core ckeditor file or part of one of the plugins mentioned above?

comment:6 Changed 9 years ago by Jakub Ś

It is located in core/selection.js

You need source version for it:!/guide/dev_source, after making the change you need to build CKEditor!/guide/dev_build

comment:7 Changed 9 years ago by Eyal

Any update on this issue? I'm also getting this error. Wouldn't it be wiser to understand why the error happens, instead of swallowing it with a try-catch? Nevertheless, any solution to this issue will be appreciated.

comment:8 Changed 9 years ago by

Any update about it, I still found the same error in our current version. ​ Thanks.

comment:9 Changed 9 years ago by Rike

Wake up! This bug makes Div Editing Area mode unusable! From version 4.4.6 to actual 4.5.3...

comment:10 Changed 9 years ago by Jeroen

I too have this error. It happens whenever I press ok on a custom iframedialog.
So I cant give an example.
The code of the error is below and is being executed after the following events:
click(on Ok button dialog) -> [dialog plugin]ok -> [dialog]saveSnapshot -> [undo plugin]beforeUndoImage followed by afterUndoImage

The error occures in selection.js:224

function moveNativeSelectionToBookmark( document, bm ) {
   var sel = document.getSelection(),
   range = document.createRange();

   range.setStart( bm[ 0 ].node, bm[ 0 ].offset );
   range.collapse( true );
   sel.addRange( range );
   sel.extend( bm[ 1 ].node, bm[ 1 ].offset ); << error

Where bm[1].node is a TextNode with text =""
and bm[1].offset is 1

I don't know why the extend throws an exception, can't find it's workings.

It is possible this bug is related to #10031 because it happens on chrome when the current selection is character &#8203(ZERO WIDTH SPACE U+200B)

comment:11 Changed 9 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.5.4

We've got #13513 and #13284 assigned to 4.5.4 already. Both are on review and both have a chance to fix this issue as well. But let's keep track of this ticket as well (I'm assigning it to 4.5.4).

comment:12 Changed 9 years ago by Piotrek Koszuliński

PS. Please note that this is very complicated issue caused by even more complicated hack for Webkit and Blink bugs. We may not be able to succeed in closing every type of this issue in one release.

comment:13 Changed 8 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.5.4CKEditor 4.5.5

Just like in – we need a bit more time, but it's finally looking promising.

comment:14 Changed 8 years ago by darkangel

Cc: glen.84@… added

comment:15 Changed 8 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.5CKEditor 4.5.6

This issue will be fixed by #13816 in the next milestone.

comment:16 Changed 8 years ago by ferahl

Thanks for working on this. I get it when clicking a "Add Post" button, after adding the post I want to clear the content but this error stops setData("") from working for roughly 120ms

Submitting with the keyboard doesn't cause the error so it must be an issue with blur

Anyone have any ideas how to fix this before 4.5.6?


  • It only happens if I start typing something, then press CMD+b/i and carry on typing and the click then button
  • The error doesn't happen if I focus on something else before doing setData("")
  • Edit: Pretty obvious but for now I'm just emptying the element myself, I wasn't sure if getData() would still work but it does.
Last edited 8 years ago by ferahl (previous) (diff)

comment:17 Changed 8 years ago by Marek Lewandowski

Milestone: CKEditor 4.5.6CKEditor 4.5.7

comment:18 Changed 8 years ago by Marek Lewandowski

Resolution: fixed
Status: confirmedclosed

Fixed with git:2d078ff42a by #13816.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy