SlexAxton / require-handlebars-plugin

A plugin for handlebars in require.js (both in dev and build)
804 stars 202 forks source link

jsdom environment unsupported #254

Closed agoldis closed 6 years ago

agoldis commented 7 years ago

Loading a web app that uses require-handlebars-plugin via jsdom confuses the initialization flow. The re-definition of fetchText function doesn't happen because jsdom doesn't fulfill any of the conditions below:

if (typeof window !== 'undefined' &&
window.navigator &&
window.document &&
!window.navigator.userAgent.match(/Node.js/)) {
...
} else if (
    typeof process !== 'undefined' &&
    process.versions &&
    !!process.versions.node
  ) {

...
} else if (typeof java !== 'undefined' && typeof java.io !== 'undefined') {
... 
}

Ended up by removing !window.navigator.userAgent.match(/Node.js/ to mimic browser-like behaviour in jsdom