Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function h (sel, b, c) { // eslint-disable-line complexity
let data = {}
let children
let text
let i
if (arguments.length === 3) {
data = b
if (is.array(c)) {
children = c
} else if (is.primitive(c)) {
text = c
}
} else if (arguments.length === 2) {
if (is.array(b)) {
children = b
} else if (is.primitive(b)) {
text = b
} else {
data = b
}
}
if (is.array(children)) {
children = children.filter(x => x) // handle null/undef children
for (i = 0; i < children.length; ++i) {
if (is.primitive(children[i])) {
children[i] = vnode(undefined, undefined, undefined, children[i])
}
}
}
if (sel[0] === 's' && sel[1] === 'v' && sel[2] === 'g') {
function addNS(data: any,
children: Array> | undefined,
selector: string | undefined): void {
data.ns = `http://www.w3.org/2000/svg`;
if (selector !== `text` && selector !== `foreignObject` &&
typeof children !== 'undefined' && is.array(children)) {
for (let i = 0; i < children.length; ++i) {
if (isGenericStream(children[i])) {
children[i] = (children[i] as Stream).map(mutateStreamWithNS);
} else {
addNS(
(children[i] as VNode).data,
(children[i] as VNode).children,
(children[i] as VNode).sel,
);
}
}
}
}
export function h(sel: string, b?: any, c?: any): VNode {
let data = {};
let children: Array | undefined;
let text: string | undefined;
if (arguments.length === 3) {
data = b;
if (is.array(c)) {
children = c;
} else if (is.primitive(c)) {
text = c as string;
}
} else if (arguments.length === 2) {
if (is.array(b)) {
children = b;
} else if (is.primitive(b)) {
text = b as string;
} else {
data = b;
}
}
if (is.array(children)) {
children = children.filter(x => !!x);
for (let i = 0; i < children.length; ++i) {
export function h(sel: string, b?: any, c?: any): VNode {
let data = {};
let children: Array | undefined;
let text: string | undefined;
if (arguments.length === 3) {
data = b;
if (is.array(c)) {
children = c;
} else if (is.primitive(c)) {
text = c as string;
}
} else if (arguments.length === 2) {
if (is.array(b)) {
children = b;
} else if (is.primitive(b)) {
text = b as string;
} else {
data = b;
}
}
if (is.array(children)) {
children = children.filter(x => !!x);
for (let i = 0; i < children.length; ++i) {
if (is.primitive(children[i])) {
children[i] = vnode(undefined as any, undefined, undefined, children[i] as any, undefined);
}
}
}
if (sel[0] === 's' && sel[1] === 'v' && sel[2] === 'g') {
data = b;
if (is.array(c)) {
children = c;
} else if (is.primitive(c)) {
text = c as string;
}
} else if (arguments.length === 2) {
if (is.array(b)) {
children = b;
} else if (is.primitive(b)) {
text = b as string;
} else {
data = b;
}
}
if (is.array(children)) {
children = children.filter(x => !!x);
for (let i = 0; i < children.length; ++i) {
if (is.primitive(children[i])) {
children[i] = vnode(undefined as any, undefined, undefined, children[i] as any, undefined);
}
}
}
if (sel[0] === 's' && sel[1] === 'v' && sel[2] === 'g') {
addNS(data, children, sel);
}
return vnode(sel, data, children, text, undefined);
};