fix: AvalComponent failing to mount on Safari 26 - #6
Merged
Merged
Conversation
|
@huntabyte is attempting to deploy a commit to the pixelpoint Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Safari 26.x (iOS and macOS), mounting
<AvalComponent>from@pixel-point/aval-sveltethrows:TypeError: Registered aval-player does not implement the required snapshot APIThe adapter binding called
defineAvalElement()lazily insideattach. By then Svelte had already created the<aval-player>host from a compiled template. Svelte creates custom-element hosts withdocument.importNode.WebKit only assigns the global registry to template nodes after
window.customElementshas been accessed at least once. Nodes created from a template before that getcustomElementRegistry === nulland never upgrade: not whendefine()runs, not when connected, and not aftercustomElements.upgrade(node). In a production Svelte app, nothing touchescustomElementsbefore the first render, so the host stays a plainHTMLElementandattachthrows.Minimal WebKit repro:
Accessing
window.customElementsbefore creating the template makes the same code work in WebKit.The bug doesn't show up under the Vite dev server. The Vite client defines
vite-error-overlaybefore the app runs, which initializes the registry.Fix
aval-svelte:createAvalnow callsdefineAvalElement()whencustomElementsis available.createAvalruns in the component script, before Svelte builds any template, so the element is always defined before a host can exist. During SSRcustomElementsis undefined and the call is skipped.aval-elementadapter binding: if a node still lacks the snapshot API afterdefineAvalElement(),upgrade()callscustomElements.upgrade(node)once before throwing. This covers hosts that were created beforedefine()and are still disconnected. Such hosts aren't upgraded bydefine()in any engine.Tests
New Playwright specs in
packages/svelte/test/browser/late-definition.spec.ts. They run in Chromium and in WebKit; the WebKit project runs against a productionvite build+vite preview, so the dev client can't hide the bug.<aval-player>from a template, and callsattach. Fails on WebKit without the fix, with the exact reported error.customElements.upgrade()fallback.AvalComponentwithout the page registeringaval-player: end-to-end sanity check in both engines.