Skip to content

Commit e2b3a53

Browse files
committed
feedback
1 parent af001fb commit e2b3a53

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,26 +1359,25 @@ if (DEV) {
13591359
}
13601360

13611361
/**
1362-
* Expects a value that was wrapped with `freeze` and makes it frozen in DEV or adds a symbol in prod.
1362+
* Expects a value that was wrapped with `freeze` and makes it frozen in DEV.
13631363
* @template T
13641364
* @param {T} value
13651365
* @returns {Readonly<T>}
13661366
*/
13671367
export function freeze(value) {
1368-
if (typeof value === 'object' && value != null && !is_frozen(value)) {
1368+
if (typeof value === 'object' && value != null && !(STATE_FROZEN_SYMBOL in value)) {
13691369
// If the object is already proxified, then snapshot the value
1370-
if (STATE_SYMBOL in value) {
1370+
if (STATE_SYMBOL in value || is_frozen(value)) {
13711371
value = snapshot(value);
13721372
}
1373-
// Freeze the object in DEV, add the symbol in prod
1373+
define_property(value, STATE_FROZEN_SYMBOL, {
1374+
value: true,
1375+
writable: true,
1376+
enumerable: false
1377+
});
1378+
// Freeze the object in DEV
13741379
if (DEV) {
13751380
object_freeze(value);
1376-
} else {
1377-
define_property(value, STATE_FROZEN_SYMBOL, {
1378-
value: true,
1379-
writable: true,
1380-
enumerable: false
1381-
});
13821381
}
13831382
}
13841383
return value;

0 commit comments

Comments
 (0)