patrick-steele-idem / morphdom

Fast and lightweight DOM diffing/patching (no virtual DOM needed)
MIT License
3.21k stars 129 forks source link

TypeError: 'null' is not an object (evaluating 'morphedNode.nodeType') #38

Closed epinapala closed 5 years ago

epinapala commented 8 years ago

We have a setup where we are running tests on marko widgets, and are seeing the issue below :

PhantomJS 1.9.8 (Mac OS X 0.0.0) TypeError: 'null' is not an object (evaluating 'morphedNode.nodeType') (/path/to/project/.test/lasso/static/node_modules/marko-widgets/node_modules/morphdom/lib/index.js:373)

In addition to this we are also seeing:

ERROR: '(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.', 11

Causing all the tests the fail.

patrick-steele-idem commented 8 years ago

In almost all cases, this is due to the original HTML element associated with a Marko Widget being removed from the DOM without the widget being properly being destroyed (using myWidget.destroy()). When the DOM node associated with a widget is removed then that results in document.getElementById(widgetId) to return null. The error should probably be better messaged by Marko Widgets, but I don't believe this is a morphdom issue. Please investigate how you are managing the DOM to ensure that you are not incorrectly destroying a widget. Let me know if you are still stuck.

snewcomer commented 5 years ago

Closing for now! Feel free to reach out!