state-onchange-roots
Rich Harris 5 months ago
parent df3779dc86
commit eee51c486e

@ -267,12 +267,17 @@ export function create_proxy(value, onchanges) {
var s = sources.get(prop); var s = sources.get(prop);
var has = prop in target; var has = prop in target;
if (is_proxied_array && prop === 'length') { // bail if nothing changed
batching = true; if (s ? s.v === value : target[prop] === value) {
return true;
} }
// variable.length = value -> clear all signals with index >= value var is_length_change = is_proxied_array && prop === 'length';
if (is_proxied_array && prop === 'length') {
if (is_length_change) {
batching = true;
// variable.length = value -> clear all signals with index >= value
for (var i = value; i < /** @type {Source<number>} */ (s).v; i += 1) { for (var i = value; i < /** @type {Source<number>} */ (s).v; i += 1) {
var other_s = sources.get(i + ''); var other_s = sources.get(i + '');
if (other_s !== undefined) { if (other_s !== undefined) {
@ -316,7 +321,7 @@ export function create_proxy(value, onchanges) {
); );
} }
if (is_proxied_array && prop === 'length') { if (is_length_change) {
batching = false; batching = false;
} }

Loading…
Cancel
Save