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

Uncaught IndexSizeError: Failed to execute 'setStart' on 'Range': #82

Open
matheusbras opened this issue Sep 6, 2014 · 15 comments
Open

Comments

@matheusbras
Copy link

I'm getting this error after typing a few letters. Any ideia what could it be? I'm using Chrome 37.0.2062.94. Thanks!

Uncaught IndexSizeError: Failed to execute 'setStart' on 'Range': There is no child at offset 2.
@robertleeplummerjr
Copy link
Collaborator

Can you tell me which options, mode, and behavior you are using?
On Sep 5, 2014 10:26 PM, "Matheus Bras Quaresma" [email protected]
wrote:

I'm getting this error after typing a few letters. Any ideia what could it
be? I'm using Chrome 37.0.2062.94. Thanks!

Uncaught IndexSizeError: Failed to execute 'setStart' on 'Range': There is no child at offset 2.


Reply to this email directly or view it on GitHub
#82.

@matheusbras
Copy link
Author

@robertleeplummerjr I'm using with the default options, just passing the element.

@robertleeplummerjr
Copy link
Collaborator

So then you are using the demo's? If so, which example?

On Fri, Sep 19, 2014 at 7:48 PM, Matheus Bras Quaresma <
[email protected]> wrote:

@robertleeplummerjr https://github.com/robertleeplummerjr I'm using
with the default options, just passing the element.


Reply to this email directly or view it on GitHub
#82 (comment).

Robert Plummer

@tomatau
Copy link

tomatau commented Jan 21, 2015

I'm having the same problem.

Building inside a React component and enabling in either componentDidMount or componentDidUpdate.

The options I'm using are:

new Medium({
        element: this.getDOMNode().querySelector('.preview-content'),
        mode: Medium.richMode,
        autoHR: false,
        cssClasses: {
          editor: 'edit-mode',
        }
      })

All works fine until you delete the node's innerText and start typing again, at which point the caret jumps around and ends up at the start of the node.

Uncaught IndexSizeError: Failed to execute 'setStart' on 'Range': 
There is no child at offset 2.medium.js:1404 Medium.Cursor.setmedium.js:1305 
Medium.Utilities.setupContentsmedium.js:1601 
Medium.HtmlAssistant.placeholdersmedium.js:240 intercept.up

Currently on Chrome:39

@tomatau
Copy link

tomatau commented Jan 21, 2015

Same error in partialMode.. inlineMode works fine.. the bug only happens after typing a few characters fairly quickly

edit: no it happens when creating slowly.. seems that when the first

is added the range gets messed up.

Bug also happens in Rich mode demo.

@tomatau
Copy link

tomatau commented Jan 21, 2015

This makes it work

tags: {
  paragraph: null
}

but now inserting unnecessary <div> tags where a <br> would be more suitable for the text content. Also seems hacky, if more complex behaviour would be introduced for e.g. highlighting the first word.

@robertleeplummerjr
Copy link
Collaborator

What are the exact steps to reproduce?

@tomatau
Copy link

tomatau commented Jan 24, 2015

Click on the editor for the rich editor in your demo, press delete twice (you'll see the caret position change slightly despite their being no text), then type three characters very quickly.

From then on - the error happens seemingly randomly in your demo but more consistently in other implementations. The first page load can produce the error consistently.

@robertleeplummerjr
Copy link
Collaborator

Try latest from master.

On Sat, Jan 24, 2015 at 1:43 PM, Thomas [email protected] wrote:

Click on the editor for the rich editor in your demo, press delete twice
(you'll see the caret position change slightly despite their being no
text), then type three characters very quickly.

From then on - the error happens seemingly randomly in your demo but more
consistently in other implementations. The first page load can produce the
error consistently.


Reply to this email directly or view it on GitHub
#82 (comment).

Robert Plummer

@tomatau
Copy link

tomatau commented Feb 2, 2015

Mmm did you bump the version at all after making this change? I'm noticing no difference for my implementation.

edit: your demo page still performs exactly the same too

@tomatau
Copy link

tomatau commented Feb 4, 2015

Here's a video demonstrating the behaviour - you can see the code used to implement and the current version tracked by npm.

MediumJSErrorDemo.sm.mov | uploaded via ZenHub

@vkovalskiy
Copy link

Any fixes on that? Having the same issue here..

@janwirth
Copy link

janwirth commented May 4, 2016

Same for me, I get this when trying to set a value or typing in anything but inlineMode.

@janwirth
Copy link

janwirth commented May 23, 2016

I was encountering this issue when trying to wrap it in a medium directive and using any mode other than inline.

@vkovalskiy @levity
I found a different, probably more hacky workaround:
https://github.com/FranzSkuffka/innovant/blob/firebase-wip/assets/libs/medium.js#L1404

just wrap the call in a try / catch construct and things will work as expected.

@ivanov
Copy link

ivanov commented Dec 8, 2016

For what it's worth, I also just ran into a very similar issue (mine was an Uncaught DOMexception Failed to execute 'setEnd' on 'Range': The offset 1 is larger than or equal to the node's length (0)).

The problem for me was caused by a Chrome extensions that was going in and modifying the DOM elements on the page under codemirror's nose (in my case it was this text url to clickable url extension - which would break codemirror if I had a URL in the editor contents).

Disabling that extension resolved the issue for me.

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

No branches or pull requests

7 participants
@ivanov @vkovalskiy @matheusbras @robertleeplummerjr @tomatau @janwirth and others