Skip to content

Commit 5bef454

Browse files
committed
Don’t use typeof to test for undefined values
‘typeof foo == "undefined"’ is identical to ‘foo === void 0’ yet the latter is shorter so prefer it over the former.
1 parent a3c7567 commit 5bef454

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/html5shiv-printshiv.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2+
* @preserve HTML5 Shiv 3.7.4-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
33
*/
44
;(function(window, document) {
55
/*jshint evil:true */
66
/** version */
7-
var version = '3.7.3';
7+
var version = '3.7.4-pre';
88

99
/** Preset options */
1010
var options = window.html5 || {};
@@ -42,9 +42,9 @@
4242
(document.createElement)('a');
4343
var frag = document.createDocumentFragment();
4444
return (
45-
typeof frag.cloneNode == 'undefined' ||
46-
typeof frag.createDocumentFragment == 'undefined' ||
47-
typeof frag.createElement == 'undefined'
45+
frag.cloneNode === void 0 ||
46+
frag.createDocumentFragment === void 0 ||
47+
frag.createElement === void 0
4848
);
4949
}());
5050
} catch(e) {
@@ -332,11 +332,11 @@
332332
// assign a false negative if unable to shiv
333333
var docEl = document.documentElement;
334334
return !(
335-
typeof document.namespaces == 'undefined' ||
336-
typeof document.parentWindow == 'undefined' ||
337-
typeof docEl.applyElement == 'undefined' ||
338-
typeof docEl.removeNode == 'undefined' ||
339-
typeof window.attachEvent == 'undefined'
335+
document.namespaces === void 0 ||
336+
document.parentWindow === void 0 ||
337+
docEl.applyElement === void 0 ||
338+
docEl.removeNode === void 0 ||
339+
window.attachEvent === void 0
340340
);
341341
}());
342342

@@ -439,7 +439,7 @@
439439
if (!supportsShivableSheets || ownerDocument.printShived) {
440440
return ownerDocument;
441441
}
442-
if (typeof namespaces[shivNamespace] == 'undefined') {
442+
if (namespaces[shivNamespace] === void 0) {
443443
namespaces.add(shivNamespace);
444444
}
445445

@@ -521,4 +521,4 @@
521521
module.exports = html5;
522522
}
523523

524-
}(typeof window !== "undefined" ? window : this, document));
524+
}(window === void 0 ? this : window, document));

src/html5shiv.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
2+
* @preserve HTML5 Shiv 3.7.4-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
33
*/
44
;(function(window, document) {
55
/*jshint evil:true */
66
/** version */
7-
var version = '3.7.3';
7+
var version = '3.7.4-pre';
88

99
/** Preset options */
1010
var options = window.html5 || {};
@@ -42,9 +42,9 @@
4242
(document.createElement)('a');
4343
var frag = document.createDocumentFragment();
4444
return (
45-
typeof frag.cloneNode == 'undefined' ||
46-
typeof frag.createDocumentFragment == 'undefined' ||
47-
typeof frag.createElement == 'undefined'
45+
frag.cloneNode === void 0 ||
46+
frag.createDocumentFragment === void 0 ||
47+
frag.createElement === void 0
4848
);
4949
}());
5050
} catch(e) {
@@ -323,4 +323,4 @@
323323
module.exports = html5;
324324
}
325325

326-
}(typeof window !== "undefined" ? window : this, document));
326+
}(window === void 0 ? this : window, document));

0 commit comments

Comments
 (0)