5

On a jsdom document:

document = require('jsdom').jsdom("<html><head></head><body></body></html>");
window   = document.createWindow();

Changing its hash:

document.location.href = '#bang';

doesn't trigger any 'hashchange' event on window

Does anyone aware of a workaround for this?

Thank you

Ja͢ck
  • 170,779
  • 38
  • 263
  • 309
abernier
  • 27,030
  • 20
  • 83
  • 114
  • I could be wrong about this, but normally you'd use `window.location.href = '#bang'` instead of `document`. Don't know enough about node.js though. – Ja͢ck May 15 '12 at 16:16

1 Answers1

2

Check out the jsdom docs

Try this before the rest of your code:

require('jsdom').defaultDocumentFeatures = {
  FetchExternalResources   : ['script'], 
  ProcessExternalResources : ['script'],
  MutationEvents           : '2.0',
  QuerySelector            : false
}

var window = jsdom.jsdom(body).createWindow();
crazy_prog
  • 1,085
  • 5
  • 19
  • 34
  • Nice to remember the ability to set this bunch of options! However, I don't get how any of them affect the `hashchange` event... Am I missing something? – abernier May 16 '12 at 08:16