Skip to content

Commit 8e1f614

Browse files
committed
Don’t comparo to undefined directly, just check whether value is falsy
Strictly speaking, ‘!foo’ is superset of ‘foo === void 0’, but in all of the cases it actually doesn’t matter and simple negation produces shorter code.
1 parent 5bef454 commit 8e1f614

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/html5shiv-printshiv.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
// assign a false positive if unable to shiv
4242
(document.createElement)('a');
4343
var frag = document.createDocumentFragment();
44-
return (
45-
frag.cloneNode === void 0 ||
46-
frag.createDocumentFragment === void 0 ||
47-
frag.createElement === void 0
48-
);
44+
return !(frag.cloneNode &&
45+
frag.createDocumentFragment &&
46+
frag.createElement);
4947
}());
5048
} catch(e) {
5149
// assign a false positive if detection fails => unable to shiv
@@ -331,13 +329,11 @@
331329
var supportsShivableSheets = !supportsUnknownElements && (function() {
332330
// assign a false negative if unable to shiv
333331
var docEl = document.documentElement;
334-
return !(
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
340-
);
332+
return !!(document.namespaces &&
333+
document.parentWindow &&
334+
docEl.applyElement &&
335+
docEl.removeNode &&
336+
window.attachEvent);
341337
}());
342338

343339
/*--------------------------------------------------------------------------*/
@@ -439,7 +435,7 @@
439435
if (!supportsShivableSheets || ownerDocument.printShived) {
440436
return ownerDocument;
441437
}
442-
if (namespaces[shivNamespace] === void 0) {
438+
if (!namespaces[shivNamespace]) {
443439
namespaces.add(shivNamespace);
444440
}
445441

@@ -521,4 +517,4 @@
521517
module.exports = html5;
522518
}
523519

524-
}(window === void 0 ? this : window, document));
520+
}(window || this, document));

src/html5shiv.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@
4141
// assign a false positive if unable to shiv
4242
(document.createElement)('a');
4343
var frag = document.createDocumentFragment();
44-
return (
45-
frag.cloneNode === void 0 ||
46-
frag.createDocumentFragment === void 0 ||
47-
frag.createElement === void 0
48-
);
44+
return !(frag.cloneNode &&
45+
frag.createDocumentFragment &&
46+
frag.createElement);
4947
}());
5048
} catch(e) {
5149
// assign a false positive if detection fails => unable to shiv
@@ -323,4 +321,4 @@
323321
module.exports = html5;
324322
}
325323

326-
}(window === void 0 ? this : window, document));
324+
}(window || this, document));

0 commit comments

Comments
 (0)