Permalink
Browse files

feat(element): warn developer is key on element is not defined

  • Loading branch information...
bas080
bas080 committed Jun 24, 2016
1 parent d2d1af1 commit 88e5c1e514e54f19351e58c5e5754ae1c4f67082
Showing with 15 additions and 2 deletions.
  1. +1 −0 config.js
  2. +1 −0 package.json
  3. +8 −0 src/component/form-field.js
  4. +2 −2 src/component/form-fields.js
  5. +3 −0 src/logger.js
@@ -22,6 +22,7 @@ System.config({
"babel": "npm:babel-core@5.8.38",
"babel-runtime": "npm:babel-runtime@5.8.38",
"core-js": "npm:core-js@1.2.6",
"existy": "npm:existy@1.0.1",
"extend": "npm:extend@3.0.0",
"github:jspm/nodelibs-assert@0.1.0": {
"assert": "npm:assert@1.4.1"
@@ -83,6 +83,7 @@
"aurelia-logging": "npm:aurelia-logging@^1.0.0-beta.1.2.1",
"aurelia-validatejs": "npm:aurelia-validatejs@^0.6.0",
"aurelia-view-manager": "npm:aurelia-view-manager@^0.0.5",
"existy": "npm:existy@^1.0.1",
"extend": "npm:extend@^3.0.0"
},
"devDependencies": {
@@ -1,6 +1,8 @@
import {Config} from '../config';
import {bindingMode, bindable, computedFrom, inject, customElement} from 'aurelia-framework';
import {resolvedView, ViewManager} from 'aurelia-view-manager';
import {logger} from '../logger';
import existy from 'existy';

@customElement('form-field')
@resolvedView('spoonx/form', 'form-field')
@@ -19,6 +21,12 @@ export class FormField {
this.viewManager = viewManager;
}

attached() {
if (!existy(this.element.key)) {
logger.error('an element key propery cannot be null or undefined');
}
}

/**
* Used to determine the what to display
*
@@ -1,6 +1,6 @@
import {bindable, bindingMode, customElement} from 'aurelia-framework';
import {getLogger} from 'aurelia-logging';
import {resolvedView} from 'aurelia-view-manager';
import {logger} from '../logger';

@customElement('form-fields')
@resolvedView('spoonx/form', 'form-fields')
@@ -14,7 +14,7 @@ export class FormFields {

attached() {
if (typeof this.model !== 'object') {
getLogger('aurelia-form').warn(`model is not an object`);
logger.warn(`model is not an object`);
}
}
}
@@ -0,0 +1,3 @@
import {getLogger} from 'aurelia-logging';
const logger = getLogger('aurelia-form');
export {logger};

0 comments on commit 88e5c1e

Please sign in to comment.