Skip to content

Commit

Permalink
Small optimization in render hyperscript.js (MithrilJS#2064)
Browse files Browse the repository at this point in the history
* Small optimization in render hyperscript.js

* Remove temporary variable

* Small optimization in render hyperscript.js

Squashed commits:

[5b10329] Small optimization in render hyperscript.js

* Remove sloppy mode comment
  • Loading branch information
magikstm authored and dead-claudia committed Sep 25, 2018
1 parent d1b1cfe commit a10fb79
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions render/hyperscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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)
}
Expand Down

0 comments on commit a10fb79

Please sign in to comment.