fix: ensure inline object literals are correctly serialised

inline-expression-fix
Dominic Gannaway 9 hours ago
parent 95ab85fad7
commit 24bf1af832

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure inline object literals are correctly serialised

@ -184,6 +184,9 @@ 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;
}
const left = object(node);
if (!left) return false;

@ -0,0 +1,10 @@
import { test } from '../../test';
export default test({
html: `
<p>Without text expression: 7.36</p>
<p>With text expression: 7.36</p>
<p>With text expression and function call: 7.36</p>
<p>With text expression and property access: 4</p>
<p>4</p>`
});

@ -0,0 +1,5 @@
<p>Without text expression: 7.36</p>
<p>With text expression: {7.36}</p>
<p>With text expression and function call: {(7.36).toLocaleString()}</p>
<p>With text expression and property access: {"test".length}</p>
<p>{"test".length}</p>
Loading…
Cancel
Save