mirror of https://github.com/sveltejs/svelte
parent
ed39c85f5d
commit
be59af940b
@ -1,6 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let count = 0;
|
|
||||||
export let foo = { bar: 'baz' };
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h3>Called {count} times.</h3>
|
|
@ -1,18 +0,0 @@
|
|||||||
export default {
|
|
||||||
immutable: true,
|
|
||||||
html: `<div><h3>Called 0 times.</h3></div>`,
|
|
||||||
|
|
||||||
test(assert, component, target, window) {
|
|
||||||
var nested = component.nested;
|
|
||||||
nested.on('state', ({ changed }) => {
|
|
||||||
if (changed.foo) {
|
|
||||||
nested.set({ count: nested.get().count + 1 });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.htmlEqual(target.innerHTML, `<div><h3>Called 0 times.</h3></div>`);
|
|
||||||
|
|
||||||
nested.set({ foo: nested.get().foo });
|
|
||||||
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`);
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
<script>
|
|
||||||
export let nested;
|
|
||||||
|
|
||||||
import Nested from './Nested.html';
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<Nested ref:nested />
|
|
||||||
</div>
|
|
@ -1,6 +1,17 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { beforeRender, onMount } from 'svelte';
|
||||||
|
|
||||||
|
let mounted;
|
||||||
export let count = 0;
|
export let count = 0;
|
||||||
export let foo = { bar: 'baz' };
|
export let foo = { bar: 'baz' };
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
mounted = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeRender(() => {
|
||||||
|
if (mounted) count += 1;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h3>Called {count} times.</h3>
|
<h3>Called {count} times.</h3>
|
@ -1,18 +1,13 @@
|
|||||||
export default {
|
export default {
|
||||||
immutable: true,
|
immutable: true,
|
||||||
html: `<div><h3>Called 0 times.</h3></div>`,
|
html: `<div><h3>Called 1 times.</h3></div>`,
|
||||||
|
|
||||||
test(assert, component, target, window) {
|
test(assert, component, target, window) {
|
||||||
var nested = component.nested;
|
var nested = component.nested;
|
||||||
nested.on('state', ({ changed }) => {
|
|
||||||
if (changed.foo) {
|
|
||||||
nested.set({ count: nested.get().count + 1 });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
assert.htmlEqual(target.innerHTML, `<div><h3>Called 0 times.</h3></div>`);
|
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`);
|
||||||
|
|
||||||
nested.set({ foo: nested.get().foo });
|
nested.foo = nested.foo;
|
||||||
assert.htmlEqual(target.innerHTML, `<div><h3>Called 0 times.</h3></div>`);
|
assert.htmlEqual(target.innerHTML, `<div><h3>Called 1 times.</h3></div>`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in new issue