We have an each block optimization that omits the comment when the each block is the sole child of an element. This optimization clashes with async which wants to skip ahead to the sibling closing comment.
For now we therefore remove that optimization when the each block is async. In the long run we should instead optimize _all_ cases where _any_ block is the sole child of an element, in both async and sync mode, consistently.
fixes#16905fixes#16907
* fix: update error message to clarify usage with radio inputs
* show an extra bind checked error when a radio type
* typo
* replace 'group' binding with , drive-by fix some other messages
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Race them against each other - in almost all cases requestAnimationFrame will fire first, but e.g. in case the window is not focused or a view transition happens, requestAnimationFrame will be delayed and setTimeout helps us resolve fast enough in that case
Fixes#16429
Fixes https://github.com/sveltejs/kit/issues/14220
* fix: depend on reads of deriveds created within reaction (async mode)
As part of https://github.com/sveltejs/kit/pull/14481 we discovered that deriveds created within reactions and reading from them in that same reaction is actually useful in some cases, as such a use case we couldn't imagine yet in #15564 has appeared.
We think it's ultimately better to rerun on those cases, so we're going to make this change in async mode (that way the behavior doesn't change unless you have enabled the experimental flag)
* fix tests
Fixes#16816Fixes#16811
---------
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* feat: First pass at payload
* first crack
* snapshots
* checkpoint
* fix: cloning
* add test option
* big dumb
* today's hard work; few tests left to fix
* improve
* tests passing no wayyyyy yo
* lots of progress, couple of failing tests around selects
* meh
* solve async tree stuff
* fix select/option stuff
* whoop, tests
* simplify
* feat: hoisting
* fix: `$effect.pending` sends updates to incorrect boundary
* changeset
* stuff from upstream
* feat: first hydrationgaa
* remove docs
* snapshots
* silly fix
* checkpoint
* meh
* ALKASJDFALSKDFJ the test passes
* chore: Update a bunch of tests for hydration markers
* chore: remove snippet and is_async
* naming
* better errors for sync-in-async
* test improvements
* idk man
* merge local branches (#16757)
* use fragment as async hoist boundary
* remove async_hoist_boundary
* only dewaterfall when necessary
* unused
* simplify/fix
* de-waterfall awaits in separate elements
* update snapshots
* remove unnecessary wrapper
* fix
* fix
* remove suspends_without_fallback
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* Update payload.js
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* checkpoint
* got the extra children to go away
* just gonna go ahead and merge this as the review comments take up too much space
* chore: remove hoisted_promises (#16766)
* chore: remove hoisted_promises
* WIP optimise promises
* WIP
* fix <slot> with await in prop
* tweak
* fix type error
* Update packages/svelte/src/compiler/phases/3-transform/server/visitors/SvelteHead.js
* chore: fix hydration treeshaking (#16767)
* chore: fix hydration treeshaking
* fix
* remove await_outside_boundary error (#16762)
* chore: remove unused analysis.boundary (#16763)
* chore: simplify slots (#16765)
* chore: simplify slots
* unused
* Apply suggestions from code review
* chore: remove metadata.pending (#16764)
* Update packages/svelte/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js
* put this back where it was, keep the diff small
* Update packages/svelte/src/compiler/phases/types.d.ts
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* chore: remove analysis.state.title (#16771)
* chore: remove analysis.state.title
* unused
* chore: remove is_async (#16769)
* chore: remove is_async
* unused
* Apply suggestions from code review
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* cleanup
* lint
* clean up payload a bit
* compiler work
* run ssr on sync and async
* prettier
* inline capture
* Update packages/svelte/src/compiler/phases/3-transform/server/visitors/EachBlock.js
* chore: simplify build_template (#16780)
* small tweak to aid greppability
* chore: fix SSR context (#16781)
* at least passing
* cleanup
* fix
* remove push/pop from exports, not needed with payload
* I think this is better but tbh not sure
* async SSR
* qualification
* errors:
* I have lost the plot
* finally
* ugh
* tweak error codes to better align with existing conventions, such as they are
* tweak messages
* remove unused args
* DRY out a bit
* unused
* unused
* unused
* simplify - we can enforce readonly at a type level
* unused
* simplify
* avoid magical accessors
* simplify algorithm
* unused
* unused
* reduce indirection
* TreeState -> SSRState
* mark deprecated methods
* grab this.local from parent directly
* rename render -> fn per conventions (fn indicates 'arbitrary code')
* reduce indirection
* Revert "reduce indirection"
This reverts commit 3ec461baad.
* tweak
* okay works this time
* no way chat, it works
* fix context stuff
* tweak
* make it chainable
* lint
* clean up
* lint
* Update packages/svelte/src/internal/server/types.d.ts
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* sunset html for async
* types
* we use 'deprecated' in other messages
* oops
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* chore: generate CSS hash using the filename
* fix all tests but one
* slightly kludgy fix
* try this
* fix
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Consolidates our scheduling system that had diverged into two - queue_micro_task and Batch.ensure-queues and resolves some edge case race conditions related to flushSync along the way.
* fix: send `$effect.pending` count to the correct boundary
* make boundary.pending private, use boundary.is_pending consistently
* move error to correct place
* we need that error
* update JSDoc
When an async derived already has a previous promise that is still pending, we were not accessing the `then` property of the new promise. If that property access causes signals to be read, that meant that those dependencies were lost and as such the derived wouldn't rerun anymore when it should. The fix is to make sure to always access the thennable.
* fix : remove cursor manipulation for input bindings
Old Fix: Restore input binding selection position (#14649)
Current Fix: Remove unnecessary cursor manipulation as the presence of runes no longer requires special handling.
* fix : add change set to my previous commit
* Revert "fix : add change set to my previous commit"
This reverts commit 6ca8ef3f97.
* fix: revert previous changeset added new to fix lint errors
* chore : resolve lint error to fix pipeline issue
* Revert "fix: revert previous changeset added new to fix lint errors"
This reverts commit 91094949a6.
* fix: input binding to handle code in a synchronous manner
Introduced Promise.resolve to ensure that the 'set' operation completes before the 'get' operation Minimizing update delays.
* Fix: resolve cursor jumps and change sets
* better fix
* test
* changeset
* simplify
* failing test
* gah we can't fix the input in an effect, need to do it here, but after a tick so that changes have been flushed through each blocks
* add explanatory comment
* fix test
* this seems to work?
---------
Co-authored-by: Hariharan Srinivasan <hariharan.srinivasan@kadfire.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Fixes#16591
This PR introduces a check for builtin custom elements (is attribute) inside the set_custom_element_data helper in order to correctly set properties that have a setter.
Implemented by reusing the `async_body` function inside `Fragment.js`. Also removes the ability to reference a `{@const ...}` of an implicit child inside a boundary pending/failed snippet:
- existing duplication of consts can have unintended side effects, e.g. async consts would unexpectedly called multiple times
- what if a const is the reason for the failure of a boundary, but is then referenced in the failed snippet?
- what if an async const is referenced in a pending snippet? deadlock
- inconsistent with how it behaves for components where this already does not work
Implemented via the experimental flag so the behavior change only applies there as this is a breaking change strictly speaking. Also added a compiler error for this.
closes#16462
* fix: properly catch top level await errors
async errors within the template and derived etc are properly handled because they know about the last active effect and invoke the error boundary correctly as a response. This logic was missing for our top level await output.
Fixes#16613
* test
* use helper for async bodies (#16641)
* use helper for async bodies
* unused
* fix
* failing test + fix
---------
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: skip effects inside dynamic component that is about to be destroyed
When a dynamic component was updated to a different instance and its props were updated at the same time, effects inside the component were still called with the already-changed props.
The fix is to mark the branch as skipped to never got to those effects.
Fixes#16387
* undo accidental commit
* fix: wrap `abort` in `without_reactive_context`
* only call without_reactive_context when the controller exists
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix: emit `snippet_invalid_export` instead of `undefined_export` for exported snippets
* try this
* this should work
* remove some junk (this never did anything)
* add test
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* Fix double event processing (#16522)
Firefox seems to garbage collect event objects during event propagation if no global reference to the event object is kept.
That discards the __root marker set on the event object to early,
leading to duplicate processing.
* minor tweaks
---------
Co-authored-by: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com>