|
|
|
@ -80,15 +80,12 @@ export function set_data_dev(text, data) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function validate_each_argument(arg) {
|
|
|
|
|
if (arg instanceof Set || arg instanceof Map) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Svelte does not allow Sets or Maps in an {#each} block. Use [...arg.values()] or [...arg.entries()] instead.`
|
|
|
|
|
);
|
|
|
|
|
if (!arg || !('length' in arg)) {
|
|
|
|
|
let msg = '{#each} only iterates over array-like objects.';
|
|
|
|
|
if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {
|
|
|
|
|
msg += ' You can use a spread to convert this iterable into an array.';
|
|
|
|
|
}
|
|
|
|
|
if (arg.length === undefined) {
|
|
|
|
|
throw new Error(
|
|
|
|
|
`Svelte needs an array-like value for the {#each} block. You can spread your iterable into an array instead, e.g. [...iterable]`
|
|
|
|
|
);
|
|
|
|
|
throw new Error(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|