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

docs: note default value breaking change to bind: in runes mode #12412

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

dummdidumm
Copy link
Member

#11400 (comment)

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Jul 11, 2024

⚠️ No Changeset found

Latest commit: 4bd2457

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@FoHoOV
Copy link
Contributor

FoHoOV commented Jul 11, 2024

I guess this can be mentioned as well (kinda the same but worth mentioning?) - My grammer sux soooo, forgive me :D:
While binding to bindable props within an each block, the inital array must have the same length (or bigger) as what the each block is iterating over. Previously svelte pushed to the array internally, but now it will use whatever is in the array.
Specifially:

<script>
      import Something from "./Something.svelte";
	
-     let boundValues = [];
+     let boundValues = $state(Array(3).fill(null)); // fill it with anything else other than undefined. 
</script>

{#each {length: 3} as _, i}
	<Something bind:value={boundValues[i]}></Something>
{/each}

Note the Array(3), is creating 3 elements, same length as what we are iterating over. For example using Array(2) will result in an error, because boundValues[2] is undefined.


Current changeset's focus is more around the default value propagation but this will also put a focus on the fact that we have to change the initial variable that we are binding to - which is specific to #each blocks AFAIK.

@Rich-Harris Rich-Harris merged commit f58d600 into main Jul 12, 2024
7 of 9 checks passed
@Rich-Harris
Copy link
Member

I think the each stuff is overkill — it's an edge case and it's not new information, it's something that's implied what's already there

@Rich-Harris Rich-Harris deleted the bind-docs-breaking-change branch July 12, 2024 14:13
trueadm pushed a commit that referenced this pull request Jul 12, 2024
…2412)

* docs: note default value breaking change to `bind:` in runes mode

#11400 (comment)

* Update sites/svelte-5-preview/src/routes/docs/content/03-appendix/02-breaking-changes.md

Co-authored-by: Rich Harris <[email protected]>

---------

Co-authored-by: Rich Harris <[email protected]>
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

3 participants