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

feat: allow to specify a scope for text/partytown scripts #624

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

aaa123eee
Copy link

@aaa123eee aaa123eee commented Sep 11, 2024

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests

Description

We have our custom "text/partytown" scripts added to the document which meant to be executed only in the worker scope.

If the fallback happens, we have to check an execution scope to avoid errors,
like typeof WorkerGlobalScope === 'undefined'

I suggest more elegant way of settling a scope for a script

<script type="text/partytown"  ptScope="worker" src="/worker-custom-logic.js"></script>

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

Copy link

vercel bot commented Sep 11, 2024

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

Name Status Preview Comments Updated (UTC)
partytown ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 11, 2024 9:24pm

@@ -96,7 +96,7 @@ export function snippet(
doc.querySelector(config!.sandboxParent || 'body')!.appendChild(sandbox);
}

function fallback(i?: number, script?: HTMLScriptElement) {
function fallback() {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parameters were never passed to the function

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.

1 participant