MCPcopy Index your code
hub / github.com/MithrilJS/mithril.js / execSelector

Function execSelector

render/hyperscript.js:32–79  ·  view source on GitHub ↗
(state, attrs, children)

Source from the content-addressed store, hash-verified

30}
31
32function execSelector(state, attrs, children) {
33 var hasAttrs = false, childList, text
34 var classAttr = hasOwn.call(attrs, "class") ? "class" : "className"
35 var className = attrs[classAttr]
36
37 if (!isEmpty(state.attrs) && !isEmpty(attrs)) {
38 var newAttrs = {}
39
40 for(var key in attrs) {
41 if (hasOwn.call(attrs, key)) {
42 newAttrs[key] = attrs[key]
43 }
44 }
45
46 attrs = newAttrs
47 }
48
49 for (var key in state.attrs) {
50 if (hasOwn.call(state.attrs, key) && key !== "className" && !hasOwn.call(attrs, key)){
51 attrs[key] = state.attrs[key]
52 }
53 }
54 if (className != null || state.attrs.className != null) attrs.className =
55 className != null
56 ? state.attrs.className != null
57 ? state.attrs.className + " " + className
58 : className
59 : state.attrs.className != null
60 ? state.attrs.className
61 : null
62
63 if (classAttr === "class") attrs.class = null
64
65 for (var key in attrs) {
66 if (hasOwn.call(attrs, key) && key !== "key") {
67 hasAttrs = true
68 break
69 }
70 }
71
72 if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") {
73 text = children[0].children
74 } else {
75 childList = children
76 }
77
78 return Vnode(state.tag, attrs.key, hasAttrs ? attrs : null, childList, text)
79}
80
81function hyperscript(selector) {
82 if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {

Callers 1

hyperscriptFunction · 0.70

Calls 2

isEmptyFunction · 0.70
VnodeFunction · 0.70

Tested by

no test coverage detected