diff --git a/hsp/rt/cptcomponent.js b/hsp/rt/cptcomponent.js index 992babf..444a77f 100644 --- a/hsp/rt/cptcomponent.js +++ b/hsp/rt/cptcomponent.js @@ -87,7 +87,9 @@ exports.$CptComponent = { for (var i = 0, sz = this.atts.length; sz > i; i++) { att = atts[i]; nm = att.name; - if (this.ctlAttributes[nm].type!=="template") { + if (!this.ctlAttributes || !this.ctlAttributes[nm]) { + throw new Error('The attribute "' + nm + '" was used but the component doesn\'t define this attribute.'); + } else if (this.ctlAttributes[nm].type!=="template") { attributes[nm]=att.getValue(eh, pvs, null); } } diff --git a/test/rt/cpterrors.spec.hsp b/test/rt/cpterrors.spec.hsp new file mode 100644 index 0000000..c87a58a --- /dev/null +++ b/test/rt/cpterrors.spec.hsp @@ -0,0 +1,51 @@ +var klass=require("hsp/klass"), + ht=require("hsp/utils/hashtester"); + +var FooNoAttrsCtrl=klass({ +}); + +var FooEmptyAttrsCtrl=klass({ + attributes: { + } +}); + +{template fooNoAttrs using ctrl:FooNoAttrsCtrl} +