expose stats.props

pull/1838/head
Rich Harris 6 years ago
parent 1f79099d2f
commit 998d86a4e3

@ -103,7 +103,10 @@ export default class Stats {
onupdate: !!component.templateProperties.onupdate
};
const computed = new Set(component.computations.map(c => c.key));
return {
props: Array.from(component.expectedProperties).filter(key => !computed.has(key)),
timings,
warnings: this.warnings,
imports,

@ -82,7 +82,7 @@ export default function compile(source: string, options: CompileOptions = {}) {
stats.stop('create component');
if (options.generate === false) {
return { ast, stats: stats.render(null), js: null, css: null };
return { ast, stats: stats.render(component), js: null, css: null };
}
if (options.generate === 'ssr') {

@ -0,0 +1,5 @@
export default {
test(assert, stats) {
assert.deepEqual(stats.props.sort(), ['cats', 'foo', 'name']);
}
};

@ -0,0 +1,23 @@
<h1>Hello {name}!</h1>
<ul>
{#each cats as cat}
<li><a target="_blank" href={cat.video}>{cat.name}</a></li>
{/each}
</ul>
<p>bar: {bar}</p>
<script>
export default {
data() {
return {
name: 'world'
};
},
computed: {
bar: ({ foo }) => foo * 2
}
};
</script>
Loading…
Cancel
Save