Skip to content

Commit 07115e6

Browse files
committed
Fix each bug
1 parent 8c8505b commit 07115e6

File tree

18 files changed

+47
-235
lines changed

18 files changed

+47
-235
lines changed

src/compile/nodes/EachBlock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export default class EachBlock extends Node {
451451
if (this.block.hasOutros) {
452452
destroy = deindent`
453453
@groupOutros();
454-
for (; #i < ${iterations}.length; #i += 1) ${outroBlock}(#i${this.compiler.options.nestedTransitions && ', 1'});
454+
for (; #i < ${iterations}.length; #i += 1) ${outroBlock}(#i, 1${this.compiler.options.nestedTransitions && ', null, 1'});
455455
`;
456456
} else {
457457
destroy = deindent`

test/cli/samples/amd/expected/Main.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
define("test", function() { "use strict";
22

33
function create_main_fragment(component, ctx) {
4-
var p, current;
4+
var p;
55

66
return {
77
c() {
88
p = createElement("p");
99
p.textContent = "Hello world!";
1010
},
1111

12-
m(target, anchor, introing) {
12+
m(target, anchor) {
1313
insert(target, p, anchor);
14-
current = true;
1514
},
1615

1716
p: noop,
1817

19-
i(target, anchor, introing) {
20-
if (current) return;
21-
22-
this.m(target, anchor, introing);
23-
},
24-
25-
o: run,
26-
2718
d(detach) {
2819
if (detach) {
2920
detachNode(p);
@@ -41,7 +32,7 @@ define("test", function() { "use strict";
4132

4233
if (options.target) {
4334
this._fragment.c();
44-
this._mount(options.target, options.anchor, 1);
35+
this._mount(options.target, options.anchor);
4536
}
4637
}
4738

@@ -69,10 +60,6 @@ define("test", function() { "use strict";
6960

7061
function noop() {}
7162

72-
function run(fn) {
73-
fn();
74-
}
75-
7663
function detachNode(node) {
7764
node.parentNode.removeChild(node);
7865
}

test/cli/samples/basic/expected/Main.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,20 @@
11
/* src/Main.html generated by Svelte vx.y.z */
22

33
function create_main_fragment(component, ctx) {
4-
var p, current;
4+
var p;
55

66
return {
77
c() {
88
p = createElement("p");
99
p.textContent = "Hello world!";
1010
},
1111

12-
m(target, anchor, introing) {
12+
m(target, anchor) {
1313
insert(target, p, anchor);
14-
current = true;
1514
},
1615

1716
p: noop,
1817

19-
i(target, anchor, introing) {
20-
if (current) return;
21-
22-
this.m(target, anchor, introing);
23-
},
24-
25-
o: run,
26-
2718
d(detach) {
2819
if (detach) {
2920
detachNode(p);
@@ -41,7 +32,7 @@ function Main(options) {
4132

4233
if (options.target) {
4334
this._fragment.c();
44-
this._mount(options.target, options.anchor, 1);
35+
this._mount(options.target, options.anchor);
4536
}
4637
}
4738

@@ -69,10 +60,6 @@ function insert(target, node, anchor) {
6960

7061
function noop() {}
7162

72-
function run(fn) {
73-
fn();
74-
}
75-
7663
function detachNode(node) {
7764
node.parentNode.removeChild(node);
7865
}

test/cli/samples/custom-element/expected/Main.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* src/Main.html generated by Svelte vx.y.z */
22

33
function create_main_fragment(component, ctx) {
4-
var p, current;
4+
var p;
55

66
return {
77
c() {
@@ -10,21 +10,12 @@ function create_main_fragment(component, ctx) {
1010
this.c = noop;
1111
},
1212

13-
m(target, anchor, introing) {
13+
m(target, anchor) {
1414
insert(target, p, anchor);
15-
current = true;
1615
},
1716

1817
p: noop,
1918

20-
i(target, anchor, introing) {
21-
if (current) return;
22-
23-
this.m(target, anchor, introing);
24-
},
25-
26-
o: run,
27-
2819
d(detach) {
2920
if (detach) {
3021
detachNode(p);
@@ -47,7 +38,7 @@ class Main extends HTMLElement {
4738
this._fragment.c();
4839
this._fragment.m(this.shadowRoot, null);
4940

50-
if (options.target) this._mount(options.target, options.anchor, 1);
41+
if (options.target) this._mount(options.target, options.anchor);
5142
}
5243

5344
static get observedAttributes() {
@@ -90,10 +81,6 @@ function insert(target, node, anchor) {
9081
target.insertBefore(node, anchor);
9182
}
9283

93-
function run(fn) {
94-
fn();
95-
}
96-
9784
function detachNode(node) {
9885
node.parentNode.removeChild(node);
9986
}

test/cli/samples/dev/expected/Main.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const file = "src/Main.html";
44

55
function create_main_fragment(component, ctx) {
6-
var p, text, current;
6+
var p, text;
77

88
return {
99
c: function create() {
@@ -12,22 +12,13 @@ function create_main_fragment(component, ctx) {
1212
addLoc(p, file, 0, 0, 0);
1313
},
1414

15-
m: function mount(target, anchor, introing) {
15+
m: function mount(target, anchor) {
1616
insert(target, p, anchor);
1717
append(p, text);
18-
current = true;
1918
},
2019

2120
p: noop,
2221

23-
i: function intro(target, anchor, introing) {
24-
if (current) return;
25-
26-
this.m(target, anchor, introing);
27-
},
28-
29-
o: run,
30-
3122
d: function destroy(detach) {
3223
if (detach) {
3324
detachNode(p);
@@ -48,7 +39,7 @@ function Main(options) {
4839
if (options.target) {
4940
if (options.hydrate) throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
5041
this._fragment.c();
51-
this._mount(options.target, options.anchor, 1);
42+
this._mount(options.target, options.anchor);
5243
}
5344
}
5445

@@ -93,10 +84,6 @@ function append(target, node) {
9384

9485
function noop() {}
9586

96-
function run(fn) {
97-
fn();
98-
}
99-
10087
function detachNode(node) {
10188
node.parentNode.removeChild(node);
10289
}

test/cli/samples/dir-sourcemap/expected/Main.js

Lines changed: 3 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/samples/dir-sourcemap/expected/Main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/samples/dir-sourcemap/expected/Widget.js

Lines changed: 3 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/samples/dir-sourcemap/expected/Widget.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/cli/samples/dir-subdir/expected/Main.js

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import Widget from './widget/Widget.html';
44

55

66
function create_main_fragment(component, ctx) {
7-
var current;
87

98
var widget = new Widget({
109
root: component.root,
@@ -16,26 +15,12 @@ function create_main_fragment(component, ctx) {
1615
widget._fragment.c();
1716
},
1817

19-
m(target, anchor, introing) {
20-
widget._mount(target, anchor, introing);
21-
current = true;
18+
m(target, anchor) {
19+
widget._mount(target, anchor);
2220
},
2321

2422
p: noop,
2523

26-
i(target, anchor, introing) {
27-
if (current) return;
28-
29-
this.m(target, anchor, introing);
30-
},
31-
32-
o(outrocallback, outroing) {
33-
if (!current) return;
34-
35-
if (widget) widget._fragment.o(outrocallback, outroing);
36-
current = false;
37-
},
38-
3924
d(detach) {
4025
widget.destroy(detach);
4126
}
@@ -51,7 +36,7 @@ function Main(options) {
5136

5237
if (options.target) {
5338
this._fragment.c();
54-
this._mount(options.target, options.anchor, 1);
39+
this._mount(options.target, options.anchor);
5540

5641
flush(this);
5742
}

0 commit comments

Comments
 (0)