Skip to content

Commit

Permalink
fix: escape issue + improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
tblivet committed Jun 12, 2024
1 parent 88aca6c commit ff7ea90
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
28 changes: 19 additions & 9 deletions src/js/components/UseHandleCartAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,27 @@ const sendCartRefreshRequest = (target: HTMLElement): void => {

if (alertPlaceholder && productUrl && productName) {
const alertText = alertPlaceholder.getAttribute('data-alert');
const productLink = `<a class="alert-link" href="${productUrl}">${productName}</a>`;
const alertMessage = `${productLink} ${alertText}`;

if (alertMessage) {
const alert = useAlert(alertMessage, {
type: 'success',
selector: SelectorsMap.cart.alertPlaceholder,
});
// Create the product link element
const productLink = document.createElement('a');
productLink.classList.add('alert-link');
productLink.setAttribute('href', productUrl);
productLink.textContent = productName;

alert.show();
}
// Create the alert message container
const alertMessage = document.createElement('span');
alertMessage.appendChild(productLink);
alertMessage.append(` ${alertText}`);

const alertMessageContainer = document.createElement('div');
alertMessageContainer.appendChild(alertMessage);

const alert = useAlert(alertMessageContainer.innerHTML, {
type: 'success',
selector: SelectorsMap.cart.alertPlaceholder,
});

alert.show();
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
data-id-product-attribute="{$product.id_product_attribute|escape:'javascript'}"
data-id-customization="{$product.id_customization|escape:'javascript'}"
data-product-url="{$product.url|escape:'javascript'}"
data-product-name="{$product.name|escape:'javascript'}"
data-product-name="{$product.name|escape:'htmlall':'UTF-8'}"
>
{l s='Remove' d='Shop.Theme.Checkout'}
</a>
Expand Down

0 comments on commit ff7ea90

Please sign in to comment.