explain each_item_block stuff

pull/10798/head
Rich Harris 2 years ago
parent bdcd25ed87
commit d102d4ebf1

@ -65,12 +65,18 @@ export function element(anchor, get_tag, is_svg, render_fn) {
/** @type {import('#client').Effect | null} */ /** @type {import('#client').Effect | null} */
let effect; let effect;
/**
* The keyed `{#each ...}` item block, if any, that this element is inside.
* We track this so we can set it when changing the element, allowing any
* `animate:` directive to bind itself to the correct block
*/
let each_item_block = current_each_item_block; let each_item_block = current_each_item_block;
const wrapper = render_effect(() => { const wrapper = render_effect(() => {
const next_tag = get_tag() || null; const next_tag = get_tag() || null;
if (next_tag === tag) return; if (next_tag === tag) return;
// See explanation of `each_item_block` above
var previous_each_item_block = current_each_item_block; var previous_each_item_block = current_each_item_block;
set_current_each_item_block(each_item_block); set_current_each_item_block(each_item_block);

Loading…
Cancel
Save