-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
...sts/snapshot/samples/static-template-expression-evaluation/_expected/_expected/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { test } from '../../test'; | ||
|
||
export default test({}); |
58 changes: 58 additions & 0 deletions
58
...tatic-template-expression-evaluation/_expected/_expected/_expected/client/index.svelte.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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']); |
13 changes: 13 additions & 0 deletions
13
...tatic-template-expression-evaluation/_expected/_expected/_expected/server/index.svelte.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 += `<!---->`; | ||
} |
16 changes: 16 additions & 0 deletions
16
...s/snapshot/samples/static-template-expression-evaluation/_expected/_expected/index.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} /> |