From 466fba19e69e1488e2b7ac09ed7d83eda2b76522 Mon Sep 17 00:00:00 2001 From: razinshafayet Date: Wed, 10 Dec 2025 16:41:34 +0600 Subject: [PATCH 1/2] docs: update #each to reflect support for null and undefined --- documentation/docs/03-template-syntax/03-each.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/03-template-syntax/03-each.md b/documentation/docs/03-template-syntax/03-each.md index 006cadd15257..d1a6023f159d 100644 --- a/documentation/docs/03-template-syntax/03-each.md +++ b/documentation/docs/03-template-syntax/03-each.md @@ -12,7 +12,7 @@ title: {#each ...} {#each expression as name, index}...{/each} ``` -Iterating over values can be done with an each block. The values in question can be arrays, array-like objects (i.e. anything with a `length` property), or iterables like `Map` and `Set` — in other words, anything that can be used with `Array.from`. +Iterating over values can be done with an each block. The values in question can be arrays, array-like objects (i.e. anything with a `length` property), or iterables like `Map` and `Set`. If the value is `null` or `undefined`, the block is skipped. ```svelte

Shopping list

From e2f2933ab1dadccf7e93d1f8c3ef4b39fcecb855 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 10 Dec 2025 19:30:36 -0500 Subject: [PATCH 2/2] update --- documentation/docs/03-template-syntax/03-each.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/docs/03-template-syntax/03-each.md b/documentation/docs/03-template-syntax/03-each.md index d1a6023f159d..57ed0def71c2 100644 --- a/documentation/docs/03-template-syntax/03-each.md +++ b/documentation/docs/03-template-syntax/03-each.md @@ -12,7 +12,9 @@ title: {#each ...} {#each expression as name, index}...{/each} ``` -Iterating over values can be done with an each block. The values in question can be arrays, array-like objects (i.e. anything with a `length` property), or iterables like `Map` and `Set`. If the value is `null` or `undefined`, the block is skipped. +Iterating over values can be done with an each block. The values in question can be arrays, array-like objects (i.e. anything with a `length` property), or iterables like `Map` and `Set`— in other words, anything that can be used with `Array.from`. + +If the value is `null` or `undefined`, it is treated the same as an empty array (which will cause [else blocks](#Else-blocks) to be rendered, where applicable). ```svelte

Shopping list