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:
parent
4922912bbb
commit
6097cfb2e9
1 changed files with 2 additions and 7 deletions
|
|
@ -79,16 +79,11 @@ function execSelector(state, attrs, children) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hyperscript(selector) {
|
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") {
|
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.");
|
throw Error("The selector must be either a string or a component.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof selector === "string") {
|
var attrs = arguments[1], start = 2, children
|
||||||
var cached = selectorCache[selector] || compileSelector(selector)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attrs == null) {
|
if (attrs == null) {
|
||||||
attrs = {}
|
attrs = {}
|
||||||
|
|
@ -108,7 +103,7 @@ function hyperscript(selector) {
|
||||||
var normalized = Vnode.normalizeChildren(children)
|
var normalized = Vnode.normalizeChildren(children)
|
||||||
|
|
||||||
if (typeof selector === "string") {
|
if (typeof selector === "string") {
|
||||||
return execSelector(cached, attrs, normalized)
|
return execSelector(selectorCache[selector] || compileSelector(selector), attrs, normalized)
|
||||||
} else {
|
} else {
|
||||||
return Vnode(selector, attrs.key, attrs, normalized)
|
return Vnode(selector, attrs.key, attrs, normalized)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue