Draft-js: ReferenceError: Node is not defined

Created on 7 Jul 2016  Â·  6Comments  Â·  Source: facebook/draft-js

Haven't changed anything in my code but reinstalling my dependencies and I now get this error.

Do you have an idea what could cause this?

When I force installing the exact version of all my dependencies, the issue is gone. Will try to figure out which one is causing the issue.

ReferenceError: Node is not defined
      at DraftEditorLeaf._setSelection (node_modules/draft-js/lib/DraftEditorLeaf.react.js:87:30)
      at DraftEditorLeaf.componentDidUpdate (node_modules/draft-js/lib/DraftEditorLeaf.react.js:105:12)
      at invokeComponentDidUpdateWithTimer (node_modules/react/lib/ReactCompositeComponent.js:74:18)
      at CallbackQueue._assign.notifyAll (node_modules/react/lib/CallbackQueue.js:66:22)
      at ReactReconcileTransaction.ON_DOM_READY_QUEUEING.close (node_modules/react/lib/ReactReconcileTransaction.js:79:26)
      at ReactReconcileTransaction.Mixin.closeAll (node_modules/react/lib/Transaction.js:202:25)
      at ReactReconcileTransaction.Mixin.perform (node_modules/react/lib/Transaction.js:149:16)
      at ReactUpdatesFlushTransaction.Mixin.perform (node_modules/react/lib/Transaction.js:136:20)
      at ReactUpdatesFlushTransaction._assign.perform (node_modules/react/lib/ReactUpdates.js:90:38)
      at Object.flushBatchedUpdates (node_modules/react/lib/ReactUpdates.js:177:19)
      at ReactDefaultBatchingStrategyTransaction.Mixin.closeAll (node_modules/react/lib/Transaction.js:202:25)
      at ReactDefaultBatchingStrategyTransaction.Mixin.perform (node_modules/react/lib/Transaction.js:149:16)
      at Object.ReactDefaultBatchingStrategy.batchedUpdates (node_modules/react/lib/ReactDefaultBatchingStrategy.js:63:19)
      at Object.batchedUpdates (node_modules/react/lib/ReactUpdates.js:98:20)
      at Object.ReactMount._renderNewRootComponent (node_modules/react/lib/ReactMount.js:286:18)
      at Object.ReactMount._renderSubtreeIntoContainer (node_modules/react/lib/ReactMount.js:365:32)
      at Object.ReactMount.render (node_modules/react/lib/ReactMount.js:386:23)
      at Object.ReactTestUtils.renderIntoDocument (node_modules/react/lib/ReactTestUtils.js:82:21)
      at renderWithOptions (node_modules/enzyme/build/react-compat.js:175:26)
      at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:94:59)
      at mount (node_modules/enzyme/build/mount.js:21:10)
      at Context.<anonymous> (message-editor.spec.js:39:25)

Most helpful comment

As far as I can tell it is caused by the absence of the definition of global Node.

This will solve the reported Error:

// http://www.w3schools.com/jsref/prop_node_nodetype.asp
global.Node = {
    TEXT_NODE: 3
};

All 6 comments

So the issue comes from jsdom >= 9.4.0 :/

Any updates (or workarounds) for this issue?

As far as I can tell it is caused by the absence of the definition of global Node.

This will solve the reported Error:

// http://www.w3schools.com/jsref/prop_node_nodetype.asp
global.Node = {
    TEXT_NODE: 3
};

@tleunen i know we've sorta dropped the ball on responsiveness in the past, my apologies for that - is this still an issue? if not, could you close?

actually it is still an issue here:

package.json

"draft-js": "^0.11.4",

Error

     ReferenceError: Node is not defined
      at isElement (node_modules/draft-js/lib/isElement.js:18:28)
      at DraftEditorTextNode.shouldComponentUpdate (node_modules/draft-js/lib/DraftEditorTextNode.react.js:105:6)
      at checkShouldComponentUpdate (node_modules/react-dom/cjs/react-dom.development.js:11346:33)
      at updateClassInstance (node_modules/react-dom/cjs/react-dom.development.js:11755:62)
      at updateClassComponent (node_modules/react-dom/cjs/react-dom.development.js:13154:20)
      at beginWork (node_modules/react-dom/cjs/react-dom.development.js:13825:14)
      at performUnitOfWork (node_modules/react-dom/cjs/react-dom.development.js:15864:12)
      at workLoop (node_modules/react-dom/cjs/react-dom.development.js:15903:24)
      at renderRoot (node_modules/react-dom/cjs/react-dom.development.js:15943:7)
      at performWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:16561:22)
      at performWork (node_modules/react-dom/cjs/react-dom.development.js:16483:7)
      at performSyncWork (node_modules/react-dom/cjs/react-dom.development.js:16455:3)
      at requestWork (node_modules/react-dom/cjs/react-dom.development.js:16355:5)
      at scheduleWork$1 (node_modules/react-dom/cjs/react-dom.development.js:16219:11)
      at scheduleRootUpdate (node_modules/react-dom/cjs/react-dom.development.js:16786:3)
      at updateContainerAtExpirationTime (node_modules/react-dom/cjs/react-dom.development.js:16813:10)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:16840:10)
      at ReactRoot.render (node_modules/react-dom/cjs/react-dom.development.js:17123:3)
      at /Users/lucien/CloudStation/WebWork/qare/front/node_modules/react-dom/cjs/react-dom.development.js:17263:14
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:16680:10)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:17259:5)
      at Object.render (node_modules/react-dom/cjs/react-dom.development.js:17318:12)
      at render (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:429:26)
      at fn (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:343:12)
      at Object.wrapAct [as render] (node_modules/enzyme-adapter-react-16/src/ReactSixteenAdapter.js:415:16)
      at new render (node_modules/enzyme/src/ReactWrapper.js:115:16)
      at mount (node_modules/enzyme/src/mount.js:10:10)
      at global.mountWithIntl (__tests__/unit/setup.js:88:3)
      at Context.<anonymous> (.tmp/mocha-webpack/1587561213019/main.js:1:30002)

If someone could post how they solved, it'd be great for future reference. Throwing this in there— try using yarn instead of npm.

Was this page helpful?
0 / 5 - 0 ratings