rstacruz/jsdom-global

MutationObserver

Closed this issue · 1 comments

I'm trying to add MutationObserver to a jsdom-created DOM like this, but for some reason the script doesn't seem to load:

require('jsdom-global')(
  '', 
  {
    scripts: [
      'https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/0.7.22/MutationObserver.js',
    ],
  }
)
ReferenceError: MutationObserver is not defined

Able to get this working by tweaking the remote script to take an argument instead of self-executing:

require('jsdom-global')()
require('./polyfills/MutationObserver.js')(global)
require('./polyfills/getSelection.js')(global)