question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`onBeforeInput` needs to be monkey patched

See original GitHub issue

Although it is part of the spec the beforeinput event is only available in Chrome at the time of this writing. Neither Firefox nor Safari or IE implement it. But although Chrome has it, it seems to have issues because it can’t be prevented. This breaks the popular slate-react bindings for the slate rich-text-editor component.

We need to normalize the event in compat. There are a few hints on how to do so in the react code base, but they’re somewhat outdated and we need to reassess the current support status in browsers.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
upendradevsinghcommented, Apr 17, 2020

I am not sure if this is the same issue, breaking slate in mobile browser. I am trying to integrate slatejs in my preact application. Everything worked fine on desktop but it broke in the mobile browser (Android - Chrome).

index.es.js:1524 Uncaught (in promise) Error: Cannot resolve a DOM point from Slate point: {"path":[0,0],"offset":7}
    at Object.toDOMPoint (index.es.js:1524)
    at Object.toDOMRange (index.es.js:1538)
    at Object.__ (index.es.js:633)
    at P (hooks.module.js:1)
    at hooks.module.js:1
    at Array.filter (<anonymous>)
    at hooks.module.js:1
    at Array.some (<anonymous>)
    at Object.a.options.__c (hooks.module.js:1)
    at x (preact.module.js:1)

I have created a sample application.

https://github.com/upendradevsingh/slate-demo

1reaction
Rafi993commented, Nov 24, 2019

This can be a browser polyfill independent of preact

Read more comments on GitHub >

github_iconTop Results From Across the Web

Monkey patching: What is it and should you be using it? - DEV ...
A monkey patch is a way to change, extend, or modify a library, plugin, or supporting system software locally. This means applying a...
Read more >
Checking if a JavaScript native function is monkey patched
Delving deep into how to determine whether a JavaScript native function has been monkey patched, and why it's not possible to determine it ......
Read more >
What is monkey patching? - python - Stack Overflow
It's simply the dynamic replacement of attributes at runtime. For instance, consider a class that has a method get_data . This method does...
Read more >
Should I use Monkey Patching in JavaScript? | by David Fekke
Monkey Patching is the capability in JavaScript to swap out a function in a JavaScript object with your own function. This can come...
Read more >
Pragmatic Uses of Monkey Patching in JavaScript - SitePoint
Vildan Softic looks at using monkey patching to alter code at runtime, arguing developers should understand how to safely use this ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found