From 6ea44e057910472e3840d21a7be30efb4bfccebd Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 16 Nov 2024 11:16:19 -0500 Subject: [PATCH] Apply suggestions from code review --- .changeset/wicked-readers-knock.md | 2 +- .../src/compiler/phases/2-analyze/visitors/shared/utils.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.changeset/wicked-readers-knock.md b/.changeset/wicked-readers-knock.md index fd828b003c..4ec417402f 100644 --- a/.changeset/wicked-readers-knock.md +++ b/.changeset/wicked-readers-knock.md @@ -2,4 +2,4 @@ 'svelte': patch --- -fix: ensure inline object literals are correctly serialised +fix: treat property accesses of literals as pure diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js index 0c297bb203..3dd5fafb95 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js @@ -184,6 +184,7 @@ export function is_pure(node, context) { if (node.type !== 'Identifier' && node.type !== 'MemberExpression') { return false; } + if (node.type === 'MemberExpression' && node.object.type === 'Literal') { return true; }