Skip to content

Commit 3f38738

Browse files
committed
Use typeof to test booleaness.
Using the typeof check is shorter, and in case of Chrome also faster at this point as shown in https://esbench.com/bench/591b46f299634800a03481f8 (upstream bug to address this at http://crbug.com/v8/6403). I personally also find the typeof version more readable, as it makes it clear what the intent was.
1 parent 9001436 commit 3f38738

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/h.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function h(nodeName, attributes) {
2525
for (i=child.length; i--; ) stack.push(child[i]);
2626
}
2727
else {
28-
if (child===true || child===false) child = null;
28+
if (typeof child==='boolean') child = null;
2929

3030
if ((simple = typeof nodeName!=='function')) {
3131
if (child==null) child = '';

src/vdom/diff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function idiff(dom, vnode, context, mountAll, componentRoot) {
6666
prevSvgMode = isSvgMode;
6767

6868
// empty values (null, undefined, booleans) render as empty Text nodes
69-
if (vnode==null || vnode===false || vnode===true) vnode = '';
69+
if (vnode==null || typeof vnode==='boolean') vnode = '';
7070

7171

7272
// Fast case: Strings & Numbers create/update Text nodes.

0 commit comments

Comments
 (0)