Skip to content

Commit

Permalink
Add optional chaining to prevent JS error
Browse files Browse the repository at this point in the history
Added optional chaining to setActiveMedia call
  • Loading branch information
lhoffbeck committed Apr 18, 2024
1 parent 591d291 commit 22ae3f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion assets/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ class VariantSelects extends HTMLElement {

document
.querySelector(`[id^="MediaGallery-${this.dataset.section}"]`)
.setActiveMedia(`${this.dataset.section}-${this.currentVariant.featured_media?.id}`);
?.setActiveMedia?.(`${this.dataset.section}-${this.currentVariant.featured_media?.id}`);

// update media modal
const modalContent = document.querySelector(`#ProductModal-${this.dataset.section} .product-media-modal__content`);
Expand Down

0 comments on commit 22ae3f2

Please sign in to comment.