Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
} else {
const renderOutput = type(props, context);
if (isInvalid(renderOutput)) {
this.addToQueue('', position);
} else if (isString(renderOutput)) {
this.addToQueue(escapeText(renderOutput), position);
} else if (isNumber(renderOutput)) {
this.addToQueue(renderOutput + '', position);
} else {
this.renderVNodeToQueue(renderOutput, context, position);
}
}
// If an element
} else if ((flags & VNodeFlags.Element) > 0) {
let renderedString = `<${type}`;
let html;
const isVoidElement = voidElements.has(type);
const className = vNode.className;
if (isString(className)) {
renderedString += ` class="${escapeText(className)}"`;
} else if (isNumber(className)) {
renderedString += ` class="${className}"`;
}
if (!isNull(props)) {
for (const prop in props) {
const value = props[prop];
switch (prop) {
export function isValidElement(obj: any): boolean {
const isValidObject = typeof obj === 'object' && !isNull(obj);
if (!isValidObject) {
return false;
}
return (obj.flags & (VNodeFlags.Component | VNodeFlags.Element)) > 0;
}
return renderVNodeToString(renderOutput, vNode, childContext);
} else {
const renderOutput = type(props, context);
if (isInvalid(renderOutput)) {
return '';
}
if (isString(renderOutput)) {
return escapeText(renderOutput);
}
if (isNumber(renderOutput)) {
return renderOutput + '';
}
return renderVNodeToString(renderOutput, vNode, context);
}
} else if ((flags & VNodeFlags.Element) !== 0) {
let renderedString = `<${type}`;
let html;
const isVoidElement = voidElements.has(type);
const className = vNode.className;
if (isString(className)) {
renderedString += ` class="${escapeText(className)}"`;
} else if (isNumber(className)) {
renderedString += ` class="${className}"`;
}
if (!isNull(props)) {
for (const prop in props) {
const value = props[prop];
public renderNode(vNode, context) {
const flags = vNode.flags;
if ((flags & VNodeFlags.Component) > 0) {
return this.renderComponent(vNode, context, flags & VNodeFlags.ComponentClass);
}
if ((flags & VNodeFlags.Element) > 0) {
return this.renderElement(vNode, context);
}
return this.renderText(vNode);
}
}
if (vNode.flags & VNodeFlags.Component) {
if (isString(vNode.type)) {
vNode.flags = getFlagsForElementVnode(vNode.type as string);
if (props) {
normalizeProps(vNode);
}
}
}
const flags = vNode.flags;
if (flags & VNodeFlags.FormElement) {
normalizeFormProps(vNode.type, props);
}
if (flags & VNodeFlags.Element) {
if (vNode.className) {
props.className = vNode.className;
}
normalizeGenericProps(props);
}
if (oldCreateVNode) {
oldCreateVNode(vNode);
}
};
function hydrateVNode(vNode: VNode, parentDOM: Element, currentDom: Element, context: Object, isSVG: boolean, lifecycle: Function[]): Element | null {
const flags = (vNode.flags |= VNodeFlags.InUse);
if (flags & VNodeFlags.Component) {
return hydrateComponent(vNode, parentDOM, currentDom, context, isSVG, (flags & VNodeFlags.ComponentClass) > 0, lifecycle);
}
if (flags & VNodeFlags.Element) {
return hydrateElement(vNode, parentDOM, currentDom, context, isSVG, lifecycle);
}
if (flags & VNodeFlags.Text) {
return hydrateText(vNode, parentDOM, currentDom);
}
if (flags & VNodeFlags.Void) {
return (vNode.dom = currentDom);
}
if (flags & VNodeFlags.Fragment) {
return hydrateFragment(vNode, parentDOM, currentDom, context, isSVG, lifecycle);
}
if (process.env.NODE_ENV !== 'production') {
throwError(`hydrate() expects a valid VNode, instead it received an object with the type "${typeof vNode}".`);
}
throwError();