ember-forge / ember-forge-ui

Ember.js UI Components that are independent of any specific CSS framework
MIT License
1 stars 2 forks source link

Should !Array.isArray() checks also be contained within the observers and computed properties? #146

Open notmessenger opened 8 years ago

notmessenger commented 8 years ago

In order to ensure that the bound property isn't made into an Array afterwards.

/ember-forge/ember-forge-ui/addon/components/form/ef-error.js:
   67:     if (!isEmpty(property) && !Array.isArray(message)) {
   68        this.message = computed(error, {
   69          get() {

/ember-forge/ember-forge-ui/addon/components/form/input/ef-checkbox.js:
  185:     if (!isEmpty(property) && !Array.isArray(get(this, `data.${property}`)) && !isEmpty(this.getAttr('value'))) {
  186        this.addObserver(`data.${property}`, this, 'initializeState');
  187      }
  ...
  250      } else {
  251        if (get(this, 'isInitializing')) {
  252:         if (!isEmpty(property) && !Array.isArray(get(this, `data.${property}`))) {
  253            Ember.run.scheduleOnce('afterRender', () => {
  254              set(this, 'internalChange', true);

/ember-forge/ember-forge-ui/addon/mixins/form/input/common.js:
  198:     if (!isEmpty(property) && !Array.isArray(get(this, `data.${property}`))) {
  199        this.value = computed(`data.${property}`, {
  200          get() {

Check other instances as well - these were just snapshots of the codebase at the time