mirror of https://github.com/sveltejs/svelte
commit
cde666a40e
@ -0,0 +1,53 @@
|
|||||||
|
/* generated by Svelte vX.Y.Z */
|
||||||
|
import {
|
||||||
|
SvelteComponent,
|
||||||
|
detach,
|
||||||
|
init,
|
||||||
|
insert,
|
||||||
|
noop,
|
||||||
|
safe_not_equal,
|
||||||
|
space,
|
||||||
|
text
|
||||||
|
} from "svelte/internal";
|
||||||
|
|
||||||
|
function create_fragment(ctx) {
|
||||||
|
let t0;
|
||||||
|
let t1;
|
||||||
|
let t2_value = import.meta.url + "";
|
||||||
|
let t2;
|
||||||
|
|
||||||
|
return {
|
||||||
|
c() {
|
||||||
|
t0 = text(/*url*/ ctx[0]);
|
||||||
|
t1 = space();
|
||||||
|
t2 = text(t2_value);
|
||||||
|
},
|
||||||
|
m(target, anchor) {
|
||||||
|
insert(target, t0, anchor);
|
||||||
|
insert(target, t1, anchor);
|
||||||
|
insert(target, t2, anchor);
|
||||||
|
},
|
||||||
|
p: noop,
|
||||||
|
i: noop,
|
||||||
|
o: noop,
|
||||||
|
d(detaching) {
|
||||||
|
if (detaching) detach(t0);
|
||||||
|
if (detaching) detach(t1);
|
||||||
|
if (detaching) detach(t2);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function instance($$self) {
|
||||||
|
const url = import.meta.url;
|
||||||
|
return [url];
|
||||||
|
}
|
||||||
|
|
||||||
|
class Component extends SvelteComponent {
|
||||||
|
constructor(options) {
|
||||||
|
super();
|
||||||
|
init(this, options, instance, create_fragment, safe_not_equal, {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Component;
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
const url = import.meta.url;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{url}
|
||||||
|
{import.meta.url}
|
@ -0,0 +1,8 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>action</button>
|
||||||
|
`,
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
assert.equal(target.querySelector('button').foo, 'bar1337');
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,10 @@
|
|||||||
|
<script>
|
||||||
|
const obj = {
|
||||||
|
foo : "bar",
|
||||||
|
action(element, { leet }) {
|
||||||
|
element.foo = this.foo + leet;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button use:obj.action={{ leet: 1337 }}>action</button>
|
@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
html: `2048 2048`
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
const num = 2_048;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{num} {2_048}
|
@ -0,0 +1,32 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<p>a: {"foo":3,"bar":2}</p>
|
||||||
|
<p>b: {"foo":3}</p>
|
||||||
|
<button></button>
|
||||||
|
<button></button>
|
||||||
|
`,
|
||||||
|
skip_if_ssr: true,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const [btn1, btn2] = target.querySelectorAll('button');
|
||||||
|
const click = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
await btn1.dispatchEvent(click);
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>a: {"foo":4,"bar":2}</p>
|
||||||
|
<p>b: {"foo":4,"baz":0}</p>
|
||||||
|
<button></button>
|
||||||
|
<button></button>
|
||||||
|
`);
|
||||||
|
|
||||||
|
await btn2.dispatchEvent(click);
|
||||||
|
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>a: {"foo":5,"bar":2}</p>
|
||||||
|
<p>b: {"foo":5,"qux":0}</p>
|
||||||
|
<button></button>
|
||||||
|
<button></button>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,24 @@
|
|||||||
|
<script>
|
||||||
|
import { writable } from '../../../../store';
|
||||||
|
|
||||||
|
const a = writable({ foo: 1, bar: 2 });
|
||||||
|
$a.foo = 3;
|
||||||
|
|
||||||
|
const b = writable({ foo: 1, bar: 2 });
|
||||||
|
$b = { foo: 3 };
|
||||||
|
|
||||||
|
function update() {
|
||||||
|
$a.foo = $a.foo + 1;
|
||||||
|
$b = { foo: $b.foo + 1, qux: 0 };
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>a: {JSON.stringify($a)}</p>
|
||||||
|
<p>b: {JSON.stringify($b)}</p>
|
||||||
|
|
||||||
|
<button on:click={() => {
|
||||||
|
$a.foo = $a.foo + 1;
|
||||||
|
$b = { foo: $b.foo + 1, baz: 0 };
|
||||||
|
}} />
|
||||||
|
|
||||||
|
<button on:click={update} />
|
@ -0,0 +1 @@
|
|||||||
|
[]
|
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
const url = import.meta.url;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{url}
|
||||||
|
{import.meta.url}
|
Loading…
Reference in new issue