Skip to content

Commit e0eddb5

Browse files
committed
moar comments
1 parent 32099d9 commit e0eddb5

File tree

59 files changed

+272
-252
lines changed

Some content is hidden

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

59 files changed

+272
-252
lines changed

src/compiler/compile/render_dom/Renderer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ export default class Renderer {
238238
const expression = bitmask
239239
.map((b, i) => ({ b, i }))
240240
.filter(({ b }) => b)
241-
.map(({ b, i }) => x`${dirty}[${i}] & /* ${b.names.join(', ')} */ ${b.n}`)
241+
.map(({ b, i }) => x`${dirty}[${i}] & /*${b.names.join(', ')}*/ ${b.n}`)
242242
.reduce((lhs, rhs) => x`${lhs} | ${rhs}`);
243243

244244
({ operator, left, right } = expression);
245245
} else {
246-
({ operator, left, right } = x`${dirty} & /* ${names.join(', ')} */ ${bitmask[0] ? bitmask[0].n : 0}` as BinaryExpression); // TODO the `: 0` case should never apply
246+
({ operator, left, right } = x`${dirty} & /*${names.join(', ')}*/ ${bitmask[0] ? bitmask[0].n : 0}` as BinaryExpression); // TODO the `: 0` case should never apply
247247
}
248248

249249
return 'BinaryExpression';
@@ -274,7 +274,7 @@ export default class Renderer {
274274
}
275275

