ivi
Version:
Lightweight Embeddable Web UI Library.
67 lines • 2.44 kB
JavaScript
import { NODE_TYPE_ELEMENT, NODE_TYPE_EXPR, NODE_TYPE_TEXT, } from "./ir.js";
export const createSNode = (node, flags) => {
const properties = node.properties;
const iChildren = node.children;
let propsExprs = 0;
for (let i = 0; i < properties.length; i++) {
if (typeof properties[i].value === "number") {
propsExprs++;
}
}
let children = null;
let siblingsFlags = 0;
let childrenExprs = 0;
let i = iChildren.length;
if (i > 0) {
children = Array(i);
while (i > 0) {
const child = iChildren[--i];
switch (child.type) {
case NODE_TYPE_ELEMENT:
const sNode = createSNode(child, siblingsFlags);
if (sNode.flags & 1 /* SNodeFlags.HasExpressions */) {
flags |= 1 /* SNodeFlags.HasExpressions */;
siblingsFlags |= 2 /* SNodeFlags.HasNextExpressions */;
}
siblingsFlags |= 4 /* SNodeFlags.HasNextDOMNode */;
children[i] = sNode;
break;
case NODE_TYPE_EXPR:
siblingsFlags |= 2 /* SNodeFlags.HasNextExpressions */;
childrenExprs++;
children[i] = {
node: child,
stateIndex: 0,
children: null,
childrenExprs: 0,
propsExprs: 0,
flags: siblingsFlags,
};
break;
case NODE_TYPE_TEXT:
children[i] = {
node: child,
stateIndex: 0,
children: null,
childrenExprs: 0,
propsExprs: 0,
flags: siblingsFlags,
};
siblingsFlags |= 4 /* SNodeFlags.HasNextDOMNode */;
}
}
}
if (propsExprs > 0 || childrenExprs > 0) {
flags |= 1 /* SNodeFlags.HasExpressions */;
}
return {
node,
stateIndex: 0,
children,
childrenExprs,
propsExprs,
flags,
};
};
export const VOID_ELEMENTS = /^(audio|video|embed|input|param|source|textarea|track|area|base|link|meta|br|col|hr|img|wbr)$/;
//# sourceMappingURL=shared.js.map