Skip to content

Commit 370f051

Browse files
committed
aspirational generated code for #1922
1 parent 3701e0d commit 370f051

File tree

30 files changed

+157
-177
lines changed

30 files changed

+157
-177
lines changed

test/js/samples/collapses-text-around-comments/expected.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ function create_fragment($$, ctx) {
2424
current = true;
2525
},
2626

27-
p(changed, ctx) {
28-
if (changed.foo) {
29-
setData(text, ctx.foo);
30-
}
27+
p(ctx) {
28+
setData(text, ctx.foo);
3129
},
3230

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

5149
$$self.$set = $$props => {
52-
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
50+
if ('foo' in $$props) $$invalidate('foo', 0, foo = $$props.foo);
5351
};
5452

5553
return { foo };

test/js/samples/debug-empty/expected.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ function create_fragment($$, ctx) {
3030
current = true;
3131
},
3232

33-
p: function update(changed, ctx) {
34-
if (changed.name) {
35-
setData(text1, ctx.name);
36-
}
33+
p: function update(ctx) {
34+
setData(text1, ctx.name);
3735

3836
debugger;
3937
},
@@ -58,7 +56,7 @@ function instance($$self, $$props, $$invalidate) {
5856
let { name } = $$props;
5957

6058
$$self.$set = $$props => {
61-
if ('name' in $$props) $$invalidate('name', name = $$props.name);
59+
if ('name' in $$props) $$invalidate('name', 0, name = $$props.name);
6260
};
6361

6462
return { name };

test/js/samples/debug-foo-bar-baz-things/expected.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ function create_each_block($$, ctx) {
3333
insert(target, text1, anchor);
3434
},
3535

36-
p: function update(changed, ctx) {
37-
if ((changed.things) && text0_value !== (text0_value = ctx.thing.name)) {
36+
p: function update(ctx, changed) {
37+
if ((changed & /*things*/1) && text0_value !== (text0_value = ctx.thing.name)) {
3838
setData(text0, text0_value);
3939
}
4040

41-
if (changed.foo || changed.bar || changed.baz || changed.things) {
41+
if (changed & /*foo, bar, baz or things*/15) {
4242
const { foo, bar, baz, thing } = ctx;
4343
console.log({ foo, bar, baz, thing });
4444
debugger;
@@ -94,8 +94,8 @@ function create_fragment($$, ctx) {
9494
current = true;
9595
},
9696

97-
p: function update(changed, ctx) {
98-
if (changed.things) {
97+
p: function update(ctx, changed) {
98+
if (changed & /*things*/1) {
9999
each_value = ctx.things;
100100

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

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

145145
$$self.$set = $$props => {
146-
if ('things' in $$props) $$invalidate('things', things = $$props.things);
147-
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
148-
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar);
149-
if ('baz' in $$props) $$invalidate('baz', baz = $$props.baz);
146+
if ('things' in $$props) $$invalidate('things', 0, things = $$props.things);
147+
if ('foo' in $$props) $$invalidate('foo', 1, foo = $$props.foo);
148+
if ('bar' in $$props) $$invalidate('bar', 2, bar = $$props.bar);
149+
if ('baz' in $$props) $$invalidate('baz', 3, baz = $$props.baz);
150150
};
151151

152152
return { things, foo, bar, baz };

test/js/samples/debug-foo/expected.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ function create_each_block($$, ctx) {
3333
insert(target, text1, anchor);
3434
},
3535

36-
p: function update(changed, ctx) {
37-
if ((changed.things) && text0_value !== (text0_value = ctx.thing.name)) {
36+
p: function update(ctx, changed) {
37+
if ((changed & /*things*/1) && text0_value !== (text0_value = ctx.thing.name)) {
3838
setData(text0, text0_value);
3939
}
4040

41-
if (changed.foo) {
41+
if (changed & /*foo*/2) {
4242
const { foo } = ctx;
4343
console.log({ foo });
4444
debugger;
@@ -94,15 +94,15 @@ function create_fragment($$, ctx) {
9494
current = true;
9595
},
9696

97-
p: function update(changed, ctx) {
98-
if (changed.things) {
97+
p: function update(ctx, changed) {
98+
if (changed & /*things*/1) {
9999
each_value = ctx.things;
100100

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

104104
if (each_blocks[i]) {
105-
each_blocks[i].p(changed, child_ctx);
105+
each_blocks[i].p(child_ctx, changed);
106106
} else {
107107
each_blocks[i] = create_each_block($$, child_ctx);
108108
each_blocks[i].c();
@@ -116,7 +116,7 @@ function create_fragment($$, ctx) {
116116
each_blocks.length = each_value.length;
117117
}
118118

119-
if (changed.foo) {
119+
if (changed & /*foo*/2) {
120120
setData(text2, ctx.foo);
121121
}
122122
},
@@ -143,8 +143,8 @@ function instance($$self, $$props, $$invalidate) {
143143
let { things, foo } = $$props;
144144

145145
$$self.$set = $$props => {
146-
if ('things' in $$props) $$invalidate('things', things = $$props.things);
147-
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
146+
if ('things' in $$props) $$invalidate('things', 0, things = $$props.things);
147+
if ('foo' in $$props) $$invalidate('foo', 1, foo = $$props.foo);
148148
};
149149

150150
return { things, foo };

test/js/samples/deconflict-builtins/expected.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function create_each_block($$, ctx) {
2222
append(span, text);
2323
},
2424

25-
p(changed, ctx) {
26-
if ((changed.createElement) && text_value !== (text_value = ctx.node)) {
25+
p(ctx) {
26+
if (text_value !== (text_value = ctx.node)) {
2727
setData(text, text_value);
2828
}
2929
},
@@ -65,27 +65,25 @@ function create_fragment($$, ctx) {
6565
current = true;
6666
},
6767

68-
p(changed, ctx) {
69-
if (changed.createElement) {
70-
each_value = ctx.createElement;
68+
p(ctx) {
69+
each_value = ctx.createElement;
7170

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

75-
if (each_blocks[i]) {
76-
each_blocks[i].p(changed, child_ctx);
77-
} else {
78-
each_blocks[i] = create_each_block($$, child_ctx);
79-
each_blocks[i].c();
80-
each_blocks[i].m(each_anchor.parentNode, each_anchor);
81-
}
74+
if (each_blocks[i]) {
75+
each_blocks[i].p(child_ctx);
76+
} else {
77+
each_blocks[i] = create_each_block($$, child_ctx);
78+
each_blocks[i].c();
79+
each_blocks[i].m(each_anchor.parentNode, each_anchor);
8280
}
81+
}
8382

84-
for (; i < each_blocks.length; i += 1) {
85-
each_blocks[i].d(1);
86-
}
87-
each_blocks.length = each_value.length;
83+
for (; i < each_blocks.length; i += 1) {
84+
each_blocks[i].d(1);
8885
}
86+
each_blocks.length = each_value.length;
8987
},
9088

9189
i(target, anchor) {

test/js/samples/dev-warning-missing-data-computed/expected.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ function create_fragment($$, ctx) {
2727
current = true;
2828
},
2929

30-
p: function update(changed, ctx) {
31-
if ((changed.foo) && text0_value !== (text0_value = Math.max(0, ctx.foo))) {
30+
p: function update(ctx, changed) {
31+
if ((changed & /*foo*/1) && text0_value !== (text0_value = Math.max(0, ctx.foo))) {
3232
setData(text0, text0_value);
3333
}
3434

35-
if (changed.bar) {
35+
if (changed & /*bar*/2) {
3636
setData(text2, ctx.bar);
3737
}
3838
},
@@ -58,12 +58,12 @@ function instance($$self, $$props, $$invalidate) {
5858
let bar;
5959

6060
$$self.$set = $$props => {
61-
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
61+
if ('foo' in $$props) $$invalidate('foo', 0, foo = $$props.foo);
6262
};
6363

64-
$$self.$$.update = ($$dirty = { foo: 1 }) => {
65-
if ($$dirty.foo) {
66-
bar = foo * 2; $$invalidate('bar', bar);
64+
$$self.$$.update = ($$dirty = -1) => {
65+
if ($$dirty & /*foo*/1) {
66+
bar = foo * 2; $$invalidate('bar', 1, bar);
6767
}
6868
};
6969

test/js/samples/do-use-dataset/expected.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ function create_fragment($$, ctx) {
2020
current = true;
2121
},
2222

23-
p(changed, ctx) {
24-
if (changed.bar) {
25-
div1.dataset.foo = ctx.bar;
26-
}
23+
p(ctx) {
24+
div1.dataset.foo = ctx.bar;
2725
},
2826

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

4947
$$self.$set = $$props => {
50-
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar);
48+
if ('bar' in $$props) $$invalidate('bar', 0, bar = $$props.bar);
5149
};
5250

5351
return { bar };

test/js/samples/dont-use-dataset-in-legacy/expected.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ function create_fragment($$, ctx) {
2020
current = true;
2121
},
2222

23-
p(changed, ctx) {
24-
if (changed.bar) {
25-
setAttribute(div1, "data-foo", ctx.bar);
26-
}
23+
p(ctx) {
24+
setAttribute(div1, "data-foo", ctx.bar);
2725
},
2826

2927
i(target, anchor) {

test/js/samples/dont-use-dataset-in-svg/expected.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ function create_fragment($$, ctx) {
2020
current = true;
2121
},
2222

23-
p(changed, ctx) {
24-
if (changed.bar) {
25-
setAttribute(g1, "data-foo", ctx.bar);
26-
}
23+
p(ctx) {
24+
setAttribute(g1, "data-foo", ctx.bar);
2725
},
2826

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

4745
$$self.$set = $$props => {
48-
if ('bar' in $$props) $$invalidate('bar', bar = $$props.bar);
46+
if ('bar' in $$props) $$invalidate('bar', 0, bar = $$props.bar);
4947
};
5048

5149
return { bar };

test/js/samples/each-block-changed-check/expected.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ function create_each_block($$, ctx) {
4444
raw_before.insertAdjacentHTML("afterend", raw_value);
4545
},
4646

47-
p(changed, ctx) {
48-
if ((changed.comments) && text2_value !== (text2_value = ctx.comment.author)) {
47+
p(ctx, changed) {
48+
if ((changed & /*comments*/1) && text2_value !== (text2_value = ctx.comment.author)) {
4949
setData(text2, text2_value);
5050
}
5151

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

56-
if ((changed.comments) && raw_value !== (raw_value = ctx.comment.html)) {
56+
if ((changed & /*comments*/1) && raw_value !== (raw_value = ctx.comment.html)) {
5757
detachAfter(raw_before);
5858
raw_before.insertAdjacentHTML("afterend", raw_value);
5959
}
@@ -100,15 +100,15 @@ function create_fragment($$, ctx) {
100100
current = true;
101101
},
102102

103-
p(changed, ctx) {
104-
if (changed.comments || changed.elapsed || changed.time) {
103+
p(ctx, changed) {
104+
if (changed & /*elapsed, comments or time*/ 7) {
105105
each_value = ctx.comments;
106106

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

110110
if (each_blocks[i]) {
111-
each_blocks[i].p(changed, child_ctx);
111+
each_blocks[i].p(child_ctx, changed);
112112
} else {
113113
each_blocks[i] = create_each_block($$, child_ctx);
114114
each_blocks[i].c();
@@ -122,7 +122,7 @@ function create_fragment($$, ctx) {
122122
each_blocks.length = each_value.length;
123123
}
124124

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

151151
$$self.$set = $$props => {
152-
if ('comments' in $$props) $$invalidate('comments', comments = $$props.comments);
153-
if ('elapsed' in $$props) $$invalidate('elapsed', elapsed = $$props.elapsed);
154-
if ('time' in $$props) $$invalidate('time', time = $$props.time);
155-
if ('foo' in $$props) $$invalidate('foo', foo = $$props.foo);
152+
if ('comments' in $$props) $$invalidate('comments', 0, comments = $$props.comments);
153+
if ('elapsed' in $$props) $$invalidate('elapsed', 1, elapsed = $$props.elapsed);
154+
if ('time' in $$props) $$invalidate('time', 2, time = $$props.time);
155+
if ('foo' in $$props) $$invalidate('foo', 3, foo = $$props.foo);
156156
};
157157

158158
return { comments, elapsed, time, foo };

test/js/samples/each-block-keyed-animated/expected.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ function create_each_block($$, key_1, ctx) {
2727
append(div, text);
2828
},
2929

30-
p(changed, ctx) {
31-
if ((changed.things) && text_value !== (text_value = ctx.thing.name)) {
30+
p(ctx) {
31+
if (text_value !== (text_value = ctx.thing.name)) {
3232
setData(text, text_value);
3333
}
3434
},
@@ -82,10 +82,10 @@ function create_fragment($$, ctx) {
8282
current = true;
8383
},
8484

85-
p(changed, ctx) {
85+
p(ctx) {
8686
const each_value = ctx.things;
8787
for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].r();
88-
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);
88+
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);
8989
for (let i = 0; i < each_blocks_1.length; i += 1) each_blocks_1[i].a();
9090
},
9191

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

126126
$$self.$set = $$props => {
127-
if ('things' in $$props) $$invalidate('things', things = $$props.things);
127+
if ('things' in $$props) $$invalidate('things', 0, things = $$props.things);
128128
};
129129

130130
return { things };

0 commit comments

Comments
 (0)