Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Should not patch same innerHTML', () => {
container.innerHTML = '<span><span><span>child</span></span></span>';
const childelem = container.firstElementChild.firstElementChild;
const props = { dangerouslySetInnerHTML: { __html: '<span>child</span>' } };
const bar = createVNode(VNodeFlags.HtmlElement, 'span', null, null, ChildFlags.HasInvalidChildren, props, null, null);
const foo = createVNode(VNodeFlags.HtmlElement, 'span', null, [bar], ChildFlags.HasNonKeyedChildren, null, null, null);
render(foo, container);
expect(childelem).toBe(container.firstElementChild.firstElementChild);
});
if (String(type).match(/[\s\n\/='"\0<>]/)) {
throw renderedString;
}
if (isVoidElement) {
return;
} else {
if (html) {
this.push(html);
this.push(``);
return;
}
}
const childFlags = vNode.childFlags;
if (childFlags === ChildFlags.HasInvalidChildren) {
this.push(``);
return;
}
return Promise.resolve(this.renderChildren(vNode.children, context, childFlags)).then(() => {
this.push(``);
});
}
}
props.children = children;
if (flags & VNodeFlags.Component) {
return createComponentVNode(flags, vNodeToClone.type, !vNodeToClone.props && !props ? EMPTY_OBJ : combineFrom(vNodeToClone.props, props), key, ref);
}
if (flags & VNodeFlags.Text) {
return createTextVNode(children);
}
if (flags & VNodeFlags.Fragment) {
return createFragment(childLen === 1 ? [children] : children, ChildFlags.UnknownChildren, key);
}
return normalizeProps(
createVNode(flags, vNodeToClone.type, className, null, ChildFlags.HasInvalidChildren, combineFrom(vNodeToClone.props, props), key, ref)
);
}
function hydrateChildren(parentVNode: VNode, parentNode, currentNode, context, isSVG, lifecycle: Function[]) {
const childFlags = parentVNode.childFlags;
const children = parentVNode.children;
const props = parentVNode.props;
const flags = parentVNode.flags;
if (childFlags !== ChildFlags.HasInvalidChildren) {
if (childFlags === ChildFlags.HasVNodeChildren) {
if (isNull(currentNode)) {
_M(children as VNode, parentNode, context, isSVG, null, lifecycle);
} else {
currentNode = hydrateVNode(children as VNode, parentNode, currentNode as Element, context, isSVG, lifecycle);
currentNode = currentNode ? currentNode.nextSibling : null;
}
} else if (childFlags === ChildFlags.HasTextChildren) {
if (isNull(currentNode)) {
parentNode.appendChild(document.createTextNode(children as string));
} else if (parentNode.childNodes.length !== 1 || currentNode.nodeType !== 3) {
parentNode.textContent = children as string;
} else {
if (currentNode.nodeValue !== children) {
currentNode.nodeValue = children as string;
}