diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js index 97cb057cc5..c0d06bf928 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js @@ -7,8 +7,7 @@ import { EACH_IS_ANIMATED, EACH_IS_CONTROLLED, EACH_ITEM_IMMUTABLE, - EACH_ITEM_REACTIVE, - EACH_KEYED + EACH_ITEM_REACTIVE } from '../../../../../constants.js'; import { dev } from '../../../../state.js'; import { extract_paths, object } from '../../../../utils/ast.js'; @@ -42,12 +41,8 @@ export function EachBlock(node, context) { let flags = 0; - if (node.metadata.keyed) { - flags |= EACH_KEYED; - - if (node.index) { - flags |= EACH_INDEX_REACTIVE; - } + if (node.metadata.keyed && node.index) { + flags |= EACH_INDEX_REACTIVE; } const key_is_item = @@ -252,7 +247,7 @@ export function EachBlock(node, context) { declarations.push(b.let(node.index, index)); } - if (dev && (flags & EACH_KEYED) !== 0) { + if (dev && node.metadata.keyed) { context.state.init.push( b.stmt(b.call('$.validate_each_keys', b.thunk(collection), key_function)) ); diff --git a/packages/svelte/src/constants.js b/packages/svelte/src/constants.js index f66c99e5c7..03fddc5ebd 100644 --- a/packages/svelte/src/constants.js +++ b/packages/svelte/src/constants.js @@ -1,11 +1,9 @@ export const EACH_ITEM_REACTIVE = 1; export const EACH_INDEX_REACTIVE = 1 << 1; -export const EACH_KEYED = 1 << 2; - /** See EachBlock interface metadata.is_controlled for an explanation what this is */ -export const EACH_IS_CONTROLLED = 1 << 3; -export const EACH_IS_ANIMATED = 1 << 4; -export const EACH_ITEM_IMMUTABLE = 1 << 5; +export const EACH_IS_CONTROLLED = 1 << 2; +export const EACH_IS_ANIMATED = 1 << 3; +export const EACH_ITEM_IMMUTABLE = 1 << 4; export const PROPS_IS_IMMUTABLE = 1; export const PROPS_IS_RUNES = 1 << 1;