mirror of https://github.com/sveltejs/svelte
Merge pull request #463 from sveltejs/readonly-dev-warning
In dev mode, throw if user sets a read-only propertypull/471/head
commit
262f4aaf49
@ -0,0 +1,12 @@
|
||||
export default {
|
||||
dev: true,
|
||||
|
||||
test ( assert, component ) {
|
||||
try {
|
||||
component.set({ foo: 1 });
|
||||
throw new Error( 'Expected an error' );
|
||||
} catch ( err ) {
|
||||
assert.equal( err.message, `Cannot set read-only property 'foo'` );
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1,7 @@
|
||||
<script>
|
||||
export default {
|
||||
computed: {
|
||||
foo: a => a + 1
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,12 @@
|
||||
export default {
|
||||
dev: true,
|
||||
|
||||
test ( assert, component ) {
|
||||
try {
|
||||
component.set({ width: 99 });
|
||||
throw new Error( 'Expected an error' );
|
||||
} catch ( err ) {
|
||||
assert.equal( err.message, `Cannot set read-only property 'width'` );
|
||||
}
|
||||
}
|
||||
};
|
@ -0,0 +1 @@
|
||||
<:Window bind:innerWidth='width'/>
|
Loading…
Reference in new issue