update diffs (#13575)

* update diffs

* gah

* fix
pull/13581/head
Rich Harris 2 months ago committed by GitHub
parent 3f0b41b252
commit 5ee3ae4369
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,8 +10,7 @@ Most state is component-level state that lives as long as its component lives. T
The easiest way to do that is to create global state and just import that.
```ts
/// file: state.svelte.ts
/// file: state.svelte.js
export const myGlobalState = $state({
user: {
/* ... */

@ -110,23 +110,21 @@ With runes, we can use `$effect.pre`, which behaves the same as `$effect` but ru
- [Before](/#H4sIAAAAAAAAE31WXa_bNgz9K6yL1QmWOLlrC-w6H8MeBgwY9tY9NfdBtmlbiywZkpyPBfnvo2zLcZK28AWuRPGI5OGhkEuQc4EmiL9eAskqDOLg97oOZoE9125jDigs0t6oRqfOsjap5rXd7uTO8qpW2sIFEsyVxn_qjFmcAcstar-xPN3DFXKtKgi768IVgQku0ELj3Lgs_kZjWIEGNpAzYXDlHWyJFZI1zJjeh4O5uvl_DY8oUkVeVoFuJKYls-_CGYS25Aboj0EtWNqel0wWoBoLTGZgmdgDS9zW4Uz4NsrswPHoyutN4xInkylstnBxdmIhh8m7xzqmoNE2Wq46n1RJQzEbq4g-JQSl7e-HDx-GdaTy3KD9E3lRWvj5Zu9QX1QN20dj7zyHz8s-1S6lW7Cpz3RnXTcm04hIlfdFuO8p2mQ5-3a06cqjrn559bF_2NHOnRZ5I1PLlXQNyQT-hedMHeUEDyjtdMxsa4n2eIbNhlTwhyRthaOKOmYtniwF6pwt0wXa6MBEg0OibZec27gz_dk3UrZ6hB2LLYoiv521Yd8Gt-foTrfhiCDP0lC9VUUhcDLU49Xe_9943cNvEArHfAjxeBTovvXiNpFynfEDpIIZs9kFbg52QbeNHWZzebz32s7xHco3nJAJl1nshmhz8dYOQJDyZetnbb2gTWe-vEeWlrfpZMavr56ldb29eNt6UXvgwgFbp_WC0tl2RK25rGk6lYz3nUI2lzvBXGHhPZPGWmKUXFNBKqdaW259wl_aHbiqoVIZdpE60Nax6IOujT0LbFFx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Me-mG6A7l60XIlMs8ce2-OXtrDyBItdz6qVjPadObzx-RZdV1nJjx64tXad1sz962njceOHfAzmk9JzrbXqg1lw3NkZL7vgE257t-uMDcO6attSSokpmgFqVMO2U93e_dDlzOUKsc-3t6zNZp6K9cG3sS2KGSUqiUiUmq8tNYoJwbmvpTAoXA96GyjCojI26xNglk6DpwOPm7NdRYp4ia0JL94bTqRiGB5WJxqFY37RGPoz3c6i4jP3rcUA7wmhqNywQW7om_YQ2L4UQdUBdCHSPiOQJ8bFcxHzeK0jKBY0XcV95SkCWlD9t-9eOM3TLKucauiyktJdpaPqT19ddF4wFHntsqgS-_XE01e48GMwnw02AtWZP02QyGVOkcNfk072CU4PkduZSWpVYt9SkcmJ64hPwHpWF5ziVls3wIFmmW89Y83vMeGf5PBxjcyPSkXNy10J18t3x6-a6CDtBq6SGklNKeazFyLahB3PVIGo2UbhOgGi9vKjzW_j6xVFFD17difXx5ebll0vwvkcGpn4sZ9MN3vqFYsJoL6gUuK9TcPrO_PxgzWMRfflSEr2NHPJf6lj1957rRpH8CNMG84JgHidUtXt4u_wK21LXERAgAAA==)
```diff
<!-- prettier-ignore -->
```svelte
<script>
- import { beforeUpdate, afterUpdate, tick } from 'svelte';
+ import { tick } from 'svelte';
import { ---beforeUpdate, afterUpdate,--- tick } from 'svelte';
- let updatingMessages = false;
- let theme = 'dark';
- let messages = [];
+ let theme = $state('dark');
+ let messages = $state([]);
---let updatingMessages = false;---
let theme = +++$state('dark')+++;
let messages = +++$state([])+++;
let viewport;
- beforeUpdate(() => {
+ $effect.pre(() => {
- if (!updatingMessages) return;
+ messages;
---beforeUpdate(() => {---
+++$effect.pre(() => {+++
---if (!updatingMessages) return;---
+++messages;+++
const autoscroll = viewport && viewport.offsetHeight + viewport.scrollTop > viewport.scrollHeight - 50;
if (autoscroll) {
@ -135,7 +133,7 @@ With runes, we can use `$effect.pre`, which behaves the same as `$effect` but ru
});
}
- updatingMessages = false;
---updatingMessages = false;---
});
function handleKeydown(event) {
@ -143,7 +141,7 @@ With runes, we can use `$effect.pre`, which behaves the same as `$effect` but ru
const text = event.target.value;
if (!text) return;
- updatingMessages = true;
---updatingMessages = true;---
messages = [...messages, text];
event.target.value = '';
}
@ -161,12 +159,8 @@ With runes, we can use `$effect.pre`, which behaves the same as `$effect` but ru
{/each}
</div>
- <input on:keydown={handleKeydown} />
+ <input onkeydown={handleKeydown} />
<input +++onkeydown+++={handleKeydown} />
- <button on:click={toggle}>
+ <button onclick={toggle}>
Toggle dark mode
</button>
<button +++onclick+++={toggle}> Toggle dark mode </button>
</div>
```

@ -16,10 +16,10 @@ npm install -D vitest
Then adjust your `vite.config.js`:
```diff
<!-- prettier-ignore -->
```js
/// file: vite.config.js
- import { defineConfig } from 'vite';
+ import { defineConfig } from 'vitest/config';
import { defineConfig } from +++'vitest/config'+++;
export default defineConfig({ /* ... */ })
```

@ -774,24 +774,27 @@ In some cases `<object.property>` syntax can be used as a replacement; a lowerca
For complex component resolution logic, an intermediary, capitalized variable may be necessary. E.g. in places where `@const` can be used:
```diff
<!-- prettier-ignore -->
```svelte
{#each items as item}
- <svelte:component this={item.condition ? Y : Z} />
+ {@const Component = item.condition ? Y : Z}
+ <Component />
---<svelte:component this={item.condition ? Y : Z} />---
+++{@const Component = item.condition ? Y : Z}+++
+++<Component />+++
{/each}
```
A derived value may be used in other contexts:
```diff
<!-- prettier-ignore -->
```svelte
<script>
...
// ...
let condition = $state(false);
+ const Component = $derived(condition ? Y : Z);
+++const Component = $derived(condition ? Y : Z);+++
</script>
- <svelte:component this={condition ? Y : Z} />
+ <Component />
---<svelte:component this={condition ? Y : Z} />---
+++<Component />+++
```
### svelte_element_invalid_this

@ -74,24 +74,27 @@ In some cases `<object.property>` syntax can be used as a replacement; a lowerca
For complex component resolution logic, an intermediary, capitalized variable may be necessary. E.g. in places where `@const` can be used:
```diff
<!-- prettier-ignore -->
```svelte
{#each items as item}
- <svelte:component this={item.condition ? Y : Z} />
+ {@const Component = item.condition ? Y : Z}
+ <Component />
---<svelte:component this={item.condition ? Y : Z} />---
+++{@const Component = item.condition ? Y : Z}+++
+++<Component />+++
{/each}
```
A derived value may be used in other contexts:
```diff
<!-- prettier-ignore -->
```svelte
<script>
...
// ...
let condition = $state(false);
+ const Component = $derived(condition ? Y : Z);
+++const Component = $derived(condition ? Y : Z);+++
</script>
- <svelte:component this={condition ? Y : Z} />
+ <Component />
---<svelte:component this={condition ? Y : Z} />---
+++<Component />+++
```
## svelte_element_invalid_this

Loading…
Cancel
Save