mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
fix(helpers): allow usage in ES6 modules fix for #676
* Fix for issue #676 This will check for situations when this is undefined, eg ES6 module wrapper Co-authored-by: SyntaxRules <devyn.stott@gmail.com>
This commit is contained in:
parent
41cee10659
commit
ed51972315
|
@ -6,11 +6,15 @@ if (!showdown.hasOwnProperty('helper')) {
|
||||||
showdown.helper = {};
|
showdown.helper = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof this.document === 'undefined' && typeof this.window === 'undefined') {
|
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');
|
var jsdom = require('jsdom');
|
||||||
this.window = new jsdom.JSDOM('', {}).window; // jshint ignore:line
|
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
|
* Check if var is string
|
||||||
|
|
Loading…
Reference in New Issue
Block a user