File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,15 @@ var parseFromString = function () {
20
20
) ;
21
21
} ;
22
22
23
+ var DOMParser = typeof window === 'object' && window . DOMParser ;
24
+
23
25
/**
24
26
* DOMParser (performance: slow).
25
27
*
26
28
* @see https://developer.mozilla.org/docs/Web/API/DOMParser#Parsing_an_SVG_or_HTML_document
27
29
*/
28
- if ( typeof window . DOMParser === 'function' ) {
29
- var domParser = new window . DOMParser ( ) ;
30
+ if ( typeof DOMParser === 'function' ) {
31
+ var domParser = new DOMParser ( ) ;
30
32
var mimeType = 'text/html' ;
31
33
32
34
/**
@@ -52,7 +54,7 @@ if (typeof window.DOMParser === 'function') {
52
54
*
53
55
* @see https://developer.mozilla.org/docs/Web/API/DOMImplementation/createHTMLDocument
54
56
*/
55
- if ( document . implementation ) {
57
+ if ( typeof document === 'object' && document . implementation ) {
56
58
var doc = document . implementation . createHTMLDocument ( ) ;
57
59
58
60
/**
@@ -79,7 +81,9 @@ if (document.implementation) {
79
81
*
80
82
* @see https://developer.mozilla.org/docs/Web/HTML/Element/template
81
83
*/
82
- var template = document . createElement ( 'template' ) ;
84
+ var template =
85
+ typeof document === 'object' ? document . createElement ( 'template' ) : { } ;
86
+
83
87
var parseFromTemplate ;
84
88
85
89
if ( template . content ) {
Original file line number Diff line number Diff line change 1
1
import assert from 'assert' ;
2
2
import HTMLDOMParser from '../../index.mjs' ;
3
+ import HTMLDOMParserClient from '../../lib/client/html-to-dom.mjs' ;
3
4
4
5
assert . strictEqual ( typeof HTMLDOMParser , 'function' ) ;
6
+ assert . strictEqual ( typeof HTMLDOMParserClient , 'function' ) ;
You can’t perform that action at this time.
0 commit comments