Skip to content

Commit e8eeefa

Browse files
author
Timothy Johnson
committed
Conditionally add bubble to fragment
1 parent 0ee7cb2 commit e8eeefa

File tree

76 files changed

+10
-102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+10
-102
lines changed

src/compiler/compile/render_dom/Block.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Renderer from './Renderer';
22
import Wrapper from './wrappers/shared/Wrapper';
3-
import { b, x } from 'code-red';
3+
import { b, x, p } from 'code-red';
44
import { Node, Identifier, ArrayPattern } from 'estree';
55
import { is_head } from './wrappers/shared/is_head';
66

@@ -294,9 +294,7 @@ export default class Block {
294294
}`;
295295
}
296296

297-
if (this.chunks.bubble.length === 0) {
298-
properties.bubble = noop;
299-
} else {
297+
if (this.chunks.bubble.length > 0) {
300298
const mounted: Identifier = {
301299
type: 'Identifier',
302300
name: '#mounted'
@@ -410,7 +408,6 @@ export default class Block {
410408
l: ${properties.claim},
411409
h: ${properties.hydrate},
412410
m: ${properties.mount},
413-
b: ${properties.bubble},
414411
p: ${properties.update},
415412
r: ${properties.measure},
416413
f: ${properties.fix},
@@ -420,6 +417,10 @@ export default class Block {
420417
d: ${properties.destroy}
421418
}`;
422419

420+
if (properties.bubble) {
421+
return_value.properties.push(p`b: ${properties.bubble}`);
422+
}
423+
423424
const block = dev && this.get_unique_name('block');
424425

