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

fix: expose global functions when they are wrapped with try/catch #236

Merged

Conversation

slawekkolodziej
Copy link
Contributor

This PR modifies the snippet used to wrap scripts with functions exposed via 'globalFns.' Previous implementations did not work properly when functions were declared within a 'try/catch' block, for example:

<script type="text/partytown">
  try {
    function hello() {
      console.log('hello world!');
    }
  } catch (err) {}
</script>
<script type="text/partytown">
  if (hello) {
    hello();
  }
</script>

@vercel
Copy link

vercel bot commented Aug 2, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
partytown ✅ Ready (Inspect) Visit Preview Sep 2, 2022 at 5:58PM (UTC)

@adamdbradley
Copy link
Contributor

Thanks!

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.

None yet

2 participants