Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function renderAttributes( props ) {
let result = '';
for ( const key in props ) {
const attribute = getNormalAttributeName( key );
if ( ! isValidAttributeName( attribute ) ) {
continue;
}
let value = getNormalAttributeValue( key, props[ key ] );
// If value is not of serializeable type, skip.
if ( ! ATTRIBUTES_TYPES.has( typeof value ) ) {
continue;
}
// Don't render internal attribute names.
if ( isInternalAttribute( key ) ) {
continue;
}
const isBooleanAttribute = BOOLEAN_ATTRIBUTES.has( attribute );
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 ) }`;
}