Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Only write boolean value as attribute if meaningful.
if ( typeof value === 'boolean' && ! isMeaningfulAttribute ) {
continue;
}
result += ' ' + attribute;
// Boolean attributes should write attribute name, but without value.
// Mere presence of attribute name is effective truthiness.
if ( isBooleanAttribute ) {
continue;
}
if ( typeof value === 'string' ) {
value = escapeAttribute( value );
}
result += '="' + value + '"';
}
return result;
}
function createElementHTML( { type, attributes, object, children } ) {
let attributeString = '';
for ( const key in attributes ) {
if ( ! isValidAttributeName( key ) ) {
continue;
}
attributeString += ` ${ key }="${ escapeAttribute( attributes[ key ] ) }"`;
}
if ( object ) {
return `<${ type }${ attributeString }>`;
}
return `<${ type }${ attributeString }>${ createChildrenHTML( children ) }`;
}