mirror of https://github.com/sveltejs/svelte
parent
945973b358
commit
bdc2ac5e2c
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
import 'svelte/internal/disclose-version';
|
||||||
|
import * as $ from 'svelte/internal/client';
|
||||||
|
|
||||||
|
var on_click = (_, count) => $.update(count);
|
||||||
|
var root = $.template(`<h1></h1> <p></p> <button> </button> <p></p> <p></p> <p></p> <!>`, 1);
|
||||||
|
|
||||||
|
export default function App($$anchor) {
|
||||||
|
let a = 1;
|
||||||
|
let b = 2;
|
||||||
|
let name = 'world';
|
||||||
|
let count = $.state(0);
|
||||||
|
|
||||||
|
function Component() {} // placeholder component
|
||||||
|
|
||||||
|
var fragment = root();
|
||||||
|
var h1 = $.first_child(fragment);
|
||||||
|
|
||||||
|
h1.textContent = 'Hello, world!';
|
||||||
|
|
||||||
|
var p = $.sibling(h1, 2);
|
||||||
|
|
||||||
|
p.textContent = '1 + 2 = 3';
|
||||||
|
|
||||||
|
var button = $.sibling(p, 2);
|
||||||
|
|
||||||
|
button.__click = [on_click, count];
|
||||||
|
|
||||||
|
var text = $.child(button);
|
||||||
|
|
||||||
|
$.reset(button);
|
||||||
|
|
||||||
|
var p_1 = $.sibling(button, 2);
|
||||||
|
|
||||||
|
p_1.textContent = '1 + 2 = 3';
|
||||||
|
|
||||||
|
var p_2 = $.sibling(p_1, 2);
|
||||||
|
|
||||||
|
p_2.textContent = 'Sum is 3';
|
||||||
|
|
||||||
|
var p_3 = $.sibling(p_2, 2);
|
||||||
|
|
||||||
|
p_3.textContent = '1';
|
||||||
|
|
||||||
|
var node = $.sibling(p_3, 2);
|
||||||
|
|
||||||
|
Component(node, {
|
||||||
|
a: 1,
|
||||||
|
get count() {
|
||||||
|
return $.get(count);
|
||||||
|
},
|
||||||
|
c: 3
|
||||||
|
});
|
||||||
|
|
||||||
|
$.template_effect(() => $.set_text(text, `Count is ${$.get(count) ?? ''}`));
|
||||||
|
$.append($$anchor, fragment);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.delegate(['click']);
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import * as $ from 'svelte/internal/server';
|
||||||
|
|
||||||
|
export default function App($$payload) {
|
||||||
|
let a = 1;
|
||||||
|
let b = 2;
|
||||||
|
let name = 'world';
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
function Component() {} // placeholder component
|
||||||
|
$$payload.out += `<h1>Hello, ${$.escape(name)}!</h1> <p>${$.escape(a)} + ${$.escape(b)} = ${$.escape(a + b)}</p> <button>Count is ${$.escape(count)}</button> <p>1 + 2 = ${$.escape(1 + 2)}</p> <p>Sum is ${$.escape((a, b, a + b))}</p> <p>${$.escape(a === 1 ? a : b)}</p> `;
|
||||||
|
Component($$payload, { a, count, c: a + b });
|
||||||
|
$$payload.out += `<!---->`;
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
<script>
|
||||||
|
let a = 1;
|
||||||
|
let b = 2;
|
||||||
|
let name = 'world';
|
||||||
|
let count = $state(0);
|
||||||
|
function Component() {
|
||||||
|
// placeholder component
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<h1>Hello, {name}!</h1>
|
||||||
|
<p>{a} + {b} = {a + b}</p>
|
||||||
|
<button onclick={() => count++}>Count is {count}</button>
|
||||||
|
<p>{1} + {2} = {1 + 2}</p>
|
||||||
|
<p>Sum is {(a, b, a + b)}</p>
|
||||||
|
<p>{a === 1 ? a : b}</p>
|
||||||
|
<Component {a} {count} c={a+b} />
|
||||||
Loading…
Reference in new issue