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

IE11 : Exception when resolving position during readDOMChange #547

Closed
thomasWajs opened this issue Jan 31, 2017 · 6 comments
Closed

IE11 : Exception when resolving position during readDOMChange #547

thomasWajs opened this issue Jan 31, 2017 · 6 comments

Comments

@thomasWajs
Copy link

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 readDOMChange send a NaN post 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.

@marijnh
Copy link
Member

marijnh commented Jan 31, 2017

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

@thomasWajs
Copy link
Author

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.

@marijnh
Copy link
Member

marijnh commented Jan 31, 2017

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.

@marijnh marijnh closed this as completed Jan 31, 2017
@thomasWajs
Copy link
Author

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.

@erkiesken
Copy link

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.

@mitar
Copy link

mitar commented Jan 10, 2018

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

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

4 participants