From 7a184cb3b7f7bb992de6522808ca1c3dd37c9e5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=CC=81r=20O=CC=88rlygsson?= Date: Thu, 18 Feb 2016 18:42:26 +0000 Subject: [PATCH] Use RegExp#test instead of String#match Using `.test()` is both faster and more explicit. --- mithril.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mithril.js b/mithril.js index d023ac34..7d3721c8 100644 --- a/mithril.js +++ b/mithril.js @@ -456,7 +456,7 @@ nodes = injectHTML(parentElement, index, data) } else { nodes = [$document.createTextNode(data)] - if (!parentElement.nodeName.match(voidElements)) { + if (!voidElements.test(parentElement.nodeName)) { insertNode(parentElement, nodes[0], index) } } @@ -1902,7 +1902,7 @@ m.deferred.onerror = function (e) { if (type.call(e) === "[object Error]" && - !e.constructor.toString().match(/ Error/)) { + !/ Error/.test(e.constructor.toString())) { pendingRequests = 0 throw e }