6
6
* MIT Licensed
7
7
*/
8
8
var promiseExists = typeof Promise === 'function' ;
9
- var globalObject = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : self ; // eslint-disable-line
10
- var isDom = 'location' in globalObject && 'document' in globalObject ;
9
+
10
+ /* eslint-disable no-undef */
11
+ var globalObject = typeof self === 'object' ? self : global ; // eslint-disable-line id-blacklist
12
+
13
+ /*
14
+ * All of these attributes must be available on the global object for the current environment
15
+ * to be considered a DOM environment (browser)
16
+ */
17
+ var isDom = typeof window === 'object' &&
18
+ 'document' in window &&
19
+ 'navigator' in window &&
20
+ 'HTMLElement' in window ;
21
+ /* eslint-enable */
22
+
11
23
var symbolExists = typeof Symbol !== 'undefined' ;
12
24
var mapExists = typeof Map !== 'undefined' ;
13
25
var setExists = typeof Set !== 'undefined' ;
@@ -160,7 +172,7 @@ module.exports = function typeDetect(obj) {
160
172
* Test: `Object.prototype.toString.call(document.createElement('blockquote'))``
161
173
* - IE <=10 === "[object HTMLBlockElement]"
162
174
*/
163
- if ( obj instanceof HTMLElement && obj . tagName === 'BLOCKQUOTE' ) {
175
+ if ( obj instanceof globalObject . HTMLElement && obj . tagName === 'BLOCKQUOTE' ) {
164
176
return 'HTMLQuoteElement' ;
165
177
}
166
178
@@ -176,7 +188,7 @@ module.exports = function typeDetect(obj) {
176
188
* - Firefox === "[object HTMLTableCellElement]"
177
189
* - Safari === "[object HTMLTableCellElement]"
178
190
*/
179
- if ( obj instanceof HTMLElement && obj . tagName === 'TD' ) {
191
+ if ( obj instanceof globalObject . HTMLElement && obj . tagName === 'TD' ) {
180
192
return 'HTMLTableDataCellElement' ;
181
193
}
182
194
@@ -192,7 +204,7 @@ module.exports = function typeDetect(obj) {
192
204
* - Firefox === "[object HTMLTableCellElement]"
193
205
* - Safari === "[object HTMLTableCellElement]"
194
206
*/
195
- if ( obj instanceof HTMLElement && obj . tagName === 'TH' ) {
207
+ if ( obj instanceof globalObject . HTMLElement && obj . tagName === 'TH' ) {
196
208
return 'HTMLTableHeaderCellElement' ;
197
209
}
198
210
}
0 commit comments