Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jsdom hashchange event

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

like image 310
abernier Avatar asked Nov 05 '22 02:11

abernier


1 Answers

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();
like image 164
crazy_prog Avatar answered Nov 11 '22 05:11

crazy_prog