Skip to content

Commit

Permalink
Use Number.isNaN as a safer alternative to isNaN
Browse files Browse the repository at this point in the history
  • Loading branch information
tomalec committed Jun 25, 2024
1 parent 45b9a80 commit 9e2060c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/js/src/integrations/classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function classicTracking(
button?.[ 0 ]?.dataset.product_id || button?.[ 0 ]?.value
);

if ( isNaN( productID ) ) {
if ( Number.isNaN( productID ) ) {
throw new Error(
'Google Analytics for WooCommerce: Could not read product ID from the button given in `added_to_cart` event. Check whether WooCommerce Core events or elements are malformed by other extensions.'
);
Expand Down Expand Up @@ -104,7 +104,7 @@ export function classicTracking(
function removeFromCartHandler( element ) {
const productID = parseInt( element.target?.dataset.product_id );

if ( isNaN( productID ) ) {
if ( Number.isNaN( productID ) ) {
throw new Error(
'Google Analytics for WooCommerce: Could not read product ID from the target element given to remove from cart event. Check whether WooCommerce Core events or elements are malformed by other extensions.'
);
Expand Down

0 comments on commit 9e2060c

Please sign in to comment.