Skip to content

Commit 7d697d9

Browse files
Apply suggestions from code review
Co-authored-by: Simon H <[email protected]>
1 parent 696bb2e commit 7d697d9

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

.changeset/selfish-onions-begin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
'svelte': minor
33
---
44

5-
feat: partial evaluation
5+
feat: partially evaluate certain expressions

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,6 @@ function build_element_special_value_attribute(element, node_id, attribute, cont
686686
);
687687

688688
const evaluated = context.state.scope.evaluate(value);
689-
690689
const assignment = b.assignment('=', b.member(node_id, '__value'), value);
691690

692691
const inner_assignment = b.assignment(

packages/svelte/src/compiler/phases/scope.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { determine_slot } from '../utils/slot.js';
1717
import { validate_identifier_name } from './2-analyze/visitors/shared/utils.js';
1818

1919
export const UNKNOWN = Symbol('unknown');
20-
export const NUMBER = Symbol('number'); // includes BigInt
20+
/** Includes `BigInt` */
21+
export const NUMBER = Symbol('number');
2122
export const STRING = Symbol('string');
2223

2324
export class Binding {
@@ -540,7 +541,9 @@ export class Scope {
540541
}
541542

542543
/**
543-
*
544+
* Does partial evaluation to find an exact value or at least the rough type of the expression.
545+
* Only call this once scope has been fully generated in a first pass,
546+
* else this evaluates on incomplete data and may yield wrong results.
544547
* @param {Expression} expression
545548
* @param {Set<any>} values
546549
*/

0 commit comments

Comments
 (0)