Browse Source

fix jsdom polyfill

Estevao Soares dos Santos 7 năm trước cách đây
mục cha
commit
410b453049
7 tập tin đã thay đổi với 12 bổ sung20 xóa
  1. 6 10
      dist/showdown.js
  2. 0 0
      dist/showdown.js.map
  3. 0 0
      dist/showdown.min.js
  4. 0 0
      dist/showdown.min.js.map
  5. 1 1
      src/converter.js
  6. 5 0
      src/helpers.js
  7. 0 9
      src/showdown.js

+ 6 - 10
dist/showdown.js

@@ -196,15 +196,6 @@ function allOptionsOn () {
 /**
  * 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
 var showdown = {},
     parsers = {},
@@ -590,6 +581,11 @@ if (!showdown.hasOwnProperty('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
  * @static
@@ -4394,7 +4390,7 @@ showdown.Converter = function (converterOptions) {
     // ex: <em>this is</em> <strong>sparta</strong>
     src = src.replace(/>[ \t]+</, '>¨NBSP;<');
 
-    var doc = document.createElement('div');
+    var doc = showdown.helper.document.createElement('div');
     doc.innerHTML = src;
 
     var preList = substitutePreCodeTags(doc);

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/showdown.js.map


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/showdown.min.js


Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/showdown.min.js.map


+ 1 - 1
src/converter.js

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

+ 5 - 0
src/helpers.js

@@ -6,6 +6,11 @@ if (!showdown.hasOwnProperty('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
  * @static

+ 0 - 9
src/showdown.js

@@ -1,15 +1,6 @@
 /**
  * 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
 var showdown = {},
     parsers = {},

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác