mirror of https://github.com/sveltejs/svelte
commit
3d50a212b6
@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
options: {
|
||||||
|
dev: true
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,109 @@
|
|||||||
|
/* generated by Svelte vX.Y.Z */
|
||||||
|
import {
|
||||||
|
SvelteComponentDev,
|
||||||
|
dispatch_dev,
|
||||||
|
init,
|
||||||
|
loop_guard,
|
||||||
|
noop,
|
||||||
|
safe_not_equal
|
||||||
|
} from "svelte/internal";
|
||||||
|
|
||||||
|
const file = undefined;
|
||||||
|
|
||||||
|
function create_fragment(ctx) {
|
||||||
|
const block = {
|
||||||
|
c: noop,
|
||||||
|
l: function claim(nodes) {
|
||||||
|
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
|
||||||
|
},
|
||||||
|
m: noop,
|
||||||
|
p: noop,
|
||||||
|
i: noop,
|
||||||
|
o: noop,
|
||||||
|
d: noop
|
||||||
|
};
|
||||||
|
|
||||||
|
dispatch_dev("SvelteRegisterBlock", {
|
||||||
|
block,
|
||||||
|
id: create_fragment.name,
|
||||||
|
type: "component",
|
||||||
|
source: "",
|
||||||
|
ctx
|
||||||
|
});
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
function instance($$self) {
|
||||||
|
const guard = loop_guard();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
foo();
|
||||||
|
guard();
|
||||||
|
}
|
||||||
|
|
||||||
|
const guard_1 = loop_guard();
|
||||||
|
|
||||||
|
for (; ; ) {
|
||||||
|
foo();
|
||||||
|
guard_1();
|
||||||
|
}
|
||||||
|
|
||||||
|
const guard_2 = loop_guard();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
foo();
|
||||||
|
guard_2();
|
||||||
|
}
|
||||||
|
|
||||||
|
const guard_4 = loop_guard();
|
||||||
|
|
||||||
|
do {
|
||||||
|
foo();
|
||||||
|
guard_4();
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
$$self.$capture_state = () => {
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
|
$$self.$inject_state = $$props => {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
$: {
|
||||||
|
const guard_3 = loop_guard();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
foo();
|
||||||
|
guard_3();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$: {
|
||||||
|
const guard_5 = loop_guard();
|
||||||
|
|
||||||
|
do {
|
||||||
|
foo();
|
||||||
|
guard_5();
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
class Component extends SvelteComponentDev {
|
||||||
|
constructor(options) {
|
||||||
|
super(options);
|
||||||
|
init(this, options, instance, create_fragment, safe_not_equal, {});
|
||||||
|
|
||||||
|
dispatch_dev("SvelteRegisterComponent", {
|
||||||
|
component: this,
|
||||||
|
tagName: "Component",
|
||||||
|
options,
|
||||||
|
id: create_fragment.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Component;
|
@ -0,0 +1,12 @@
|
|||||||
|
<script>
|
||||||
|
while(true) {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
for(;;) {
|
||||||
|
foo();
|
||||||
|
}
|
||||||
|
while(true) foo();
|
||||||
|
$: while(true) foo();
|
||||||
|
do foo(); while(true);
|
||||||
|
$: do foo(); while(true);
|
||||||
|
</script>
|
@ -0,0 +1,33 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button></button>
|
||||||
|
<input type=range min=0 max=10>
|
||||||
|
<p>10 of 10</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
ssrHtml: `
|
||||||
|
<button></button>
|
||||||
|
<input type=range min=0 max=10 value=10>
|
||||||
|
<p>10 of 10</p>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, target, window }) {
|
||||||
|
const input = target.querySelector('input');
|
||||||
|
assert.equal(input.value, '10');
|
||||||
|
|
||||||
|
// should not change because max is 10, input range behaviour
|
||||||
|
// seems there is bug in jsdom (HTMLInputElement-impl) which behaviour is different from real browsers
|
||||||
|
// input.value = '20';
|
||||||
|
// assert.equal(input.value, '10');
|
||||||
|
|
||||||
|
const button = target.querySelector('button');
|
||||||
|
await button.dispatchEvent(new window.Event('click'));
|
||||||
|
|
||||||
|
assert.equal(input.value, '20');
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button></button>
|
||||||
|
<input type=range min=0 max=20>
|
||||||
|
<p>20 of 20</p>
|
||||||
|
`);
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let value=10;
|
||||||
|
let max=10;
|
||||||
|
|
||||||
|
function change() {
|
||||||
|
value=20;
|
||||||
|
max=20;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={change}/>
|
||||||
|
<input type=range min=0 max={max} bind:value>
|
||||||
|
<p>{value} of {max}</p>
|
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
export let count
|
||||||
|
|
||||||
|
function handleClick() {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={handleClick}>
|
||||||
|
button {count}
|
||||||
|
</button>
|
@ -0,0 +1,38 @@
|
|||||||
|
export default {
|
||||||
|
html: `
|
||||||
|
<button>main 0</button>
|
||||||
|
<button>button 0</button>
|
||||||
|
`,
|
||||||
|
|
||||||
|
async test({ assert, component, target, window }) {
|
||||||
|
const event = new window.MouseEvent('click');
|
||||||
|
|
||||||
|
const buttons = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
await buttons[0].dispatchEvent(event);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>main 1</button>
|
||||||
|
<button>button 1</button>
|
||||||
|
`);
|
||||||
|
|
||||||
|
await buttons[1].dispatchEvent(event);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>main 2</button>
|
||||||
|
<button>button 2</button>
|
||||||
|
`);
|
||||||
|
|
||||||
|
// reactive update, reset to 2
|
||||||
|
await buttons[0].dispatchEvent(event);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>main 2</button>
|
||||||
|
<button>button 2</button>
|
||||||
|
`);
|
||||||
|
|
||||||
|
// bound to main, reset to 2
|
||||||
|
await buttons[1].dispatchEvent(event);
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<button>main 2</button>
|
||||||
|
<button>button 2</button>
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,19 @@
|
|||||||
|
<script>
|
||||||
|
import Button from './Button.svelte';
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
$: if (count > 2) {
|
||||||
|
count = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClick() {
|
||||||
|
count += 1;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={handleClick}>
|
||||||
|
main {count}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<Button bind:count />
|
@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
error: 'Infinite loop detected',
|
||||||
|
compileOptions: {
|
||||||
|
dev: true,
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,5 @@
|
|||||||
|
<script>
|
||||||
|
while(true) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in new issue