Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
label={ __( 'Product rating', 'woo-gutenberg-products-block' ) }
checked={ attributes.showReviewRating }
onChange={ () =>
setAttributes( {
showReviewRating: ! attributes.showReviewRating,
} )
}
/>
{ attributes.showReviewRating && ! REVIEW_RATINGS_ENABLED && (
{ sprintf(
escapeHTML(
/* translators: A notice that links to WooCommerce settings. */
__(
'Product rating is disabled in your %sstore settings%s.',
'woo-gutenberg-products-block'
)
),
`<a href="${ getAdminLink(
'admin.php?page=wc-settings&tab=products'
) }">`,
'</a>'
) }
) }
// 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;
}
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 );
export function renderElement( element, context, legacyContext = {} ) {
if ( null === element || undefined === element || false === element ) {
return '';
}
if ( Array.isArray( element ) ) {
return renderChildren( element, context, legacyContext );
}
switch ( typeof element ) {
case 'string':
return escapeHTML( element );
case 'number':
return element.toString();
}
const { type, props } = element;
switch ( type ) {
case StrictMode:
case Fragment:
return renderChildren( props.children, context, legacyContext );
case RawHTML:
const { children, ...wrapperProps } = props;
return renderNativeComponent(
function announceCurrentSlide( swiper ) {
const currentSlide = swiper.slides[ swiper.activeIndex ];
if ( ! currentSlide ) {
return;
}
const figcaption = currentSlide.getElementsByTagName( 'FIGCAPTION' )[ 0 ];
const img = currentSlide.getElementsByTagName( 'IMG' )[ 0 ];
if ( swiper.a11y.liveRegion ) {
swiper.a11y.liveRegion[ 0 ].innerHTML = figcaption
? figcaption.innerHTML
: escapeHTML( img.alt );
}
}
return children.map( ( child ) => {
return child.text === undefined ? createElementHTML( child ) : escapeHTML( child.text );
} ).join( '' );
}
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 ) }`;
}
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 ) }`;
}