mirror of https://github.com/sveltejs/svelte
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 commentspull/9293/head
parent
c1b7262248
commit
6b9b8af050
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ignore trailing comments when comparing nodes
|
@ -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>
|
@ -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');
|
||||
}
|
||||
};
|
@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import SomeComponent from './SomeComponent.svelte';
|
||||
let objectProp = ['name', 'age'];
|
||||
|
||||
// look in SomeComponent.svelte for explaination
|
||||
</script>
|
||||
|
||||
<SomeComponent {objectProp} />
|
Loading…
Reference in new issue