From 6097cfb2e9146c63a3cad3816cd18511b37e7808 Mon Sep 17 00:00:00 2001 From: magikstm Date: Fri, 18 May 2018 14:48:56 -0400 Subject: [PATCH] Small optimization in render hyperscript.js (#2064) * Small optimization in render hyperscript.js * Remove temporary variable * Small optimization in render hyperscript.js Squashed commits: [5b103291] Small optimization in render hyperscript.js * Remove sloppy mode comment --- render/hyperscript.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/render/hyperscript.js b/render/hyperscript.js index 00c438c9..768dad8f 100644 --- a/render/hyperscript.js +++ b/render/hyperscript.js @@ -79,16 +79,11 @@ function execSelector(state, attrs, children) { } function hyperscript(selector) { - // Because sloppy mode sucks - var attrs = arguments[1], start = 2, children - if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") { throw Error("The selector must be either a string or a component."); } - if (typeof selector === "string") { - var cached = selectorCache[selector] || compileSelector(selector) - } + var attrs = arguments[1], start = 2, children if (attrs == null) { attrs = {} @@ -108,7 +103,7 @@ function hyperscript(selector) { var normalized = Vnode.normalizeChildren(children) if (typeof selector === "string") { - return execSelector(cached, attrs, normalized) + return execSelector(selectorCache[selector] || compileSelector(selector), attrs, normalized) } else { return Vnode(selector, attrs.key, attrs, normalized) }