MCPcopy Index your code
hub / github.com/developit/htm / createVNode

Function createVNode

packages/babel-plugin-htm/index.mjs:99–122  ·  view source on GitHub ↗
(tag, props, children)

Source from the content-addressed store, hash-verified

97 }
98
99 function createVNode(tag, props, children) {
100 // Never pass children=[[]].
101 if (children.elements.length === 1 && t.isArrayExpression(children.elements[0]) && children.elements[0].elements.length === 0) {
102 children = children.elements[0];
103 }
104
105 if (inlineVNodes) {
106 return t.objectExpression([
107 options.monomorphic && t.objectProperty(propertyName('type'), t.numericLiteral(1)),
108 t.objectProperty(propertyName('tag'), tag),
109 t.objectProperty(propertyName('props'), props),
110 t.objectProperty(propertyName('children'), children),
111 options.monomorphic && t.objectProperty(propertyName('text'), t.nullLiteral())
112 ].filter(Boolean));
113 }
114
115 // Passing `{variableArity:false}` always produces `h(tag, props, children)` - where `children` is always an Array.
116 // Otherwise, the default is `h(tag, props, ...children)`.
117 if (options.variableArity !== false) {
118 children = children.elements;
119 }
120
121 return t.callExpression(pragma, [tag, props].concat(children));
122 }
123
124 function spreadNode(args, state) {
125 if (args.length === 0) {

Callers 1

transformFunction · 0.85

Calls 1

propertyNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…