fix jsdom polyfill

This commit is contained in:
Estevao Soares dos Santos 2017-12-23 14:00:20 +00:00
parent 17222b3d5a
commit 410b453049
7 changed files with 6 additions and 10 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

View File

@ -359,7 +359,7 @@ showdown.Converter = function (converterOptions) {
// ex: <em>this is</em> <strong>sparta</strong> // ex: <em>this is</em> <strong>sparta</strong>
src = src.replace(/>[ \t]+</, '>¨NBSP;<'); src = src.replace(/>[ \t]+</, '>¨NBSP;<');
var doc = document.createElement('div'); var doc = showdown.helper.document.createElement('div');
doc.innerHTML = src; doc.innerHTML = src;
var preList = substitutePreCodeTags(doc); var preList = substitutePreCodeTags(doc);

View File

@ -6,6 +6,11 @@ if (!showdown.hasOwnProperty('helper')) {
showdown.helper = {}; showdown.helper = {};
} }
if (typeof this.document === 'undefined' && typeof this.window === 'undefined') {
this.window = require('jsdom').jsdom('', {}).defaultView; // jshint ignore:line
}
showdown.helper.document = this.window.document;
/** /**
* Check if var is string * Check if var is string
* @static * @static

View File

@ -1,15 +1,6 @@
/** /**
* Created by Tivie on 06-01-2015. * Created by Tivie on 06-01-2015.
*/ */
// load dependencies
if (typeof document === 'undefined' && typeof window === 'undefined') {
var jsdom = require('jsdom').jsdom,
jsdomObj = jsdom('', {}),
window = jsdomObj.defaultView, // jshint ignore:line
document = window.document; // jshint ignore:line
}
// Private properties // Private properties
var showdown = {}, var showdown = {},
parsers = {}, parsers = {},