425426
const body = b`

src/runtime/internal/Component.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ export class SvelteComponent {
216216
}
217217

218218
$on(type, callback) {
219-
const dispose = this.$$.fragment && this.$$.fragment.b(type, callback) || noop;
219+
const dispose = this.$$.fragment
220+
&& this.$$.fragment.b
221+
&& this.$$.fragment.b(type, callback)
222+
|| noop;
220223
const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
221224
callbacks.push(callback);
222225

test/js/samples/action-custom-event-handler/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function create_fragment(ctx) {
2626
if (remount) dispose();
2727
dispose = action_destroyer(foo_action = foo.call(null, button, /*foo_function*/ ctx[1]));
2828
},
29-
b: noop,
3029
p(ctx, [dirty]) {
3130
if (foo_action && is_function(foo_action.update) && dirty & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]);
3231
},

test/js/samples/action/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function create_fragment(ctx) {
2727
if (remount) dispose();
2828
dispose = action_destroyer(link_action = link.call(null, a));
2929
},
30-
b: noop,
3130
p: noop,
3231
i: noop,
3332
o: noop,

test/js/samples/bind-online/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function create_fragment(ctx) {
2323
listen(window, "offline", /*onlinestatuschanged*/ ctx[1])
2424
];
2525
},
26-
b: noop,
2726
p: noop,
2827
i: noop,
2928
o: noop,

test/js/samples/bind-open/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ function create_fragment(ctx) {
2727
if (remount) dispose();
2828
dispose = listen(details, "toggle", /*details_toggle_handler*/ ctx[1]);
2929
},
30-
b: noop,
3130
p(ctx, [dirty]) {
3231
if (dirty & /*open*/ 1) {
3332
details.open = /*open*/ ctx[0];

test/js/samples/bind-width-height/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function create_fragment(ctx) {
2525
insert(target, div, anchor);
2626
div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[2].bind(div));
2727
},
28-
b: noop,
2928
p: noop,
3029
i: noop,
3130
o: noop,

test/js/samples/bindings-readonly-order/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function create_fragment(ctx) {
3838
listen(input1, "change", /*input1_change_handler*/ ctx[2])
3939
];
4040
},
41-
b: noop,
4241
p: noop,
4342
i: noop,
4443
o: noop,

test/js/samples/capture-inject-dev-only/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ function create_fragment(ctx) {
3838
if (remount) dispose();
3939
dispose = listen(input, "input", /*input_input_handler*/ ctx[1]);
4040
},
41-
b: noop,
4241
p(ctx, [dirty]) {
4342
if (dirty & /*foo*/ 1) set_data(t0, /*foo*/ ctx[0]);
4443

test/js/samples/capture-inject-state/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function create_fragment(ctx) {
6767
append_dev(p, t9);
6868
append_dev(p, t10);
6969
},
70-
b: noop,
7170
p: function update(ctx, [dirty]) {
7271
if (dirty & /*prop*/ 1) set_data_dev(t0, /*prop*/ ctx[0]);
7372
if (dirty & /*realName*/ 2) set_data_dev(t2, /*realName*/ ctx[1]);

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

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ function create_fragment(ctx) {
3434
insert(target, p, anchor);
3535
append(p, t);
3636
},
37-
b: noop,
3837
p(ctx, [dirty]) {
3938
if (dirty & /*foo*/ 1) set_data(t, /*foo*/ ctx[0]);
4039
},

test/js/samples/component-static-array/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function create_fragment(ctx) {
2323
mount_component(nested, target, anchor);
2424
current = true;
2525
},
26-
b: noop,
2726
p: noop,
2827
i(local) {
2928
if (current) return;

test/js/samples/component-static-immutable/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function create_fragment(ctx) {
2323
mount_component(nested, target, anchor);
2424
current = true;
2525
},
26-
b: noop,
2726
p: noop,
2827
i(local) {
2928
if (current) return;

test/js/samples/component-static-immutable2/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function create_fragment(ctx) {
2323
mount_component(nested, target, anchor);
2424
current = true;
2525
},
26-
b: noop,
2726
p: noop,
2827
i(local) {
2928
if (current) return;

test/js/samples/component-static-var/expected.js

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
insert,
1010
listen,
1111
mount_component,
12-
noop,
1312
safe_not_equal,
1413
set_input_value,
1514
space,
@@ -48,7 +47,6 @@ function create_fragment(ctx) {
4847
if (remount) dispose();
4948
dispose = listen(input, "input", /*input_input_handler*/ ctx[1]);
5049
},
51-
b: noop,
5250
p(ctx, [dirty]) {
5351
const bar_changes = {};
5452
if (dirty & /*z*/ 1) bar_changes.x = /*z*/ ctx[0];

test/js/samples/component-static/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function create_fragment(ctx) {
2323
mount_component(nested, target, anchor);
2424
current = true;
2525
},
26-
b: noop,
2726
p: noop,
2827
i(local) {
2928
if (current) return;

test/js/samples/component-store-access-invalidate/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function create_fragment(ctx) {
2828
insert(target, h1, anchor);
2929
append(h1, t);
3030
},
31-
b: noop,
3231
p(ctx, [dirty]) {
3332
if (dirty & /*$foo*/ 1) set_data(t, /*$foo*/ ctx[0]);
3433
},

test/js/samples/component-store-reassign-invalidate/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ function create_fragment(ctx) {
4040
if (remount) dispose();
4141
dispose = listen(button, "click", /*click_handler*/ ctx[2]);
4242
},
43-
b: noop,
4443
p(ctx, [dirty]) {
4544
if (dirty & /*$foo*/ 2) set_data(t0, /*$foo*/ ctx[1]);
4645
},

test/js/samples/css-media-query/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function create_fragment(ctx) {
2929
m(target, anchor) {
3030
insert(target, div, anchor);
3131
},
32-
b: noop,
3332
p: noop,
3433
i: noop,
3534
o: noop,

test/js/samples/css-shadow-dom-keyframes/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ function create_fragment(ctx) {
2121
m(target, anchor) {
2222
insert(target, div, anchor);
2323
},
24-
b: noop,
2524
p: noop,
2625
i: noop,
2726
o: noop,

test/js/samples/data-attribute/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function create_fragment(ctx) {
2929
insert(target, t, anchor);
3030
insert(target, div1, anchor);
3131
},
32-
b: noop,
3332
p(ctx, [dirty]) {
3433
if (dirty & /*bar*/ 1) {
3534
attr(div1, "data-foo", /*bar*/ ctx[0]);

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

-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function create_fragment(ctx) {
4545
append_dev(h1, t2);
4646
insert_dev(target, t3, anchor);
4747
},
48-
b: noop,
4948
p: function update(ctx, [dirty]) {
5049
if (dirty & /*name*/ 1) set_data_dev(t1, /*name*/ ctx[0]);
5150
debugger;

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

-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ function create_each_block(ctx) {
5555
append_dev(span, t0);
5656
insert_dev(target, t1, anchor);
5757
},
58-
b: noop,
5958
p: function update(ctx, dirty) {
6059
if (dirty & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[4].name + "")) set_data_dev(t0, t0_value);
6160

@@ -123,7 +122,6 @@ function create_fragment(ctx) {
123122
append_dev(p, t1);
124123
append_dev(p, t2);
125124
},
126-
b: noop,
127125
p: function update(ctx, [dirty]) {
128126
if (dirty & /*things*/ 1) {
129127
each_value = /*things*/ ctx[0];

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

-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ function create_each_block(ctx) {
5252
append_dev(span, t0);
5353
insert_dev(target, t1, anchor);
5454
},
55-
b: noop,
5655
p: function update(ctx, dirty) {
5756
if (dirty & /*things*/ 1 && t0_value !== (t0_value = /*thing*/ ctx[2].name + "")) set_data_dev(t0, t0_value);
5857

@@ -117,7 +116,6 @@ function create_fragment(ctx) {
117116
append_dev(p, t1);
118117
append_dev(p, t2);
119118
},
120-
b: noop,
121119
p: function update(ctx, [dirty]) {
122120
if (dirty & /*things*/ 1) {
123121
each_value = /*things*/ ctx[0];

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

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function create_fragment(ctx) {
2424
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
2525
},
2626
m: noop,
27-
b: noop,
2827
p: function update(ctx, [dirty]) {
2928
if (dirty & /*obj, kobzol*/ 3) {
3029
const obj = /*obj*/ ctx[0];

test/js/samples/debug-no-dependencies/expected.js

-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ function create_each_block(ctx) {
4545
insert_dev(target, t0, anchor);
4646
insert_dev(target, t1, anchor);
4747
},
48-
b: noop,
4948
p: noop,
5049
d: function destroy(detaching) {
5150
if (detaching) detach_dev(t0);
@@ -92,7 +91,6 @@ function create_fragment(ctx) {
9291

9392
insert_dev(target, each_1_anchor, anchor);
9493
},
95-
b: noop,
9694
p: function update(ctx, [dirty]) {
9795
if (dirty & /*things*/ 0) {
9896
each_value = things;

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

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function create_each_block(ctx) {
3535
insert(target, span, anchor);
3636
append(span, t);
3737
},
38-
b: noop,
3938
p(ctx, dirty) {
4039
if (dirty & /*createElement*/ 1 && t_value !== (t_value = /*node*/ ctx[1] + "")) set_data(t, t_value);
4140
},
@@ -69,7 +68,6 @@ function create_fragment(ctx) {
6968

7069
insert(target, each_1_anchor, anchor);
7170
},
72-
b: noop,
7371
p(ctx, [dirty]) {
7472
if (dirty & /*createElement*/ 1) {
7573
each_value = /*createElement*/ ctx[0];

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

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ function create_fragment(ctx) {
4242
append_dev(p, t1);
4343
append_dev(p, t2);
4444
},
45-
b: noop,
4645
p: function update(ctx, [dirty]) {
4746
if (dirty & /*foo*/ 1 && t0_value !== (t0_value = Math.max(0, /*foo*/ ctx[0]) + "")) set_data_dev(t0, t0_value);
4847
if (dirty & /*bar*/ 2) set_data_dev(t2, /*bar*/ ctx[1]);

test/js/samples/dont-invalidate-this/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function create_fragment(ctx) {
2323
if (remount) dispose();
2424
dispose = listen(input, "input", make_uppercase);
2525
},
26-
b: noop,
2726
p: noop,
2827
i: noop,
2928
o: noop,

test/js/samples/dynamic-import/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ function create_fragment(ctx) {
2525
mount_component(lazyload, target, anchor);
2626
current = true;
2727
},
28-
b: noop,
2928
p: noop,
3029
i(local) {
3130
if (current) return;

test/js/samples/each-block-array-literal/expected.js

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ function create_each_block(ctx) {
3535
insert(target, span, anchor);
3636
append(span, t);
3737
},
38-
b: noop,
3938
p(ctx, dirty) {
4039
if (dirty & /*a, b, c, d, e*/ 31 && t_value !== (t_value = /*num*/ ctx[5] + "")) set_data(t, t_value);
4140
},
@@ -69,7 +68,6 @@ function create_fragment(ctx) {
6968

7069
insert(target, each_1_anchor, anchor);
7170
},
72-
b: noop,
7371
p(ctx, [dirty]) {
7472
if (dirty & /*a, b, c, d, e*/ 31) {
7573
each_value = [/*a*/ ctx[0], /*b*/ ctx[1], /*c*/ ctx[2], /*d*/ ctx[3], /*e*/ ctx[4]];

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

-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ function create_each_block(ctx) {
6969
append(div, t6);
7070
html_tag.m(div);
7171
},
72-
b: noop,
7372
p(ctx, dirty) {
7473
if (dirty & /*comments*/ 1 && t2_value !== (t2_value = /*comment*/ ctx[4].author + "")) set_data(t2, t2_value);
7574
if (dirty & /*elapsed, comments, time*/ 7 && t4_value !== (t4_value = /*elapsed*/ ctx[1](/*comment*/ ctx[4].time, /*time*/ ctx[2]) + "")) set_data(t4, t4_value);
@@ -111,7 +110,6 @@ function create_fragment(ctx) {
111110
insert(target, p, anchor);
112111
append(p, t1);
113112
},
114-
b: noop,
115113
p(ctx, [dirty]) {
116114
if (dirty & /*comments, elapsed, time*/ 7) {
117115
each_value = /*comments*/ ctx[0];

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

-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ function create_each_block(key_1, ctx) {
4343
insert(target, div, anchor);
4444
append(div, t);
4545
},
46-
b: noop,
4746
p(ctx, dirty) {
4847
if (dirty & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value);
4948
},
@@ -92,7 +91,6 @@ function create_fragment(ctx) {
9291

9392
insert(target, each_1_anchor, anchor);
9493
},
95-
b: noop,
9694
p(ctx, [dirty]) {
9795
if (dirty & /*things*/ 1) {
9896
const each_value = /*things*/ ctx[0];

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

-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function create_each_block(key_1, ctx) {
3939
insert(target, div, anchor);
4040
append(div, t);
4141
},
42-
b: noop,
4342
p(ctx, dirty) {
4443
if (dirty & /*things*/ 1 && t_value !== (t_value = /*thing*/ ctx[1].name + "")) set_data(t, t_value);
4544
},
@@ -77,7 +76,6 @@ function create_fragment(ctx) {
7776

7877
insert(target, each_1_anchor, anchor);
7978
},
80-
b: noop,
8179
p(ctx, [dirty]) {
8280
if (dirty & /*things*/ 1) {
8381
const each_value = /*things*/ ctx[0];

test/js/samples/event-handler-dynamic/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ function create_fragment(ctx) {
6363
})
6464
];
6565
},
66-
b: noop,
6766
p(new_ctx, [dirty]) {
6867
ctx = new_ctx;
6968
if (dirty & /*number*/ 2) set_data(t4, /*number*/ ctx[1]);

test/js/samples/event-handler-no-passive/expected.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function create_fragment(ctx) {
2626
if (remount) dispose();
2727
dispose = listen(a, "touchstart", touchstart_handler);
2828
},
29-
b: noop,
3029
p: noop,
3130
i: noop,
3231
o: noop,

0 commit comments

Comments
 (0)