Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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;
}
}
if (type === 'option' && typeof props.value !== 'undefined' && props.value === parent.props.value) {
// Parent value sets children value
renderedString += ` selected`;
}
}
if (isVoidElement) {
renderedString += `>`;
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 {
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}"`;
// 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<>]/)) {
throw renderedString;
}
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)}"`;
} else if (isNumber(className)) {
renderedString += ` class="${className}"`;
}
instance.$PS = null;
}
instance.$BR = false;
if (hasNewAPI) {
instance.state = createDerivedState(instance, props, instance.state);
}
const renderOutput = instance.render(instance.props, instance.state, instance.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);
});
}
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)}"`;
}
break;
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;
}
}
}
}
getDelay(key) {
const { delay } = this.props;
if (typeof delay === 'object') {
return !isNumber(delay[key]) ? DEFAULT_DELAYS[key] : delay[key];
}
return delay;
}
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();
}
if (!isNullOrUndef(childContext)) {
}
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];
switch (prop) {
case 'dangerouslySetInnerHTML':
html = value.__html;
break;
case 'style':
if (!isNullOrUndef(props.style)) {
renderedString += ` style="${renderStylesToString(props.style)}"`;
}
break;