You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/test/compiler/observe-prevents-loop/_config.js

28 lines
438 B

export default {
data: {
thing: { a: 1 }
},
test ( assert, component ) {
const thing = component.get( 'thing' );
component.observe( 'thing', function ( thing ) {
thing.b = thing.a * 2;
this.set({ thing }); // triggers infinite loop, unless observer breaks it
});
assert.deepEqual( thing, {
a: 1,
b: 2
});
thing.a = 3;
component.set({ thing });
assert.deepEqual( thing, {
a: 3,
b: 6
});
}
};