Skip to content

[WIP] implement bitmask-based change tracking #1943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions test/js/samples/collapses-text-around-comments/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
if (changed.foo) {
setData(text, ctx.foo);
}
p(ctx) {
setData(text, ctx.foo);
},

i(target, anchor) {
Expand All @@ -49,7 +47,7 @@ function instance($$self, $$props, $$invalidate) {
let { foo = 42 } = $$props;

$$self.$set = $$props => {
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
if ('foo' in $$props) $$invalidate('foo', 0, foo = $$props.foo);
};

return { foo };
Expand Down
8 changes: 3 additions & 5 deletions test/js/samples/debug-empty/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ function create_fragment($$, ctx) {
current = true;
},

p: function update(changed, ctx) {
if (changed.name) {
setData(text1, ctx.name);
}
p: function update(ctx) {
setData(text1, ctx.name);

debugger;
},
Expand All @@ -58,7 +56,7 @@ function instance($$self, $$props, $$invalidate) {
let { name } = $$props;

$$self.$set = $$props => {
if ('name' in $$props) $$invalidate('name', name = $$props.name);
if ('name' in $$props) $$invalidate('name', 0, name = $$props.name);
};

return { name };
Expand Down
20 changes: 10 additions & 10 deletions test/js/samples/debug-foo-bar-baz-things/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function create_each_block($$, ctx) {
insert(target, text1, anchor);
},

p: function update(changed, ctx) {
if ((changed.things) && text0_value !== (text0_value = ctx.thing.name)) {
p: function update(ctx, changed) {
if ((changed & /*things*/1) && text0_value !== (text0_value = ctx.thing.name)) {
setData(text0, text0_value);
}

if (changed.foo || changed.bar || changed.baz || changed.things) {
if (changed & /*foo, bar, baz or things*/15) {
const { foo, bar, baz, thing } = ctx;
console.log({ foo, bar, baz, thing });
debugger;
Expand Down Expand Up @@ -94,8 +94,8 @@ function create_fragment($$, ctx) {
current = true;
},

p: function update(changed, ctx) {
if (changed.things) {
p: function update(ctx, changed) {
if (changed & /*things*/1) {
each_value = ctx.things;

for (var i = 0; i < each_value.length; i += 1) {
Expand All @@ -116,7 +116,7 @@ function create_fragment($$, ctx) {
each_blocks.length = each_value.length;
}

if (changed.foo) {
if (changed & /*foo*/2) {
setData(text2, ctx.foo);
}
},
Expand All @@ -143,10 +143,10 @@ function instance($$self, $$props, $$invalidate) {
let { things, foo, bar, baz } = $$props;

$$self.$set = $$props => {
if ('things' in $$props) $$invalidate('things', things = $$props.things);
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar);
if ('baz' in $$props) $$invalidate('baz', baz = $$props.baz);
if ('things' in $$props) $$invalidate('things', 0, things = $$props.things);
if ('foo' in $$props) $$invalidate('foo', 1, foo = $$props.foo);
if ('bar' in $$props) $$invalidate('bar', 2, bar = $$props.bar);
if ('baz' in $$props) $$invalidate('baz', 3, baz = $$props.baz);
};

return { things, foo, bar, baz };
Expand Down
18 changes: 9 additions & 9 deletions test/js/samples/debug-foo/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function create_each_block($$, ctx) {
insert(target, text1, anchor);
},

p: function update(changed, ctx) {
if ((changed.things) && text0_value !== (text0_value = ctx.thing.name)) {
p: function update(ctx, changed) {
if ((changed & /*things*/1) && text0_value !== (text0_value = ctx.thing.name)) {
setData(text0, text0_value);
}

if (changed.foo) {
if (changed & /*foo*/2) {
const { foo } = ctx;
console.log({ foo });
debugger;
Expand Down Expand Up @@ -94,15 +94,15 @@ function create_fragment($$, ctx) {
current = true;
},

p: function update(changed, ctx) {
if (changed.things) {
p: function update(ctx, changed) {
if (changed & /*things*/1) {
each_value = ctx.things;

for (var i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);

if (each_blocks[i]) {
each_blocks[i].p(changed, child_ctx);
each_blocks[i].p(child_ctx, changed);
} else {
each_blocks[i] = create_each_block($$, child_ctx);
each_blocks[i].c();
Expand All @@ -116,7 +116,7 @@ function create_fragment($$, ctx) {
each_blocks.length = each_value.length;
}

if (changed.foo) {
if (changed & /*foo*/2) {
setData(text2, ctx.foo);
}
},
Expand All @@ -143,8 +143,8 @@ function instance($$self, $$props, $$invalidate) {
let { things, foo } = $$props;

$$self.$set = $$props => {
if ('things' in $$props) $$invalidate('things', things = $$props.things);
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
if ('things' in $$props) $$invalidate('things', 0, things = $$props.things);
if ('foo' in $$props) $$invalidate('foo', 1, foo = $$props.foo);
};

return { things, foo };
Expand Down
34 changes: 16 additions & 18 deletions test/js/samples/deconflict-builtins/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function create_each_block($$, ctx) {
append(span, text);
},

p(changed, ctx) {
if ((changed.createElement) && text_value !== (text_value = ctx.node)) {
p(ctx) {
if (text_value !== (text_value = ctx.node)) {
setData(text, text_value);
}
},
Expand Down Expand Up @@ -65,27 +65,25 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
if (changed.createElement) {
each_value = ctx.createElement;
p(ctx) {
each_value = ctx.createElement;

for (var i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);
for (var i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);

if (each_blocks[i]) {
each_blocks[i].p(changed, child_ctx);
} else {
each_blocks[i] = create_each_block($$, child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_anchor.parentNode, each_anchor);
}
if (each_blocks[i]) {
each_blocks[i].p(child_ctx);
} else {
each_blocks[i] = create_each_block($$, child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_anchor.parentNode, each_anchor);
}
}

for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
},

i(target, anchor) {
Expand Down
14 changes: 7 additions & 7 deletions test/js/samples/dev-warning-missing-data-computed/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ function create_fragment($$, ctx) {
current = true;
},

p: function update(changed, ctx) {
if ((changed.foo) && text0_value !== (text0_value = Math.max(0, ctx.foo))) {
p: function update(ctx, changed) {
if ((changed & /*foo*/1) && text0_value !== (text0_value = Math.max(0, ctx.foo))) {
setData(text0, text0_value);
}

if (changed.bar) {
if (changed & /*bar*/2) {
setData(text2, ctx.bar);
}
},
Expand All @@ -58,12 +58,12 @@ function instance($$self, $$props, $$invalidate) {
let bar;

$$self.$set = $$props => {
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
if ('foo' in $$props) $$invalidate('foo', 0, foo = $$props.foo);
};

$$self.$$.update = ($$dirty = { foo: 1 }) => {
if ($$dirty.foo) {
bar = foo * 2; $$invalidate('bar', bar);
$$self.$$.update = ($$dirty = -1) => {
if ($$dirty & /*foo*/1) {
bar = foo * 2; $$invalidate('bar', 1, bar);
}
};

Expand Down
8 changes: 3 additions & 5 deletions test/js/samples/do-use-dataset/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
if (changed.bar) {
div1.dataset.foo = ctx.bar;
}
p(ctx) {
div1.dataset.foo = ctx.bar;
},

i(target, anchor) {
Expand All @@ -47,7 +45,7 @@ function instance($$self, $$props, $$invalidate) {
let { bar } = $$props;

$$self.$set = $$props => {
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar);
if ('bar' in $$props) $$invalidate('bar', 0, bar = $$props.bar);
};

return { bar };
Expand Down
6 changes: 2 additions & 4 deletions test/js/samples/dont-use-dataset-in-legacy/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
if (changed.bar) {
setAttribute(div1, "data-foo", ctx.bar);
}
p(ctx) {
setAttribute(div1, "data-foo", ctx.bar);
},

i(target, anchor) {
Expand Down
8 changes: 3 additions & 5 deletions test/js/samples/dont-use-dataset-in-svg/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
if (changed.bar) {
setAttribute(g1, "data-foo", ctx.bar);
}
p(ctx) {
setAttribute(g1, "data-foo", ctx.bar);
},

i(target, anchor) {
Expand All @@ -45,7 +43,7 @@ function instance($$self, $$props, $$invalidate) {
let { bar } = $$props;

$$self.$set = $$props => {
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar);
if ('bar' in $$props) $$invalidate('bar', 0, bar = $$props.bar);
};

return { bar };
Expand Down
24 changes: 12 additions & 12 deletions test/js/samples/each-block-changed-check/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ function create_each_block($$, ctx) {
raw_before.insertAdjacentHTML("afterend", raw_value);
},

p(changed, ctx) {
if ((changed.comments) && text2_value !== (text2_value = ctx.comment.author)) {
p(ctx, changed) {
if ((changed & /*comments*/1) && text2_value !== (text2_value = ctx.comment.author)) {
setData(text2, text2_value);
}

if ((changed.elapsed || changed.comments || changed.time) && text4_value !== (text4_value = ctx.elapsed(ctx.comment.time, ctx.time))) {
if ((changed & /*elapsed, comments or time*/ 7) && text4_value !== (text4_value = ctx.elapsed(ctx.comment.time, ctx.time))) {
setData(text4, text4_value);
}

if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) {
if ((changed & /*comments*/1) && raw_value !== (raw_value = ctx.comment.html)) {
detachAfter(raw_before);
raw_before.insertAdjacentHTML("afterend", raw_value);
}
Expand Down Expand Up @@ -100,15 +100,15 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
if (changed.comments || changed.elapsed || changed.time) {
p(ctx, changed) {
if (changed & /*elapsed, comments or time*/ 7) {
each_value = ctx.comments;

for (var i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);

if (each_blocks[i]) {
each_blocks[i].p(changed, child_ctx);
each_blocks[i].p(child_ctx, changed);
} else {
each_blocks[i] = create_each_block($$, child_ctx);
each_blocks[i].c();
Expand All @@ -122,7 +122,7 @@ function create_fragment($$, ctx) {
each_blocks.length = each_value.length;
}

if (changed.foo) {
if (changed & /*foo*/8) {
setData(text1, ctx.foo);
}
},
Expand All @@ -149,10 +149,10 @@ function instance($$self, $$props, $$invalidate) {
let { comments, elapsed, time, foo } = $$props;

$$self.$set = $$props => {
if ('comments' in $$props) $$invalidate('comments', comments = $$props.comments);
if ('elapsed' in $$props) $$invalidate('elapsed', elapsed = $$props.elapsed);
if ('time' in $$props) $$invalidate('time', time = $$props.time);
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
if ('comments' in $$props) $$invalidate('comments', 0, comments = $$props.comments);
if ('elapsed' in $$props) $$invalidate('elapsed', 1, elapsed = $$props.elapsed);
if ('time' in $$props) $$invalidate('time', 2, time = $$props.time);
if ('foo' in $$props) $$invalidate('foo', 3, foo = $$props.foo);
};

return { comments, elapsed, time, foo };
Expand Down
10 changes: 5 additions & 5 deletions test/js/samples/each-block-keyed-animated/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function create_each_block($$, key_1, ctx) {
append(div, text);
},

p(changed, ctx) {
if ((changed.things) && text_value !== (text_value = ctx.thing.name)) {
p(ctx) {
if (text_value !== (text_value = ctx.thing.name)) {
setData(text, text_value);
}
},
Expand Down Expand Up @@ -82,10 +82,10 @@ function create_fragment($$, ctx) {
current = true;
},

p(changed, ctx) {
p(ctx) {
const each_value = ctx.things;
for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].r();
each_blocks_1 = updateKeyedEach(each_blocks_1, $$, changed, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, fixAndOutroAndDestroyBlock, create_each_block, "m", each_anchor, get_each_context);
each_blocks_1 = updateKeyedEach(each_blocks_1, $$, 0, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, fixAndOutroAndDestroyBlock, create_each_block, "m", each_anchor, get_each_context);
for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].a();
},

Expand Down Expand Up @@ -124,7 +124,7 @@ function instance($$self, $$props, $$invalidate) {
let { things } = $$props;

$$self.$set = $$props => {
if ('things' in $$props) $$invalidate('things', things = $$props.things);
if ('things' in $$props) $$invalidate('things', 0, things = $$props.things);
};

return { things };
Expand Down
Loading