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.

0.10.2 fails on a test: global.getSelection().anchorNode undefined

See original GitHub issue

A test with these 3 lines with an error. Removing the last line make it to succeed. It uses enzyme.

wrapper.find('.public-DraftEditor-content').simulate('beforeInput', { data: '@' });
wrapper.find('.public-DraftEditor-content').simulate('keydown', { which: KEY_ESC });
wrapper.find('.public-DraftEditor-content').simulate('beforeInput', { data: 't' });

So it seems this line anchorNode is undefined, not null. https://github.com/facebook/draft-js/blob/master/src/component/handlers/edit/editOnBeforeInput.js#L159

TypeError: Cannot read property 'nodeType' of undefined
      
      at editOnBeforeInput (node_modules/draft-js/lib/editOnBeforeInput.js:112:74)
      at node_modules/draft-js/lib/DraftEditor.react.js:146:19
      at Object.invokeGuardedCallback [as invokeGuardedCallbackWithCatch] (node_modules/react-dom/lib/ReactErrorUtils.js:26:5)
      at executeDispatch (node_modules/react-dom/lib/EventPluginUtils.js:83:21)
      at Object.executeDispatchesInOrder (node_modules/react-dom/lib/EventPluginUtils.js:108:5)
      at executeDispatchesAndRelease (node_modules/react-dom/lib/EventPluginHub.js:43:22)
      at executeDispatchesAndReleaseSimulated (node_modules/react-dom/lib/EventPluginHub.js:51:10)
      at forEachAccumulated (node_modules/react-dom/lib/forEachAccumulated.js:26:8)
      at Object.processEventQueue (node_modules/react-dom/lib/EventPluginHub.js:252:7)
      at node_modules/react-dom/lib/ReactTestUtils.js:351:22
      at ReactDefaultBatchingStrategyTransaction.perform (node_modules/react-dom/lib/Transaction.js:143:20)
      at Object.batchedUpdates (node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js:62:26)
      at Object.batchedUpdates (node_modules/react-dom/lib/ReactUpdates.js:97:27)
      at node_modules/react-dom/lib/ReactTestUtils.js:349:18
      at ReactWrapper.<anonymous> (node_modules/enzyme/build/ReactWrapper.js:776:11)
      at ReactWrapper.single (node_modules/enzyme/build/ReactWrapper.js:1421:25)
      at ReactWrapper.simulate (node_modules/enzyme/build/ReactWrapper.js:769:14)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
icd2k3commented, Apr 23, 2018

I’m running into the same error as @eldh periodically. Still hunting for a solid repro case…

1reaction
eldhcommented, Dec 21, 2017

I’m still seeing this (or a very similar error) in v0.10.4, coming from editOnInput. I’ll make a PR cause I don’t know if my fix is nice or not.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enzyme Jest window.getSelection() does not work
You have to stub out window.getSelection().removeAllRanges() . I think this would work: before(() => { window.getSelection = () => { return ...
Read more >
slate-react - UNPKG
'undefined' && /Chrome/i.test(navigator.userAgent)\n\n// Native `beforeInput` events don't work well with react on Chrome 75\n// and older, Chrome 76+ can ...
Read more >
getSelection() Workaround for Safari 1.3, 2.0 and Firefox 1.0.3
Fails with “undefined” in both. There is some good news: getSelection() test 8 javascript:d=window.getSelection(); alert(d.
Read more >
oak - Mercurial
browser/components/aboutlogins/tests/chrome/test_login_item.html ... [[package]] name = "rkv" -version = "0.9.7" +version = "0.10.2" source ...
Read more >
2018학년도 경북대 약대입시 기본계획 발표 : 네이버 블로그
loadFile() failed " + e ); } }, /** * Append message to log file with specified level. ... LINKED); }, /** *...
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