Simon H
8be7dd558b
feat: make `<svelte:component>` unnecessary in runes mode ( #12646 )
...
* feat: make `<svelte:component>` unnecessary in runes mode
In Svelte 4, writing `<Component />` meant that the component instance is static. If you made the variable `Component` a reactive state variable and updated the component value, the component would not be reinstantiated with the new value - you had to use `<svelte:component>` for that. One reason was that having a dynamic component was more overhead, which is no longer the case in Svelte 5. We can therefore reduce the potential API surface area (by maybe deprecating `<svelte:component>` in the future) by allowing Svelte to recognize when a component variable is potentially dynamic. It turned out that this was already mostly the case. This PR fixes one case where it wasn't, and fixes another where this was wrongfully applied in legacy mode.
* we already have this function
* add interactive demos
* changeset
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Simon H
00e8ebde1d
fix: widen `ComponentProps` constraint to accept more component shapes ( #12666 )
...
language tools has to type its own shape for backwards compatibility, and it currently doesn't include the `$on` and `$set` methods, which means without widening the type as done here you would get a "this shape is not accepted" type error when passing it to `ComponentProps`
closes #12627
2 months ago
github-actions[bot]
ee1a3df835
Version Packages (next) ( #12650 )
...
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2 months ago
Simon Holthausen
d20e064674
chore: enhance comment on skipped test
...
explain what we need to unskip it
2 months ago
Simon Holthausen
7f558290d8
chore: enhance comment on skipped test
...
explain what we need to unskip it
2 months ago
Rich Harris
65234b80c0
chore: unified expression metadata ( #12644 )
...
* add ExpressionMetadata type
* use unified reactivity metadata
* simplify component
* rename
* more consistency
* store bindings on expression metadata
* tidy
* regenerate types
* remove junk from options node
* reuse
* tweak jsdoc
2 months ago
Simon H
363535c849
feat: warn on obvious legacy component instantiation ( #12648 )
...
Adds a compiler warning that warns about legacy component instantiation (i.e. using `new Component(..)`). This won't catch all cases, but the most obvious ones which probably make up ~80%
2 months ago
Simon H
85f2f161ed
chore: use queue_microtask on `#await` again ( #12647 )
...
Now that we've made `mount` and `hydrate` not call `flushSync` anymore, we can go back to using `queue_microtask` inside `#await`, which means people who want to synchronously see the pending block can do so using `flushSync` (as validated by our tests). This essentially reverts #12274
2 months ago
Paolo Ricciuti
32c4e47060
fix: always set draggable through `setAttribute` to avoid weird behavior ( #12649 )
...
Closes #12643
Very weird behaviour from the draggable setter...if you set element.draggable="false" it will actually set draggable to true (the boolean).
2 months ago
Dominic Gannaway
e417d3a2d2
fix: remove implicit passive behavior from OnDirective events ( #12645 )
...
Fixes #12639
2 months ago
github-actions[bot]
5817767a87
Version Packages (next) ( #12641 )
...
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2 months ago
Rich Harris
5d82cf1f03
feat: remove `$.unwrap` calls from `bind:group` ( #12642 )
...
* add each.metadata.keyed
* simplify
* feat: remove `$.unwrap` from `bind:group` code
* changeset
* regenerate types
2 months ago
Rich Harris
219ba6a71b
fix: error on `bind:this` to each block parameter ( #12638 )
...
* chore: remove outdated comment
* fix: error on `bind:this` to each block parameter
2 months ago
Rich Harris
7af0e604d8
feat: remove `$.unwrap` calls from each block indexes ( #12640 )
...
* remove $.unwrap from key functions
* feat: remove `$.unwrap` calls from each block indexes
* tweak
2 months ago
Simon H
3bff87ac66
chore: tweak html tree validation ( #12618 )
...
* chore: tweak html tree validation
- relax validation in some places where we know the HTML will not break or only break when using SSR
- consolidate validation in one place and for better reuse, which results in more cases getting caught at runtime
closes #11941
* move more of the validation into more descriptive record
* obselete / incorrect (those are not autoclosed, and the invalid ones handled later)
* typo
* backticks
* update tests
* Update packages/svelte/messages/compile-errors/template.md
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
* Update packages/svelte/messages/compile-warnings/template.md
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Rich Harris
2e8a205161
chore: remove outdated comment ( #12632 )
2 months ago
Rich Harris
04a211e1e1
chore: VSCode -> VS Code ( #12631 )
2 months ago
Simon H
dba4dfaff8
docs: add testing section ( #12600 )
...
* docs: add testing section
- explain component and rune testing using Vitest
- explain e2e testing using Playwright
closes #10244
closes #10650
* better examples
* Update documentation/docs/05-misc/02-testing.md
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* Update documentation/docs/05-misc/02-testing.md
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* Update documentation/docs/05-misc/02-testing.md
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* fix
* Update documentation/docs/05-misc/02-testing.md
* Update documentation/docs/05-misc/02-testing.md
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
* Update documentation/docs/05-misc/02-testing.md
* we normally use single quotes
* Apply suggestions from code review
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* more details on component testing
* extract component testing into its own sub section, reorder a bit
* fix code example
* Update documentation/docs/05-misc/02-testing.md
* Apply suggestions from code review
Co-authored-by: Rich Harris <rich.harris@vercel.com>
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com>
2 months ago
github-actions[bot]
1d17677131
Version Packages (next) ( #12613 )
...
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2 months ago
Simon H
c9e9e90659
fix: always close tags when namespace is foreign ( #12623 )
2 months ago
Simon H
32af9434bc
fix: never set custom element props as attributes ( #12622 )
...
* fix: never set custom element props as attributes
* changeset
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Simon H
0f41689916
chore: unskip more tests ( #12621 )
2 months ago
btea
e1728e5a0b
chore: remove unnecessary `\d` ( #12619 )
...
`\w` includes `\d`
2 months ago
Rich Harris
a212b0d2fe
chore: remove obsolete comment ( #12615 )
2 months ago
Rich Harris
97d5cf178f
chore: simplify assignments in server code ( #12614 )
...
Also fixes an uncovered bug where store `+=/-=` etc assignments were not serialized correctly on the server
2 months ago
Dominic Gannaway
993fff0045
fix: tune hydrate mismatch logic to catch more cases ( #12612 )
2 months ago
Rich Harris
c66d2cfcc1
feat: better code generation for `let:` directives in SSR mode ( #12611 )
...
* better code generation for slot props in SSR
* simplify
* remove getters mechanism from server compiler
* changeset
* no need to use getters in SSR mode
* fix comment
2 months ago
github-actions[bot]
beea5c3772
Version Packages (next) ( #12609 )
...
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
github-actions[bot]
ff27753742
Version Packages (next) ( #12583 )
...
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2 months ago
Rich Harris
ba5f5f38b1
chore: tweak event delegation docs ( #12607 )
2 months ago
Simon H
13d86e9019
feat: allow `:global` in more places (alternative) ( #12560 )
...
* `div { :global { &.x { ... } } }` is equivalent to `div:global.x { ... }`, so the latter should be allowed, too
* finalize
* replace obsolete breaking change (which turned out to be a wrong change and was since reverted), add new breaking change note
* changeset
* regenerate types
* Update sites/svelte-5-preview/src/routes/docs/content/03-appendix/02-breaking-changes.md
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* always remove descendant selector before global
* error on lone `:global` with nested `&`, revert "remove spaces" rule
* regenerate types
* documentation
* oops
* switch to removing descendant combinator
* fix
* revert combinator validation relaxation
* error on first global being modified
* tweak docs
* tweak error messages
* Update documentation/docs/02-template-syntax/05-styles-and-classes.md
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* clarify
* tweak messages
* update tests
* tweak docs
* tweak `:global(...)` docs
* tweak docs
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Rich Harris
e2f17c8a7b
chore: tweak xmlns docs ( #12606 )
2 months ago
Rich Harris
db7652116e
chore: tweak `$state.is` warning docs a bit more ( #12605 )
2 months ago
Dominic Gannaway
5a07219836
fix: add missing hydration mismatch call-site ( #12604 )
...
* fix: add missing hydration mismatch call-site
* add changeset
* Update playgrounds/demo/index.html
Co-authored-by: Conduitry <git@chor.date>
---------
Co-authored-by: Conduitry <git@chor.date>
2 months ago
Simon H
3515776009
docs: tweak `$state.is` warning ( #12599 )
...
Also add a detailed explanation which can later appear on the docs site
closes #11556
2 months ago
Dominic Gannaway
afa3128d2f
breaking: avoid flushing queued updates on mount/hydrate ( #12602 )
...
* Revert "Revert "breaking: avoid flushing queued updates on mount/hydrate" (#1…"
This reverts commit 8d139210b7
.
* fix legacy wrapper
* lint
* docs
* duplicate
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Rich Harris
75ea6da9cd
chore: modularize server code ( #12596 )
...
* start modularizing server code
* more
* more
* more
* more
* alphabetize
* start on JS visitors
* more
* more
* more
* more
* less
* more
* alphabetize
* lint
* combine into single visitors folder
* alphabetize
2 months ago
Simon H
6223a7e87e
docs: event delegation tweaks ( #12597 )
...
closes #11317
2 months ago
Simon H
bc78391bdc
docs: mention xmlns attribute for `<svelte:element>` ( #12598 )
...
closes #11993
2 months ago
Dominic Gannaway
7a8cf3a9a1
fix: ensure directives run in sequential order ( #12591 )
...
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Rich Harris
c173140969
chore: use JSDoc import ( #12595 )
...
* more
* more
* more
2 months ago
Rich Harris
8d139210b7
Revert "breaking: avoid flushing queued updates on mount/hydrate" ( #12593 )
...
* Revert "breaking: avoid flushing queued updates on mount/hydrate (#12587 )"
This reverts commit 20b879717a
.
* Update packages/svelte/src/internal/client/render.js
2 months ago
Rich Harris
c548932390
chore: use JSDoc imports ( #12592 )
...
* more
* more
* more
* more
* more
* more
* more
* regenerate types
2 months ago
Rich Harris
7a5c6b588f
chore: more JSDoc imports ( #12590 )
...
* more
* more
* more
* more
* fix
2 months ago
Dominic Gannaway
20b879717a
breaking: avoid flushing queued updates on mount/hydrate ( #12587 )
...
* breaking: avoid flushing queued updates on mount/hydrat
* Fix tests
* Update packages/svelte/src/internal/client/render.js
Co-authored-by: Rich Harris <rich.harris@vercel.com>
* tweak
* tweak
---------
Co-authored-by: Rich Harris <rich.harris@vercel.com>
2 months ago
Rich Harris
6037b961c0
chore: more JSDoc ( #12588 )
2 months ago
Dominic Gannaway
abaa4413df
fix: tweak element_invalid_self_closing_tag to exclude namespace ( #12585 )
2 months ago
Rich Harris
621eb76e1e
chore: use JSDoc `@import` ( #12581 )
...
* chore: use JSDoc @import
* regenerate types
2 months ago
Dominic Gannaway
37f58cf318
fix: apply dynamic event fixes to OnDirective ( #12582 )
...
* fix: apply dynamic event fixes to OnDirective
* build
2 months ago
Simon H
528d3468d0
docs: note hydration comments change ( #12580 )
...
closes #10375
2 months ago