mirror of https://github.com/sveltejs/svelte
feat: simpler output for reactive vars if dependencies are all static (#7942)
parent
c9a269c149
commit
53de73d08c
@ -0,0 +1,60 @@
|
|||||||
|
/* generated by Svelte vX.Y.Z */
|
||||||
|
import {
|
||||||
|
SvelteComponent,
|
||||||
|
detach,
|
||||||
|
element,
|
||||||
|
init,
|
||||||
|
insert,
|
||||||
|
noop,
|
||||||
|
safe_not_equal,
|
||||||
|
set_data,
|
||||||
|
space,
|
||||||
|
text
|
||||||
|
} from "svelte/internal";
|
||||||
|
|
||||||
|
function create_fragment(ctx) {
|
||||||
|
let h1;
|
||||||
|
let t3;
|
||||||
|
let t4;
|
||||||
|
|
||||||
|
return {
|
||||||
|
c() {
|
||||||
|
h1 = element("h1");
|
||||||
|
h1.textContent = `Hello ${name}!`;
|
||||||
|
t3 = space();
|
||||||
|
t4 = text(/*foo*/ ctx[0]);
|
||||||
|
},
|
||||||
|
m(target, anchor) {
|
||||||
|
insert(target, h1, anchor);
|
||||||
|
insert(target, t3, anchor);
|
||||||
|
insert(target, t4, anchor);
|
||||||
|
},
|
||||||
|
p(ctx, [dirty]) {
|
||||||
|
if (dirty & /*foo*/ 1) set_data(t4, /*foo*/ ctx[0]);
|
||||||
|
},
|
||||||
|
i: noop,
|
||||||
|
o: noop,
|
||||||
|
d(detaching) {
|
||||||
|
if (detaching) detach(h1);
|
||||||
|
if (detaching) detach(t3);
|
||||||
|
if (detaching) detach(t4);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let name = 'world';
|
||||||
|
|
||||||
|
function instance($$self) {
|
||||||
|
let foo;
|
||||||
|
$: foo = name + name;
|
||||||
|
return [foo];
|
||||||
|
}
|
||||||
|
|
||||||
|
class Component extends SvelteComponent {
|
||||||
|
constructor(options) {
|
||||||
|
super();
|
||||||
|
init(this, options, instance, create_fragment, safe_not_equal, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Component;
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
let name = 'world';
|
||||||
|
$: foo = name + name;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1>Hello {name}!</h1>
|
||||||
|
{foo}
|
Loading…
Reference in new issue