Skip to content

Commit 82a645f

Browse files
fix: $state.is missing second argument on the server (#11835)
* fix: `$state.is` missing second argument on the server * chore: update test
1 parent 22e2aec commit 82a645f

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

.changeset/dull-donkeys-smell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: `$state.is` missing second argument on the server

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ const javascript_visitors_runes = {
791791
if (rune === '$state.is') {
792792
return b.call(
793793
'Object.is',
794-
/** @type {import('estree').Expression} */ (context.visit(node.arguments[0]))
794+
/** @type {import('estree').Expression} */ (context.visit(node.arguments[0])),
795+
/** @type {import('estree').Expression} */ (context.visit(node.arguments[1]))
795796
);
796797
}
797798

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p>true</p>
2+
<p>true</p>
3+
<p>true</p>
4+
<p>true</p>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script>
2+
const obj = {};
3+
const a = $state(obj)
4+
const b= $state(obj)
5+
</script>
6+
7+
<p>{a === obj}</p>
8+
<p>{$state.is(a, obj)}</p>
9+
<p>{a === b}</p>
10+
<p>{$state.is(a, b)}</p>

0 commit comments

Comments
 (0)