|
|
@ -7,7 +7,13 @@ import {
|
|
|
|
} from './hydration.js';
|
|
|
|
} from './hydration.js';
|
|
|
|
import { is_array } from './utils.js';
|
|
|
|
import { is_array } from './utils.js';
|
|
|
|
import { each_item_block, destroy_each_item_block, update_each_item_block } from './render.js';
|
|
|
|
import { each_item_block, destroy_each_item_block, update_each_item_block } from './render.js';
|
|
|
|
import { EACH_INDEX_REACTIVE, EACH_IS_ANIMATED, EACH_ITEM_REACTIVE } from '../../constants.js';
|
|
|
|
import {
|
|
|
|
|
|
|
|
EACH_INDEX_REACTIVE,
|
|
|
|
|
|
|
|
EACH_IS_ANIMATED,
|
|
|
|
|
|
|
|
EACH_IS_PROXIED,
|
|
|
|
|
|
|
|
EACH_ITEM_REACTIVE
|
|
|
|
|
|
|
|
} from '../../constants.js';
|
|
|
|
|
|
|
|
import { MAGIC_SYMBOL } from './magic.js';
|
|
|
|
|
|
|
|
|
|
|
|
const NEW_BLOCK = -1;
|
|
|
|
const NEW_BLOCK = -1;
|
|
|
|
const MOVED_BLOCK = 99999999;
|
|
|
|
const MOVED_BLOCK = 99999999;
|
|
|
@ -177,9 +183,17 @@ export function reconcile_indexed_array(
|
|
|
|
flags,
|
|
|
|
flags,
|
|
|
|
apply_transitions
|
|
|
|
apply_transitions
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
var is_proxied_array = MAGIC_SYMBOL in array;
|
|
|
|
var a_blocks = each_block.v;
|
|
|
|
var a_blocks = each_block.v;
|
|
|
|
var active_transitions = each_block.s;
|
|
|
|
var active_transitions = each_block.s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_proxied_array) {
|
|
|
|
|
|
|
|
if ((flags & EACH_ITEM_REACTIVE) !== 0) {
|
|
|
|
|
|
|
|
flags ^= EACH_ITEM_REACTIVE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
flags |= EACH_IS_PROXIED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {number | void} */
|
|
|
|
/** @type {number | void} */
|
|
|
|
var a = a_blocks.length;
|
|
|
|
var a = a_blocks.length;
|
|
|
|
|
|
|
|
|
|
|
@ -220,7 +234,7 @@ export function reconcile_indexed_array(
|
|
|
|
hydrating_node = /** @type {Node} */ (
|
|
|
|
hydrating_node = /** @type {Node} */ (
|
|
|
|
/** @type {Node} */ (/** @type {Node} */ (fragment.at(-1)).nextSibling).nextSibling
|
|
|
|
/** @type {Node} */ (/** @type {Node} */ (fragment.at(-1)).nextSibling).nextSibling
|
|
|
|
);
|
|
|
|
);
|
|
|
|
block = each_item_block(item, null, index, render_fn, flags);
|
|
|
|
block = each_item_block(array, item, null, index, render_fn, flags);
|
|
|
|
b_blocks[index] = block;
|
|
|
|
b_blocks[index] = block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -228,7 +242,7 @@ export function reconcile_indexed_array(
|
|
|
|
if (index >= a) {
|
|
|
|
if (index >= a) {
|
|
|
|
// Add block
|
|
|
|
// Add block
|
|
|
|
item = array[index];
|
|
|
|
item = array[index];
|
|
|
|
block = each_item_block(item, null, index, render_fn, flags);
|
|
|
|
block = each_item_block(array, item, null, index, render_fn, flags);
|
|
|
|
b_blocks[index] = block;
|
|
|
|
b_blocks[index] = block;
|
|
|
|
insert_each_item_block(block, dom, is_controlled, null);
|
|
|
|
insert_each_item_block(block, dom, is_controlled, null);
|
|
|
|
} else if (index >= b) {
|
|
|
|
} else if (index >= b) {
|
|
|
@ -277,8 +291,16 @@ export function reconcile_tracked_array(
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
var a_blocks = each_block.v;
|
|
|
|
var a_blocks = each_block.v;
|
|
|
|
const is_computed_key = keys !== null;
|
|
|
|
const is_computed_key = keys !== null;
|
|
|
|
|
|
|
|
var is_proxied_array = MAGIC_SYMBOL in array;
|
|
|
|
var active_transitions = each_block.s;
|
|
|
|
var active_transitions = each_block.s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_proxied_array) {
|
|
|
|
|
|
|
|
if ((flags & EACH_ITEM_REACTIVE) !== 0) {
|
|
|
|
|
|
|
|
flags ^= EACH_ITEM_REACTIVE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
flags |= EACH_IS_PROXIED;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {number | void} */
|
|
|
|
/** @type {number | void} */
|
|
|
|
var a = a_blocks.length;
|
|
|
|
var a = a_blocks.length;
|
|
|
|
|
|
|
|
|
|
|
@ -327,7 +349,7 @@ export function reconcile_tracked_array(
|
|
|
|
hydrating_node = /** @type {Node} */ (
|
|
|
|
hydrating_node = /** @type {Node} */ (
|
|
|
|
/** @type {Node} */ ((fragment.at(-1) || hydrating_node).nextSibling).nextSibling
|
|
|
|
/** @type {Node} */ ((fragment.at(-1) || hydrating_node).nextSibling).nextSibling
|
|
|
|
);
|
|
|
|
);
|
|
|
|
block = each_item_block(item, key, idx, render_fn, flags);
|
|
|
|
block = each_item_block(array, item, key, idx, render_fn, flags);
|
|
|
|
b_blocks[idx] = block;
|
|
|
|
b_blocks[idx] = block;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (a === 0) {
|
|
|
|
} else if (a === 0) {
|
|
|
@ -336,7 +358,7 @@ export function reconcile_tracked_array(
|
|
|
|
idx = b_end - --b;
|
|
|
|
idx = b_end - --b;
|
|
|
|
item = array[idx];
|
|
|
|
item = array[idx];
|
|
|
|
key = is_computed_key ? keys[idx] : item;
|
|
|
|
key = is_computed_key ? keys[idx] : item;
|
|
|
|
block = each_item_block(item, key, idx, render_fn, flags);
|
|
|
|
block = each_item_block(array, item, key, idx, render_fn, flags);
|
|
|
|
b_blocks[idx] = block;
|
|
|
|
b_blocks[idx] = block;
|
|
|
|
insert_each_item_block(block, dom, is_controlled, null);
|
|
|
|
insert_each_item_block(block, dom, is_controlled, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -384,7 +406,7 @@ export function reconcile_tracked_array(
|
|
|
|
while (b_end >= start) {
|
|
|
|
while (b_end >= start) {
|
|
|
|
item = array[b_end];
|
|
|
|
item = array[b_end];
|
|
|
|
key = is_computed_key ? keys[b_end] : item;
|
|
|
|
key = is_computed_key ? keys[b_end] : item;
|
|
|
|
block = each_item_block(item, key, b_end, render_fn, flags);
|
|
|
|
block = each_item_block(array, item, key, b_end, render_fn, flags);
|
|
|
|
b_blocks[b_end--] = block;
|
|
|
|
b_blocks[b_end--] = block;
|
|
|
|
sibling = insert_each_item_block(block, dom, is_controlled, sibling);
|
|
|
|
sibling = insert_each_item_block(block, dom, is_controlled, sibling);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -446,7 +468,7 @@ export function reconcile_tracked_array(
|
|
|
|
item = array[b_end];
|
|
|
|
item = array[b_end];
|
|
|
|
if (should_create) {
|
|
|
|
if (should_create) {
|
|
|
|
key = is_computed_key ? keys[b_end] : item;
|
|
|
|
key = is_computed_key ? keys[b_end] : item;
|
|
|
|
block = each_item_block(item, key, b_end, render_fn, flags);
|
|
|
|
block = each_item_block(array, item, key, b_end, render_fn, flags);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
block = b_blocks[b_end];
|
|
|
|
block = b_blocks[b_end];
|
|
|
|
if (!is_animated && should_update_block) {
|
|
|
|
if (!is_animated && should_update_block) {
|
|
|
|