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
fix: spread as a dependency for every prop #11290
Closed
paoloricciuti
wants to merge
16
commits into
sveltejs:main
from
paoloricciuti:fix-spread-registering-dep
Closed
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
573e567
fix: spread as a dependency for every prop
paoloricciuti 27321f7
feat: implement subscribing to derived of keys instead of the whole o…
paoloricciuti c30b988
fix: change signature of spread_props
paoloricciuti 2a4a29f
fix: conditionally call keys_function
paoloricciuti 46d8f1a
Merge remote-tracking branch 'upstream/main' into fix-spread-register…
paoloricciuti ee05a3c
fix: wrong transformation for slot elements
paoloricciuti 214f899
Merge remote-tracking branch 'upstream/main' into fix-spread-register…
paoloricciuti db9398b
chore: swap `instance of Function` for `is_function`
paoloricciuti 5acbfce
chore: add tests
paoloricciuti 04d159b
chore: fix some coding style
paoloricciuti 77a955c
chore: apply better coding style to other trap
paoloricciuti ce1b12b
Merge branch 'main' into pr/11290
Rich-Harris 95eb851
rewrite
Rich-Harris ace9dcd
simplify test
Rich-Harris 5ec31ee
tweak
Rich-Harris 1c20bf3
shut up typescript
Rich-Harris File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
packages/svelte/tests/runtime-runes/samples/fine-grained-spreading-dep/Test.svelte
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script> | ||
let { about, ...rest } = $props(); | ||
|
||
$effect(()=>{ | ||
console.log(about); | ||
}) | ||
</script> |
71 changes: 71 additions & 0 deletions
71
packages/svelte/tests/runtime-runes/samples/fine-grained-spreading-dep/_config.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
// The component context class instance gets shared between tests, strangely, causing hydration to fail? | ||
|
||
async test({ assert, target, logs }) { | ||
/** | ||
* @type {HTMLButtonElement | null} | ||
*/ | ||
const no_keys_change = target.querySelector('#no-keys-change'); | ||
/** | ||
* @type {HTMLButtonElement | null} | ||
*/ | ||
const keys_change = target.querySelector('#keys-change'); | ||
/** | ||
* @type {HTMLButtonElement | null} | ||
*/ | ||
const no_keys_change_assign = target.querySelector('#no-keys-change-assign'); | ||
/** | ||
* @type {HTMLButtonElement | null} | ||
*/ | ||
const keys_change_assign = target.querySelector('#keys-change-assign'); | ||
/** | ||
* @type {HTMLButtonElement | null} | ||
*/ | ||
const keys_change_override = target.querySelector('#keys-change-override'); | ||
/** | ||
* @type {HTMLButtonElement | null} | ||
*/ | ||
const change_override_assign = target.querySelector('#change-override-assign'); | ||
|
||
assert.deepEqual(logs, ['something']); | ||
|
||
flushSync(() => { | ||
no_keys_change?.click(); | ||
}); | ||
|
||
assert.deepEqual(logs, ['something']); | ||
|
||
flushSync(() => { | ||
keys_change?.click(); | ||
}); | ||
|
||
assert.deepEqual(logs, ['something', 'something']); | ||
|
||
flushSync(() => { | ||
no_keys_change_assign?.click(); | ||
}); | ||
|
||
assert.deepEqual(logs, ['something', 'something']); | ||
|
||
flushSync(() => { | ||
keys_change_assign?.click(); | ||
}); | ||
|
||
assert.deepEqual(logs, ['something', 'something', 'something']); | ||
|
||
flushSync(() => { | ||
keys_change_override?.click(); | ||
}); | ||
|
||
assert.deepEqual(logs, ['something', 'something', 'something', 'else']); | ||
|
||
flushSync(() => { | ||
change_override_assign?.click(); | ||
}); | ||
|
||
assert.deepEqual(logs, ['something', 'something', 'something', 'else', 'another']); | ||
} | ||
}); |
31 changes: 31 additions & 0 deletions
31
packages/svelte/tests/runtime-runes/samples/fine-grained-spreading-dep/main.svelte
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts"> | ||
import Test from "./Test.svelte"; | ||
let rest = $state({}); | ||
</script> | ||
|
||
<button id="no-keys-change" onclick={()=>{ | ||
rest = {}; | ||
}}></button> | ||
|
||
<button id="keys-change" onclick={()=>{ | ||
rest = { foo: 1 }; | ||
}}></button> | ||
|
||
<button id="no-keys-change-assign" onclick={()=>{ | ||
rest.foo = 1; | ||
}}></button> | ||
|
||
<button id="keys-change-assign" onclick={()=>{ | ||
rest.bar = 1; | ||
}}></button> | ||
|
||
<button id="keys-change-override" onclick={()=>{ | ||
rest = {about: "else"}; | ||
}}></button> | ||
|
||
<button id="change-override-assign" onclick={()=>{ | ||
rest.about = "another"; | ||
}}></button> | ||
|
||
|
||
<Test about="something" {...rest}></Test> |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this stuff is unnecessary! we can create the derived inside
spread_props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duh 🤦🏻♂️ completely missed this