emit dev mode error for bad arguments to set - fixes #990

pull/1004/head
Rich Harris 7 years ago committed by GitHub
parent d10f7fbdbf
commit 81f449093d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -165,15 +165,15 @@ export function _set(newState) {
} }
} }
export function _setDev(newState) { export function setDev(newState) {
if (typeof newState !== 'object') { if (typeof newState !== 'object') {
throw new Error( throw new Error(
this._debugName + ' .set was called without an object of data key-values to update.' this._debugName + '.set was called without an object of data key-values to update.'
); );
} }
this._checkReadOnly(newState); this._checkReadOnly(newState);
_set.call(this, newState); set.call(this, newState);
} }
export function callAll(fns) { export function callAll(fns) {
@ -220,10 +220,10 @@ export var protoDev = {
fire: fire, fire: fire,
observe: observeDev, observe: observeDev,
on: onDev, on: onDev,
set: set, set: setDev,
teardown: destroyDev, teardown: destroyDev,
_recompute: noop, _recompute: noop,
_set: _setDev, _set: _set,
_mount: _mount, _mount: _mount,
_unmount: _unmount _unmount: _unmount
}; };

@ -0,0 +1,7 @@
export default {
dev: true,
error(assert, error) {
assert.equal(error.message, `<Main$>.set was called without an object of data key-values to update.`);
}
};

@ -0,0 +1,11 @@
<script>
export default {
data() {
return { key : false };
},
oncreate() {
this.set("key", true);
}
};
</script>
Loading…
Cancel
Save