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
This commit is contained in:
magikstm 2018-05-18 14:48:56 -04:00 committed by Pierre-Yves Gérardy
parent 4922912bbb
commit 6097cfb2e9

View file

@ -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)
}