mirror of https://github.com/sveltejs/svelte
fix: leave update expressions untransformed unless a transformer is provided (#14507)
* fix: leave update expressions untransformed unless a transformer is provided * fix more casespull/14529/head
parent
94694a5e63
commit
aac929d503
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: leave update expressions untransformed unless a transformer is provided
|
@ -0,0 +1,15 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: '<button>mutate</button><button>reassign</button><p>0</p>',
|
||||
test({ assert, target }) {
|
||||
const [btn1, btn2] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => btn1.click());
|
||||
assert.htmlEqual(target.innerHTML, '<button>mutate</button><button>reassign</button><p>1</p>');
|
||||
|
||||
flushSync(() => btn2.click());
|
||||
assert.htmlEqual(target.innerHTML, '<button>mutate</button><button>reassign</button><p>0</p>');
|
||||
}
|
||||
});
|
@ -0,0 +1,16 @@
|
||||
<script>
|
||||
let object = $state({ n: 0n });
|
||||
|
||||
function reassign() {
|
||||
object = { n: 0n };
|
||||
}
|
||||
|
||||
function mutate() {
|
||||
return object.n++;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={mutate}>mutate</button>
|
||||
<button onclick={reassign}>reassign</button>
|
||||
|
||||
<p>{object.n}</p>
|
@ -0,0 +1,7 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, logs }) {
|
||||
assert.deepEqual(logs, [0n, 1n, 2n, 3n, 4n, 5n]);
|
||||
}
|
||||
});
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
for (let i = 0n; i <= 5n; i++) {
|
||||
console.log(i);
|
||||
}
|
||||
</script>
|
Loading…
Reference in new issue