From d4bbdcd7d63ddbf20239c95d1ba1cee9030d7e95 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 30 Jan 2017 12:02:55 -0500 Subject: [PATCH] Raise an error if a widget doesn't have a key but uses state --- app/assets/javascripts/discourse/widgets/widget.js.es6 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/widgets/widget.js.es6 b/app/assets/javascripts/discourse/widgets/widget.js.es6 index 0b3e169a46f..25c598e1eb9 100644 --- a/app/assets/javascripts/discourse/widgets/widget.js.es6 +++ b/app/assets/javascripts/discourse/widgets/widget.js.es6 @@ -145,12 +145,12 @@ export default class Widget { this.keyValueStore = register.lookup('key-value-store:main'); // Helps debug widgets - if (Ember.testing) { + if (Discourse.Environment === "development" || Ember.testing) { const ds = this.defaultState(attrs); if (typeof ds !== "object") { - Ember.warn(`defaultState must return an object`); + throw `defaultState must return an object`; } else if (Object.keys(ds).length > 0 && !this.key) { - Ember.warn(`you need a key when using state ${this.name}`); + throw `you need a key when using state in ${this.name}`; } }