Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ function serialize_get_binding(node, state) {
if (binding.kind === 'store_sub') {
const store_id = b.id(node.name.slice(1));
return b.call(
state.options.dev ? '$.store_get_dev' : '$.store_get',
'$.store_get',
b.id('$$store_subs'),
b.literal(node.name),
serialize_get_binding(store_id, state)
Expand Down
17 changes: 5 additions & 12 deletions packages/svelte/src/internal/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as $ from '../client/runtime.js';
import { is_promise, noop } from '../common.js';
import { subscribe_to_store } from '../../store/utils.js';
import { DOMBooleanAttributes } from '../../constants.js';
import { DEV } from 'esm-env';

export * from '../client/validate.js';

Expand Down Expand Up @@ -340,6 +341,10 @@ export function merge_styles(style_attribute, style_directive) {
* @returns {V}
*/
export function store_get(store_values, store_name, store) {
if (DEV) {
validate_store(store, store_name.slice(1));
}

// it could be that someone eagerly updates the store in the instance script, so
// we should only reuse the store value in the template
if (store_name in store_values && store_values[store_name][0] === store) {
Expand All @@ -356,18 +361,6 @@ export function store_get(store_values, store_name, store) {
return store_values[store_name][2];
}

/**
* @template V
* @param {Record<string, [any, any, any]>} store_values
* @param {string} store_name
* @param {import('../client/types.js').Store<V> | null | undefined} store
* @returns {V}
*/
export function store_get_dev(store_values, store_name, store) {
validate_store(store, store_name.slice(1));
return store_get(store_values, store_name, store);
}

/**
* @param {any} store
* @param {string} name
Expand Down