Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break;
case 'defaultValue':
// Use default values if normal values are not present
if (!props.value) {
renderedString += ` value="${isString(value) ? escapeText(value) : value}"`;
}
break;
case 'defaultChecked':
// Use default values if normal values are not present
if (!props.checked) {
renderedString += ` checked="${value}"`;
}
break;
default:
if (isAttributeNameSafe(prop)) {
if (isString(value)) {
renderedString += ` ${prop}="${escapeText(value)}"`;
} else if (isNumber(value)) {
renderedString += ` ${prop}="${value}"`;
} else if (value === true) {
renderedString += ` ${prop}`;
}
break;
}
}
}
}
renderedString += `>`;
this.push(renderedString);
if (String(type).match(/[\s\n\/='"\0<>]/)) {
} 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) {
case 'dangerouslySetInnerHTML':
html = value.__html;
break;
case 'style':
if (!isNullOrUndef(props.style)) {
renderedString += ` style="${renderStylesToString(props.style)}"`;
let props: any = vNode.props;
if (isNullOrUndef(props)) {
props = vNode.props = {};
}
// React supports iterable children, in addition to Array-like
if (hasSymbolSupport && !isNull(children) && typeof children === 'object' && !isArray(children) && isFunction(children[symbolIterator])) {
vNode.children = iterableToArray(children[symbolIterator]());
}
if (!isNullOrUndef(children) && isNullOrUndef(props.children)) {
props.children = children;
}
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;
}
public renderElement(vNode, context) {
const type = vNode.type;
const props = vNode.props;
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) {
case 'dangerouslySetInnerHTML':
html = value.__html;
break;
case 'style':
if (!isNullOrUndef(props.style)) {
renderedString += ` style="${renderStylesToString(props.style)}"`;
return '';
}
if (isString(renderOutput)) {
return escapeText(renderOutput);
}
if (isNumber(renderOutput)) {
return renderOutput + '';
}
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)}"`;
position
);
return;
} else {
instance.props = combineFrom(instance.props, initialProps);
}
}
}
if (hasNewAPI) {
instance.state = createDerivedState(instance, props, instance.state);
}
const renderOutput = instance.render(instance.props, instance.state, instance.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);
}
} 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 {
public renderComponent(vComponent, context, isClass) {
const type = vComponent.type;
const props = vComponent.props;
if (!isClass) {
const renderOutput = type(props, context);
if (isInvalid(renderOutput)) {
return this.push('');
}
if (isString(renderOutput)) {
return this.push(escapeText(renderOutput));
}
if (isNumber(renderOutput)) {
return this.push(renderOutput + '');
}
return this.renderNode(renderOutput, context);
}
const instance = new type(props, context);
const hasNewAPI = Boolean(type.getDerivedStateFromProps);
instance.$BS = false;
instance.$SSR = true;
let childContext;
if (isFunction(instance.getChildContext)) {
childContext = instance.getChildContext();
function normalizeGenericProps(props) {
for (const prop in props) {
const mappedProp = InfernoCompatPropertyMap[prop];
if (mappedProp && props[prop] && mappedProp !== prop) {
props[mappedProp] = props[prop];
props[prop] = void 0;
}
if (options.reactStyles && prop === 'style') {
const styles = props.style;
if (styles && !isString(styles)) {
const newStyles = {};
for (const s in styles) {
const value = styles[s];
const hyphenStr = hyphenCase(s);
newStyles[hyphenStr] = isNumber(value) ? getNumberStyleValue(hyphenStr, value) : value;
}
props.style = newStyles;
}
}
}
}