mirror of https://github.com/sveltejs/svelte
parent
daa2635cd3
commit
2f86bd339d
@ -1,14 +1,12 @@
|
|||||||
export default {
|
export default {
|
||||||
test ( assert, component ) {
|
test(assert, component) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
component.observe( 'bar', () => {
|
component.on('state', ({ changed }) => {
|
||||||
count += 1;
|
if (changed.bar) count += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
component.set({ x: true });
|
component.set({ x: true });
|
||||||
assert.equal( count, 1 );
|
assert.equal(count, 0);
|
||||||
|
|
||||||
component.destroy();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
export default {
|
|
||||||
dev: true,
|
|
||||||
|
|
||||||
error ( assert, err ) {
|
|
||||||
assert.equal( err.message, `The first argument to component.observe(...) must be the name of a top-level property, i.e. 'nested' rather than 'nested.data'` );
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
<script>
|
|
||||||
export default {
|
|
||||||
oncreate () {
|
|
||||||
this.observe( 'nested.data', data => {
|
|
||||||
console.log( 'nope' );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,7 +0,0 @@
|
|||||||
export default {
|
|
||||||
dev: true,
|
|
||||||
|
|
||||||
warnings: [
|
|
||||||
`Return 'destroy()' from custom event handlers. Returning 'teardown()' has been deprecated and will be unsupported in Svelte 2`
|
|
||||||
]
|
|
||||||
};
|
|
@ -1,16 +0,0 @@
|
|||||||
<button on:foo='foo()'>foo</button>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
methods: {
|
|
||||||
foo() {}
|
|
||||||
},
|
|
||||||
events: {
|
|
||||||
foo(node, callback) {
|
|
||||||
return {
|
|
||||||
teardown() {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,7 +0,0 @@
|
|||||||
export default {
|
|
||||||
dev: true,
|
|
||||||
|
|
||||||
warnings: [
|
|
||||||
`Use component.on('destroy', ...) instead of component.on('teardown', ...) which has been deprecated and will be unsupported in Svelte 2`
|
|
||||||
]
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
<script>
|
|
||||||
export default {
|
|
||||||
oncreate () {
|
|
||||||
this.on( 'teardown', () => {
|
|
||||||
this.destroyed = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -1,7 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
test ( assert, component ) {
|
test ( assert, component ) {
|
||||||
assert.equal( component.get('a'), 1 );
|
assert.equal( component.get().a, 1 );
|
||||||
assert.equal( component.get('c'), 3 );
|
assert.equal( component.get().c, 3 );
|
||||||
assert.deepEqual( component.get(), { a: 1, b: 2, c: 3 });
|
assert.deepEqual( component.get(), { a: 1, b: 2, c: 3 });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
<h3>Called {{count}} times.</h3>
|
<h3>Called {{count}} times.</h3>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
immutable: false,
|
immutable: false,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
count: 0,
|
count: 0,
|
||||||
foo: { bar: 'baz' }
|
foo: { bar: 'baz' }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -1,15 +1,15 @@
|
|||||||
export default {
|
export default {
|
||||||
test ( assert, component ) {
|
test(assert, component) {
|
||||||
const foo = component.refs.foo;
|
const foo = component.refs.foo;
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
foo.observe( 'x', () => {
|
foo.on('state', ({ changed }) => {
|
||||||
count += 1;
|
if (changed.foo) count += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal( count, 1 );
|
assert.equal(count, 0);
|
||||||
|
|
||||||
component.set({ y: {} });
|
component.set({ y: {} });
|
||||||
assert.equal( count, 1 );
|
assert.equal(count, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
<div>{{foo.x}}</div>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
oncreate () {
|
|
||||||
this.observe( 'foo', foo => {
|
|
||||||
const bar = this.get( 'bar' );
|
|
||||||
if ( foo.x !== bar.x ) throw new Error( 'mismatch' );
|
|
||||||
});
|
|
||||||
|
|
||||||
this.observe( 'bar', bar => {
|
|
||||||
const foo = this.get( 'foo' );
|
|
||||||
if ( foo.x !== bar.x ) throw new Error( 'mismatch' );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
@ -0,0 +1,13 @@
|
|||||||
|
<div>{{foo.x}}</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
onstate({ current, changed }) {
|
||||||
|
if (changed.foo || changed.bar) {
|
||||||
|
if (current.foo.x !== current.bar.x) {
|
||||||
|
throw new Error('mismatch');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue