Prosemirror: IE11 : Exception when resolving position during readDOMChange

Created on 31 Jan 2017  路  6Comments  路  Source: ProseMirror/prosemirror

Following your recent fixes on prosemirror-view regarding IE11, we grabbed this latest version and made a few tests this morning.

It seems that the fixes on the _Node.contains_ method and keydown handling have uncovered another issue with IE11.

At each keystroke, there's an unhandled exception thrown at prosemirror-model/resolvedpos.js

if (!(pos >= 0 && pos <= doc.content.size)) { throw new RangeError("Position " + pos + " out of range") }

The debugger indicate that doc.content.size is NaN. This happen whatever the keystroke.
We weren't able to find out why the document size is incorrectly set.

We tried to comment this check to obtain more informations, but we only end up with another exception because readDOMChangesend a NaNpost when doing
var $to = parsed.resolveNoCache(change.endB - range.from)

( change.endB is NaN )

Hope that'll help narrow down the source of the issues.

Most helpful comment

Commenting on an old issue but we just ran into the same problem and it took too long to find this issue and the double-included bundled module hint above.

So for us it manifested as text edits throwing RangeError: Position 0 out of range errors.

In our case the root issue was badly done package.json dependency version update, that messed up yarn.lock file. Top level project package.json declared it wanted 1.0.1 of pm modules, but some of the modules had older 1.0.0 ones in their own node_modules dirs. Result was this:

$ ls -1 node_modules/prosemirror-*/node_modules/
node_modules/prosemirror-commands/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-history/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-inputrules/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-keymap/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-markdown/node_modules/:
linkify-it
markdown-it
prosemirror-model

node_modules/prosemirror-schema-basic/node_modules/:
prosemirror-model

node_modules/prosemirror-schema-list/node_modules/:
prosemirror-model

node_modules/prosemirror-state/node_modules/:
prosemirror-model

node_modules/prosemirror-transform/node_modules/:
prosemirror-model

node_modules/prosemirror-view/node_modules/:
prosemirror-model
prosemirror-state

And thus at runtime, pm-markdown used one instance of pm-model, pm-view another copy and the Fragment class instanceof checks etc didn't work properly any more.

Fix was to rm -rf node_modules && rm yarn.lock && yarn and validate with ls -1 node_modules/prosemirror-*/node_modules/ returning no dupes.

All 6 comments

I'm not seeing this in my demos. Could you submit a minimal script that sets up an editor which shows the issue?

Here is the script, built from the example setup in the doc :
prosemirror-bug-547.zip

The build is made with the latest available versions in npm, except prosemirror-view which come from the github master branch.

Your bundler is somehow creating a bundle that initializes modules multiple times, which results in multiple instances of the Fragment constructor being used, which results in instanceof not working properly, which breaks Fragment.from. This isn't an issue with ProseMirror, as far as I can see, since a CommonJS bundler should be following CommonJS rules (each module is initialized once).

You can add a console.log to the toplevel, for example near var Fragment = function(content, size), to see that this is happening.

Ok I'm gonna look into this, thanks for the reply. Wouldn't have guessed that this could be a bundling issue.

Sorry for the waste of time.

Commenting on an old issue but we just ran into the same problem and it took too long to find this issue and the double-included bundled module hint above.

So for us it manifested as text edits throwing RangeError: Position 0 out of range errors.

In our case the root issue was badly done package.json dependency version update, that messed up yarn.lock file. Top level project package.json declared it wanted 1.0.1 of pm modules, but some of the modules had older 1.0.0 ones in their own node_modules dirs. Result was this:

$ ls -1 node_modules/prosemirror-*/node_modules/
node_modules/prosemirror-commands/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-history/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-inputrules/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-keymap/node_modules/:
prosemirror-model
prosemirror-state

node_modules/prosemirror-markdown/node_modules/:
linkify-it
markdown-it
prosemirror-model

node_modules/prosemirror-schema-basic/node_modules/:
prosemirror-model

node_modules/prosemirror-schema-list/node_modules/:
prosemirror-model

node_modules/prosemirror-state/node_modules/:
prosemirror-model

node_modules/prosemirror-transform/node_modules/:
prosemirror-model

node_modules/prosemirror-view/node_modules/:
prosemirror-model
prosemirror-state

And thus at runtime, pm-markdown used one instance of pm-model, pm-view another copy and the Fragment class instanceof checks etc didn't work properly any more.

Fix was to rm -rf node_modules && rm yarn.lock && yarn and validate with ls -1 node_modules/prosemirror-*/node_modules/ returning no dupes.

@erkiesken, thank you for this report! I was debugging this for an hour now. So mysterious.

Was this page helpful?
0 / 5 - 0 ratings