diff --git a/src/helpers.js b/src/helpers.js index 34b2750..9dce4e3 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -6,11 +6,15 @@ if (!showdown.hasOwnProperty('helper')) { showdown.helper = {}; } -if (typeof this.document === 'undefined' && typeof this.window === 'undefined') { - var jsdom = require('jsdom'); - this.window = new jsdom.JSDOM('', {}).window; // jshint ignore:line +if (typeof this === 'undefined' && typeof window !== 'undefined') { + showdown.helper.document = window.document; +} else { + if (typeof this.document === 'undefined' && typeof this.window === 'undefined') { + var jsdom = require('jsdom'); + this.window = new jsdom.JSDOM('', {}).window; // jshint ignore:line + } + showdown.helper.document = this.window.document; } -showdown.helper.document = this.window.document; /** * Check if var is string