Skip to content

Commit 33f192d

Browse files
author
Timothy Johnson
committed
Conditionally add bubble to fragment
1 parent e269da2 commit 33f192d

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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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]);

0 commit comments

Comments
 (0)