mirror of https://github.com/sveltejs/svelte
parent
c5b639c108
commit
0cb62125c1
@ -1,14 +1,16 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Await_block_scope($$payload) {
|
||||
let counter = { count: 0 };
|
||||
const promise = Promise.resolve(counter);
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let counter = { count: 0 };
|
||||
const promise = Promise.resolve(counter);
|
||||
|
||||
function increment() {
|
||||
counter.count += 1;
|
||||
}
|
||||
function increment() {
|
||||
counter.count += 1;
|
||||
}
|
||||
|
||||
$$payload.out.push(`<button>clicks: ${$.escape(counter.count)}</button> `);
|
||||
$.await($$payload, promise, () => {}, (counter) => {});
|
||||
$$payload.out.push(`<!--]--> ${$.escape(counter.count)}`);
|
||||
$$payload.out.push(`<button>clicks: ${$.escape(counter.count)}</button> `);
|
||||
$.await($$payload, promise, () => {}, (counter) => {});
|
||||
$$payload.out.push(`<!--]--> ${$.escape(counter.count)}`);
|
||||
});
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Bind_this($$payload) {
|
||||
Foo($$payload, {});
|
||||
$$payload.child(({ $$payload }) => {
|
||||
Foo($$payload, {});
|
||||
});
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Delegated_locally_declared_shadowed($$payload) {
|
||||
const each_array = $.ensure_array_like({ length: 1 });
|
||||
$$payload.child(({ $$payload }) => {
|
||||
const each_array = $.ensure_array_like({ length: 1 });
|
||||
|
||||
$$payload.out.push(`<!--[-->`);
|
||||
$$payload.out.push(`<!--[-->`);
|
||||
|
||||
for (let index = 0, $$length = each_array.length; index < $$length; index++) {
|
||||
$$payload.out.push(`<button type="button"${$.attr('data-index', index)}>B</button>`);
|
||||
}
|
||||
for (let index = 0, $$length = each_array.length; index < $$length; index++) {
|
||||
$$payload.out.push(`<button type="button"${$.attr('data-index', index)}>B</button>`);
|
||||
}
|
||||
|
||||
$$payload.out.push(`<!--]-->`);
|
||||
$$payload.out.push(`<!--]-->`);
|
||||
});
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Main($$payload) {
|
||||
// needs to be a snapshot test because jsdom does auto-correct the attribute casing
|
||||
let x = 'test';
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let x = 'test';
|
||||
let y = () => 'test';
|
||||
|
||||
let y = () => 'test';
|
||||
|
||||
$$payload.out.push(`<div${$.attr('foobar', x)}></div> <svg${$.attr('viewBox', x)}></svg> <custom-element${$.attr('foobar', x)}></custom-element> <div${$.attr('foobar', y())}></div> <svg${$.attr('viewBox', y())}></svg> <custom-element${$.attr('foobar', y())}></custom-element>`);
|
||||
$$payload.out.push(`<div${$.attr('foobar', x)}></div> <svg${$.attr('viewBox', x)}></svg> <custom-element${$.attr('foobar', x)}></custom-element> <div${$.attr('foobar', y())}></div> <svg${$.attr('viewBox', y())}></svg> <custom-element${$.attr('foobar', y())}></custom-element>`);
|
||||
});
|
||||
}
|
@ -1,13 +1,15 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Each_index_non_null($$payload) {
|
||||
const each_array = $.ensure_array_like(Array(10));
|
||||
$$payload.child(({ $$payload }) => {
|
||||
const each_array = $.ensure_array_like(Array(10));
|
||||
|
||||
$$payload.out.push(`<!--[-->`);
|
||||
$$payload.out.push(`<!--[-->`);
|
||||
|
||||
for (let i = 0, $$length = each_array.length; i < $$length; i++) {
|
||||
$$payload.out.push(`<p>index: ${$.escape(i)}</p>`);
|
||||
}
|
||||
for (let i = 0, $$length = each_array.length; i < $$length; i++) {
|
||||
$$payload.out.push(`<p>index: ${$.escape(i)}</p>`);
|
||||
}
|
||||
|
||||
$$payload.out.push(`<!--]-->`);
|
||||
$$payload.out.push(`<!--]-->`);
|
||||
});
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Each_string_template($$payload) {
|
||||
const each_array = $.ensure_array_like(['foo', 'bar', 'baz']);
|
||||
$$payload.child(({ $$payload }) => {
|
||||
const each_array = $.ensure_array_like(['foo', 'bar', 'baz']);
|
||||
|
||||
$$payload.out.push(`<!--[-->`);
|
||||
$$payload.out.push(`<!--[-->`);
|
||||
|
||||
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
||||
let thing = each_array[$$index];
|
||||
for (let $$index = 0, $$length = each_array.length; $$index < $$length; $$index++) {
|
||||
let thing = each_array[$$index];
|
||||
|
||||
$$payload.out.push(`<!---->${$.escape(thing)}, `);
|
||||
}
|
||||
$$payload.out.push(`<!---->${$.escape(thing)}, `);
|
||||
}
|
||||
|
||||
$$payload.out.push(`<!--]-->`);
|
||||
$$payload.out.push(`<!--]-->`);
|
||||
});
|
||||
}
|
@ -1,23 +1,27 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Function_prop_no_getter($$payload) {
|
||||
let count = 0;
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let count = 0;
|
||||
|
||||
function onmouseup() {
|
||||
count += 2;
|
||||
}
|
||||
function onmouseup() {
|
||||
count += 2;
|
||||
}
|
||||
|
||||
const plusOne = (num) => num + 1;
|
||||
const plusOne = (num) => num + 1;
|
||||
|
||||
Button($$payload, {
|
||||
onmousedown: () => count += 1,
|
||||
onmouseup,
|
||||
onmouseenter: () => count = plusOne(count),
|
||||
Button($$payload, {
|
||||
onmousedown: () => count += 1,
|
||||
onmouseup,
|
||||
onmouseenter: () => count = plusOne(count),
|
||||
|
||||
children: ($$payload) => {
|
||||
$$payload.out.push(`<!---->clicks: ${$.escape(count)}`);
|
||||
},
|
||||
children: ($$payload) => {
|
||||
$$payload.child(({ $$payload }) => {
|
||||
$$payload.out.push(`<!---->clicks: ${$.escape(count)}`);
|
||||
});
|
||||
},
|
||||
|
||||
$$slots: { default: true }
|
||||
$$slots: { default: true }
|
||||
});
|
||||
});
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Functional_templating($$payload) {
|
||||
$$payload.out.push(`<h1>hello</h1> <div class="potato"><p>child element</p> <p>another child element</p></div>`);
|
||||
$$payload.child(({ $$payload }) => {
|
||||
$$payload.out.push(`<h1>hello</h1> <div class="potato"><p>child element</p> <p>another child element</p></div>`);
|
||||
});
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Hello_world($$payload) {
|
||||
$$payload.out.push(`<h1>hello world</h1>`);
|
||||
$$payload.child(({ $$payload }) => {
|
||||
$$payload.out.push(`<h1>hello world</h1>`);
|
||||
});
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Hmr($$payload) {
|
||||
$$payload.out.push(`<h1>hello world</h1>`);
|
||||
$$payload.child(({ $$payload }) => {
|
||||
$$payload.out.push(`<h1>hello world</h1>`);
|
||||
});
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
import { random } from './module.svelte';
|
||||
|
||||
export default function Imports_in_modules($$payload) {}
|
||||
export default function Imports_in_modules($$payload) {
|
||||
$$payload.child(({ $$payload }) => {});
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Nullish_coallescence_omittance($$payload) {
|
||||
let name = 'world';
|
||||
let count = 0;
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let name = 'world';
|
||||
let count = 0;
|
||||
|
||||
$$payload.out.push(`<h1>Hello, world!</h1> <b>123</b> <button>Count is ${$.escape(count)}</button> <h1>Hello, world</h1>`);
|
||||
$$payload.out.push(`<h1>Hello, world!</h1> <b>123</b> <button>Count is ${$.escape(count)}</button> <h1>Hello, world</h1>`);
|
||||
});
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Purity($$payload) {
|
||||
$$payload.out.push(`<p>0</p> <p>${$.escape(location.href)}</p> `);
|
||||
Child($$payload, { prop: encodeURIComponent('hello') });
|
||||
$$payload.out.push(`<!---->`);
|
||||
$$payload.child(({ $$payload }) => {
|
||||
$$payload.out.push(`<p>0</p> <p>${$.escape(location.href)}</p> `);
|
||||
Child($$payload, { prop: encodeURIComponent('hello') });
|
||||
$$payload.out.push(`<!---->`);
|
||||
});
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Skip_static_subtree($$payload, $$props) {
|
||||
let { title, content } = $$props;
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let { title, content } = $$props;
|
||||
|
||||
$$payload.out.push(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)} <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements with="attributes"></custom-elements></cant-skip> <div><input autofocus/></div> <div><source muted/></div> <select><option value="a"${$.maybe_selected($$payload, 'a')}>a</option></select> <img src="..." alt="" loading="lazy"/> <div><img src="..." alt="" loading="lazy"/></div>`);
|
||||
$$payload.out.push(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)} <p>these</p> <p>trailing</p> <p>nodes</p> <p>can</p> <p>be</p> <p>completely</p> <p>ignored</p></main> <cant-skip><custom-elements with="attributes"></custom-elements></cant-skip> <div><input autofocus/></div> <div><source muted/></div> <select><option value="a"${$.maybe_selected($$payload, 'a')}>a</option></select> <img src="..." alt="" loading="lazy"/> <div><img src="..." alt="" loading="lazy"/></div>`);
|
||||
});
|
||||
}
|
@ -1,15 +1,17 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function State_proxy_literal($$payload) {
|
||||
let str = '';
|
||||
let tpl = ``;
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let str = '';
|
||||
let tpl = ``;
|
||||
|
||||
function reset() {
|
||||
str = '';
|
||||
str = ``;
|
||||
tpl = '';
|
||||
tpl = ``;
|
||||
}
|
||||
function reset() {
|
||||
str = '';
|
||||
str = ``;
|
||||
tpl = '';
|
||||
tpl = ``;
|
||||
}
|
||||
|
||||
$$payload.out.push(`<input${$.attr('value', str)}/> <input${$.attr('value', tpl)}/> <button>reset</button>`);
|
||||
$$payload.out.push(`<input${$.attr('value', str)}/> <input${$.attr('value', tpl)}/> <button>reset</button>`);
|
||||
});
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Svelte_element($$payload, $$props) {
|
||||
let { tag = 'hr' } = $$props;
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let { tag = 'hr' } = $$props;
|
||||
|
||||
$.element($$payload, tag);
|
||||
$.element($$payload, tag);
|
||||
});
|
||||
}
|
@ -1,16 +1,18 @@
|
||||
import * as $ from 'svelte/internal/server';
|
||||
|
||||
export default function Text_nodes_deriveds($$payload) {
|
||||
let count1 = 0;
|
||||
let count2 = 0;
|
||||
$$payload.child(({ $$payload }) => {
|
||||
let count1 = 0;
|
||||
let count2 = 0;
|
||||
|
||||
function text1() {
|
||||
return count1;
|
||||
}
|
||||
function text1() {
|
||||
return count1;
|
||||
}
|
||||
|
||||
function text2() {
|
||||
return count2;
|
||||
}
|
||||
function text2() {
|
||||
return count2;
|
||||
}
|
||||
|
||||
$$payload.out.push(`<p>${$.escape(text1())}${$.escape(text2())}</p>`);
|
||||
$$payload.out.push(`<p>${$.escape(text1())}${$.escape(text2())}</p>`);
|
||||
});
|
||||
}
|
Loading…
Reference in new issue