Fix html in preview of product titles (https://github.com/woocommerce/woocommerce-blocks/pull/444)
* Fix html in preview of product titles Previously the html wasn't rendered in the preview for product titles. This renders the html. * Update test snapshot * Also decode html for featured preview name. * Un-escape HTML for featured post title render
This commit is contained in:
parent
ffc19e26ec
commit
7ffc11d987
|
@ -278,9 +278,12 @@ class FeaturedProduct extends Component {
|
||||||
style={ style }
|
style={ style }
|
||||||
>
|
>
|
||||||
<div className="wc-block-featured-product__wrapper">
|
<div className="wc-block-featured-product__wrapper">
|
||||||
<h2 className="wc-block-featured-product__title">
|
<h2
|
||||||
{ product.name }
|
className="wc-block-featured-product__title"
|
||||||
</h2>
|
dangerouslySetInnerHTML={ {
|
||||||
|
__html: product.name,
|
||||||
|
} }
|
||||||
|
/>
|
||||||
{ showDesc && (
|
{ showDesc && (
|
||||||
<div
|
<div
|
||||||
className="wc-block-featured-product__description"
|
className="wc-block-featured-product__description"
|
||||||
|
|
|
@ -25,7 +25,10 @@ const ProductPreview = ( { product } ) => {
|
||||||
return (
|
return (
|
||||||
<div className="wc-product-preview">
|
<div className="wc-product-preview">
|
||||||
{ image }
|
{ image }
|
||||||
<div className="wc-product-preview__title">{ product.name }</div>
|
<div
|
||||||
|
className="wc-product-preview__title"
|
||||||
|
dangerouslySetInnerHTML={ { __html: product.name } }
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
className="wc-product-preview__price"
|
className="wc-product-preview__price"
|
||||||
dangerouslySetInnerHTML={ { __html: product.price_html } }
|
dangerouslySetInnerHTML={ { __html: product.price_html } }
|
||||||
|
|
|
@ -10,9 +10,12 @@ exports[`ProductPreview should render a single product preview with an image 1`]
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className="wc-product-preview__title"
|
className="wc-product-preview__title"
|
||||||
>
|
dangerouslySetInnerHTML={
|
||||||
Winter Jacket
|
Object {
|
||||||
</div>
|
"__html": "Winter Jacket",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
className="wc-product-preview__price"
|
className="wc-product-preview__price"
|
||||||
dangerouslySetInnerHTML={
|
dangerouslySetInnerHTML={
|
||||||
|
@ -43,9 +46,12 @@ exports[`ProductPreview should render a single product preview without an image
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
className="wc-product-preview__title"
|
className="wc-product-preview__title"
|
||||||
>
|
dangerouslySetInnerHTML={
|
||||||
Winter Jacket
|
Object {
|
||||||
</div>
|
"__html": "Winter Jacket",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
className="wc-product-preview__price"
|
className="wc-product-preview__price"
|
||||||
dangerouslySetInnerHTML={
|
dangerouslySetInnerHTML={
|
||||||
|
|
|
@ -56,7 +56,7 @@ class WC_Block_Featured_Product {
|
||||||
|
|
||||||
$title = sprintf(
|
$title = sprintf(
|
||||||
'<h2 class="wc-block-featured-product__title">%s</h2>',
|
'<h2 class="wc-block-featured-product__title">%s</h2>',
|
||||||
esc_html( $product->get_title() )
|
wp_kses_post( $product->get_title() )
|
||||||
);
|
);
|
||||||
|
|
||||||
$desc_str = sprintf(
|
$desc_str = sprintf(
|
||||||
|
|
Loading…
Reference in New Issue