276276
if (member !== undefined) {
277-
const replacement = x`#ctx[${member.index}]` as MemberExpression;
277+
const replacement = x`/*${member.name}*/ #ctx[${member.index}]` as MemberExpression;
278278

279279
if (nodes[0].loc) replacement.object.loc = nodes[0].loc;
280280
nodes[0] = replacement;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ function create_fragment(ctx) {
2121
},
2222
m(target, anchor) {
2323
insert(target, button, anchor);
24-
foo_action = foo.call(null, button, ctx[1]) || ({});
24+
foo_action = foo.call(null, button, /*foo_function*/ ctx[1]) || ({});
2525
},
2626
p(ctx, [dirty]) {
27-
if (is_function(foo_action.update) && dirty & /* bar */ 1) foo_action.update.call(null, ctx[1]);
27+
if (is_function(foo_action.update) && dirty & /*bar*/ 1) foo_action.update.call(null, /*foo_function*/ ctx[1]);
2828
},
2929
i: noop,
3030
o: noop,

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import {
1111

1212
function create_fragment(ctx) {
1313
let dispose;
14-
add_render_callback(ctx[1]);
14+
add_render_callback(/*onlinestatuschanged*/ ctx[1]);
1515

1616
return {
1717
c() {
18-
dispose = [listen(window, "online", ctx[1]), listen(window, "offline", ctx[1])];
18+
dispose = [
19+
listen(window, "online", /*onlinestatuschanged*/ ctx[1]),
20+
listen(window, "offline", /*onlinestatuschanged*/ ctx[1])
21+
];
1922
},
2023
m: noop,
2124
p: noop,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ function create_fragment(ctx) {
2121
details.innerHTML = `<summary>summary</summary>content
2222
`;
2323

24-
dispose = listen(details, "toggle", ctx[1]);
24+
dispose = listen(details, "toggle", /*details_toggle_handler*/ ctx[1]);
2525
},
2626
m(target, anchor) {
2727
insert(target, details, anchor);
28-
details.open = ctx[0];
28+
details.open = /*open*/ ctx[0];
2929
},
3030
p(ctx, [dirty]) {
31-
if (dirty & /* open */ 1) {
32-
details.open = ctx[0];
31+
if (dirty & /*open*/ 1) {
32+
details.open = /*open*/ ctx[0];
3333
}
3434
},
3535
i: noop,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ function create_fragment(ctx) {
1919
c() {
2020
div = element("div");
2121
div.textContent = "some content";
22-
add_render_callback(() => ctx[2].call(div));
22+
add_render_callback(() => /*div_elementresize_handler*/ ctx[2].call(div));
2323
},
2424
m(target, anchor) {
2525
insert(target, div, anchor);
26-
div_resize_listener = add_resize_listener(div, ctx[2].bind(div));
26+
div_resize_listener = add_resize_listener(div, /*div_elementresize_handler*/ ctx[2].bind(div));
2727
},
2828
p: noop,
2929
i: noop,

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ function create_fragment(ctx) {
2626
input1 = element("input");
2727
attr(input0, "type", "file");
2828
attr(input1, "type", "file");
29-
dispose = [listen(input0, "change", ctx[1]), listen(input1, "change", ctx[2])];
29+
30+
dispose = [
31+
listen(input0, "change", /*input0_change_handler*/ ctx[1]),
32+
listen(input1, "change", /*input1_change_handler*/ ctx[2])
33+
];
3034
},
3135
m(target, anchor) {
3236
insert(target, input0, anchor);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ function create_fragment(ctx) {
2525
return {
2626
c() {
2727
p = element("p");
28-
t0 = text(ctx[0]);
28+
t0 = text(/*foo*/ ctx[0]);
2929
t1 = space();
3030
input = element("input");
31-
dispose = listen(input, "input", ctx[1]);
31+
dispose = listen(input, "input", /*input_input_handler*/ ctx[1]);
3232
},
3333
m(target, anchor) {
3434
insert(target, p, anchor);
3535
append(p, t0);
3636
insert(target, t1, anchor);
3737
insert(target, input, anchor);
38-
set_input_value(input, ctx[0]);
38+
set_input_value(input, /*foo*/ ctx[0]);
3939
},
4040
p(ctx, [dirty]) {
41-
if (dirty & /* foo */ 1) set_data(t0, ctx[0]);
41+
if (dirty & /*foo*/ 1) set_data(t0, /*foo*/ ctx[0]);
4242

43-
if (dirty & /* foo */ 1 && input.value !== ctx[0]) {
44-
set_input_value(input, ctx[0]);
43+
if (dirty & /*foo*/ 1 && input.value !== /*foo*/ ctx[0]) {
44+
set_input_value(input, /*foo*/ ctx[0]);
4545
}
4646
},
4747
i: noop,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
function add_css() {
1717
var style = element("style");
1818
style.id = "svelte-1a7i8ec-style";
19-
style.textContent = "p.svelte-1a7i8ec{color:red}";
19+
style.textContent = "p.svelte-1a7i8ec{\n\t\tcolor: red;\n\t}";
2020
append(document.head, style);
2121
}
2222

@@ -27,15 +27,15 @@ function create_fragment(ctx) {
2727
return {
2828
c() {
2929
p = element("p");
30-
t = text(ctx[0]);
30+
t = text(/*foo*/ ctx[0]);
3131
attr(p, "class", "svelte-1a7i8ec");
3232
},
3333
m(target, anchor) {
3434
insert(target, p, anchor);
3535
append(p, t);
3636
},
3737
p(ctx, [dirty]) {
38-
if (dirty & /* foo */ 1) set_data(t, ctx[0]);
38+
if (dirty & /*foo*/ 1) set_data(t, /*foo*/ ctx[0]);
3939
},
4040
i: noop,
4141
o: noop,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
function create_fragment(ctx) {
1515
let current;
16-
const nested = new ctx[0]({ props: { foo: [1, 2, 3] } });
16+
const nested = new /*Nested*/ ctx[0]({ props: { foo: [1, 2, 3] } });
1717

1818
return {
1919
c() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
function create_fragment(ctx) {
1515
let current;
16-
const nested = new ctx[0]({ props: { foo: "bar" } });
16+
const nested = new /*Nested*/ ctx[0]({ props: { foo: "bar" } });
1717

1818
return {
1919
c() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
function create_fragment(ctx) {
1515
let current;
16-
const nested = new ctx[0]({ props: { foo: "bar" } });
16+
const nested = new /*Nested*/ ctx[0]({ props: { foo: "bar" } });
1717

1818
return {
1919
c() {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function create_fragment(ctx) {
2626
let current;
2727
let dispose;
2828
const foo = new Foo({ props: { x: y } });
29-
const bar = new Bar({ props: { x: ctx[0] } });
29+
const bar = new Bar({ props: { x: /*z*/ ctx[0] } });
3030

3131
return {
3232
c() {
@@ -35,24 +35,24 @@ function create_fragment(ctx) {
3535
create_component(bar.$$.fragment);
3636
t1 = space();
3737
input = element("input");
38-
dispose = listen(input, "input", ctx[1]);
38+
dispose = listen(input, "input", /*input_input_handler*/ ctx[1]);
3939
},
4040
m(target, anchor) {
4141
mount_component(foo, target, anchor);
4242
insert(target, t0, anchor);
4343
mount_component(bar, target, anchor);
4444
insert(target, t1, anchor);
4545
insert(target, input, anchor);
46-
set_input_value(input, ctx[0]);
46+
set_input_value(input, /*z*/ ctx[0]);
4747
current = true;
4848
},
4949
p(ctx, [dirty]) {
5050
const bar_changes = {};
51-
if (dirty & /* z */ 1) bar_changes.x = ctx[0];
51+
if (dirty & /*z*/ 1) bar_changes.x = /*z*/ ctx[0];
5252
bar.$set(bar_changes);
5353

54-
if (dirty & /* z */ 1 && input.value !== ctx[0]) {
55-
set_input_value(input, ctx[0]);
54+
if (dirty & /*z*/ 1 && input.value !== /*z*/ ctx[0]) {
55+
set_input_value(input, /*z*/ ctx[0]);
5656
}
5757
},
5858
i(local) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313

1414
function create_fragment(ctx) {
1515
let current;
16-
const nested = new ctx[0]({ props: { foo: "bar" } });
16+
const nested = new /*Nested*/ ctx[0]({ props: { foo: "bar" } });
1717

1818
return {
1919
c() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ function create_fragment(ctx) {
2222
return {
2323
c() {
2424
h1 = element("h1");
25-
t = text(ctx[0]);
25+
t = text(/*$foo*/ ctx[0]);
2626
},
2727
m(target, anchor) {
2828
insert(target, h1, anchor);
2929
append(h1, t);
3030
},
3131
p(ctx, [dirty]) {
32-
if (dirty & /* $foo */ 1) set_data(t, ctx[0]);
32+
if (dirty & /*$foo*/ 1) set_data(t, /*$foo*/ ctx[0]);
3333
},
3434
i: noop,
3535
o: noop,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ function create_fragment(ctx) {
2727
return {
2828
c() {
2929
h1 = element("h1");
30-
t0 = text(ctx[1]);
30+
t0 = text(/*$foo*/ ctx[1]);
3131
t1 = space();
3232
button = element("button");
3333
button.textContent = "reset";
34-
dispose = listen(button, "click", ctx[2]);
34+
dispose = listen(button, "click", /*click_handler*/ ctx[2]);
3535
},
3636
m(target, anchor) {
3737
insert(target, h1, anchor);
@@ -40,7 +40,7 @@ function create_fragment(ctx) {
4040
insert(target, button, anchor);
4141
},
4242
p(ctx, [dirty]) {
43-
if (dirty & /* $foo */ 2) set_data(t0, ctx[1]);
43+
if (dirty & /*$foo*/ 2) set_data(t0, /*$foo*/ ctx[1]);
4444
},
4545
i: noop,
4646
o: noop,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import {
33
SvelteComponent,
44
append,
5-
attr,
65
detach,
76
element,
87
init,
@@ -14,7 +13,7 @@ import {
1413
function add_css() {
1514
var style = element("style");
1615
style.id = "svelte-1slhpfn-style";
17-
style.textContent = "@media(min-width: 1px){div.svelte-1slhpfn{color:red}}";
16+
style.textContent = "@media(min-width: 1px){}";
1817
append(document.head, style);
1918
}
2019

@@ -24,7 +23,6 @@ function create_fragment(ctx) {
2423
return {
2524
c() {
2625
div = element("div");
27-
attr(div, "class", "svelte-1slhpfn");
2826
},
2927
m(target, anchor) {
3028
insert(target, div, anchor);

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ function create_fragment(ctx) {
3333
class Component extends SvelteElement {
3434
constructor(options) {
3535
super();
36-
this.shadowRoot.innerHTML = `<style>div{animation:foo 1s}@keyframes foo{0%{opacity:0}100%{opacity:1}}</style>`;
36+
37+
this.shadowRoot.innerHTML = `<style>div{
38+
animation: foo 1s;
39+
}@keyframes foo{}</style>`;
40+
3741
init(this, { target: this.shadowRoot }, null, create_fragment, safe_not_equal, {});
3842

3943
if (options) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ function create_fragment(ctx) {
2222
t = space();
2323
div1 = element("div");
2424
attr(div0, "data-foo", "bar");
25-
attr(div1, "data-foo", ctx[0]);
25+
attr(div1, "data-foo", /*bar*/ ctx[0]);
2626
},
2727
m(target, anchor) {
2828
insert(target, div0, anchor);
2929
insert(target, t, anchor);
3030
insert(target, div1, anchor);
3131
},
3232
p(ctx, [dirty]) {
33-
if (dirty & /* bar */ 1) {
34-
attr(div1, "data-foo", ctx[0]);
33+
if (dirty & /*bar*/ 1) {
34+
attr(div1, "data-foo", /*bar*/ ctx[0]);
3535
}
3636
},
3737
i: noop,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function create_fragment(ctx) {
2828
c: function create() {
2929
h1 = element("h1");
3030
t0 = text("Hello ");
31-
t1 = text(ctx[0]);
31+
t1 = text(/*name*/ ctx[0]);
3232
t2 = text("!");
3333
t3 = space();
3434
debugger;
@@ -45,7 +45,7 @@ function create_fragment(ctx) {
4545
insert_dev(target, t3, anchor);
4646
},
4747
p: function update(ctx, [dirty]) {
48-
if (dirty & /* name */ 1) set_data_dev(t1, ctx[0]);
48+
if (dirty & /*name*/ 1) set_data_dev(t1, /*name*/ ctx[0]);
4949
debugger;
5050
},
5151
i: noop,
@@ -105,7 +105,7 @@ class Component extends SvelteComponentDev {
105105
const { ctx } = this.$$;
106106
const props = options.props || ({});
107107

108-
if (ctx[0] === undefined && !("name" in props)) {
108+
if (/*name*/ ctx[0] === undefined && !("name" in props)) {
109109
console.warn("<Component> was created without expected prop 'name'");
110110
}
111111
}

0 commit comments

Comments
 (0)