Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/compiler/compile/render_dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,14 @@ export default function dom(
}) as Expression)
};

const ctx_names = component.compile_options.dev && {
type: 'ArrayExpression',
elements: initial_context.map(member => ({
type: 'Literal',
value: member.name
}) as Expression)
};

body.push(b`
function ${definition}(${args}) {
${reactive_store_declarations}
Expand Down Expand Up @@ -408,6 +416,8 @@ export default function dom(

${uses_props && b`$$props = @exclude_internal_props($$props);`}

${ctx_names && x`$$self.$$.ctx_names = ${ctx_names};`}

return ${return_value};
}
`);
Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-empty/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ function instance($$self, $$props, $$invalidate) {
if ("name" in $$props) $$invalidate(0, name = $$props.name);
};

$$self.$$.ctx_names = ["name"];
return [name];
}

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-foo-bar-baz-things/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ function instance($$self, $$props, $$invalidate) {
if ("baz" in $$props) $$invalidate(3, baz = $$props.baz);
};

$$self.$$.ctx_names = ["things", "foo", "bar", "baz"];
return [things, foo, bar, baz];
}

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-foo/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function instance($$self, $$props, $$invalidate) {
if ("foo" in $$props) $$invalidate(1, foo = $$props.foo);
};

$$self.$$.ctx_names = ["things", "foo"];
return [things, foo];
}

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/debug-hoisted/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function instance($$self) {
if ("kobzol" in $$props) $$invalidate(1, kobzol = $$props.kobzol);
};

$$self.$$.ctx_names = ["obj", "kobzol"];
return [obj, kobzol];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ function instance($$self, $$props, $$invalidate) {
}
};

$$self.$$.ctx_names = ["foo", "bar"];
return [foo, bar];
}

Expand Down
1 change: 1 addition & 0 deletions test/js/samples/loop-protect/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ function instance($$self) {
} while (true);
}

$$self.$$.ctx_names = [];
return [];
}

Expand Down