fix dev mode each block validation when using strings (#4451)

pull/4453/head
Conduitry 5 years ago committed by GitHub
parent a972a47e14
commit 138213ca3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,9 @@
# Svelte changelog
## Unreleased
* Fix dev mode validation of `{#each}` blocks using strings ([#4450](https://github.com/sveltejs/svelte/issues/4450))
## 3.19.0
* Fix indirect bindings involving elements with spreads ([#3680](https://github.com/sveltejs/svelte/issues/3680))

@ -80,7 +80,7 @@ export function set_data_dev(text, data) {
}
export function validate_each_argument(arg) {
if (!arg || !('length' in arg)) {
if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && '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.';

@ -0,0 +1,10 @@
export default {
compileOptions: {
dev: true
},
html: `
<div>f</div>
<div>o</div>
<div>o</div>
`
};

@ -0,0 +1,3 @@
{#each 'foo' as c}
<div>{c}</div>
{/each}
Loading…
Cancel
Save