mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-10 14:04:35 -04:00
Better warning message if defaultState
is used improperly
This commit is contained in:
parent
55ba81494f
commit
d89fb6e83e
1 changed files with 5 additions and 2 deletions
|
@ -125,8 +125,11 @@ export default class Widget {
|
|||
this.key = this.buildKey ? this.buildKey(attrs) : null;
|
||||
|
||||
// Helps debug widgets
|
||||
if (Ember.Test) {
|
||||
if (Object.keys(this.defaultState(attrs)).length > 0 && !this.key) {
|
||||
if (Ember.testing) {
|
||||
const ds = this.defaultState(attrs);
|
||||
if (typeof ds !== "object") {
|
||||
Ember.warn(`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}`);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue