-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ignore comments while comparing nodes in node_match (#9197)
related to issue #9088 it doesn't solve the main problem of dependencies getting invalidated whenever value of a variable gets changed. but it fixes the behavior difference between the code with and without comments
- Loading branch information
1 parent
c1b7262
commit 6b9b8af
Showing
6 changed files
with
46 additions
and
4 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ignore trailing comments when comparing nodes |
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
20 changes: 20 additions & 0 deletions
20
packages/svelte/test/runtime/samples/comment-effect-on-reactivity/SomeComponent.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,20 @@ | ||
<script> | ||
export let objectProp; | ||
let count = 0; | ||
$: objectPropCopy = [...objectProp]; | ||
$: incrementCount(), console.log('propDependencyChanged', objectProp); | ||
const incrementCount = () => { | ||
count++; | ||
}; | ||
const clickAction = () => { | ||
//note that this file shouldn't be formatted and the trailing comment must be rightnext to the variable name | ||
// prettier-ignore | ||
objectPropCopy = objectPropCopy// trailing comment | ||
}; | ||
</script> | ||
|
||
<button on:click={clickAction}>click me!</button> | ||
|
||
{objectPropCopy} | ||
<div id="render-count">{count}</div> |
9 changes: 9 additions & 0 deletions
9
packages/svelte/test/runtime/samples/comment-effect-on-reactivity/_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,9 @@ | ||
export default { | ||
async test({ assert, target, window }) { | ||
const incrementButton = target.querySelector('button'); | ||
|
||
assert.equal(target.querySelector('#render-count').innerHTML, '1'); | ||
await incrementButton.dispatchEvent(new window.MouseEvent('click')); | ||
assert.equal(target.querySelector('#render-count').innerHTML, '2'); | ||
} | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/svelte/test/runtime/samples/comment-effect-on-reactivity/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,8 @@ | ||
<script> | ||
import SomeComponent from './SomeComponent.svelte'; | ||
let objectProp = ['name', 'age']; | ||
// look in SomeComponent.svelte for explaination | ||
</script> | ||
|
||
<SomeComponent {objectProp} /> |