Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null check for summary.NextElementSibling in global.js #3453

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vitorascorrea
Copy link

PR Summary:

This PR adds a check in global.js that prevents trying to access a <summary> element sibling if it doesn't exist.

Why are these changes introduced?

Fixes #3452

What approach did you take?

Use optional chaining on the nextElementSibling query.

Visual impact on existing themes

Merchants that have a <summary> element that matches the default global.js selector but don't have a sibling won't cause the page's javascript to thrown an exception.

Testing steps/scenarios

Customizing the theme's product page by adding an html snippet like the one below shouldn't break option/variant selection:

<div id="Details-001">
  <details>
    <summary>This is the only child</summary>
    <!-- There is no nextElementSibling for this summary -->
  </details>
</div>

Checklist

@vitorascorrea vitorascorrea requested review from lhoffbeck and a team May 3, 2024 14:25
@vitorascorrea vitorascorrea changed the title Add null check for summary.NextElementSibling Add null check for summary.NextElementSibling in global.js May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default global.js script tries to match for nextElementSiblings that might not exist
1 participant