You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var klass = require("hsp/klass");
var MyItemCtrl= klass({
attributes: {
"foo" : { type : "string"},
"bar" : { type : "string" }
}
});
module.exports = MyItemCtrl;
hello.hsp
var MyItemCtrl = require("./MyItemCtrl");
{template Hello}
<#myItem foo="FOO" bar="BAR" />
{/template}
{template myItem using ctrl:MyItemCtrl}
foo = {ctrl.foo} <br>
bar = {ctrl.bar} <br>
{/template}
module.exports = Hello;
So far so good, I define attributes in the controller (foo and bar) and pass them from Hello template to <#myItem> and everything works properly.
Now, let's change line 4 in hello.hsp from:
<#myItem foo="FOO" bar="BAR" />
to
<#myItem foo="FOO" bar="BAR" xxx="xxx" />
i.e. let's pass some redundant attrib that is not defined in attributes of the controller.
What we get is a compilation failure plus a cryptic error message:
TypeError: this.ctlAttributes[nm] is undefined
if (this.ctlAttributes[nm].type !== "template") {
I think the code should still compile fine, only raising a warning, with a better description of the issue.
The text was updated successfully, but these errors were encountered:
jakub-g
changed the title
Passing redundant attributes to a component fails the compilations with a cryptic error
Passing redundant attributes to a component fails the compilation with a cryptic error
Jul 24, 2014
Let's consider the following plunk:
http://plnkr.co/edit/pPQWTgkzTLyBdBIX8vfQ?p=preview
MyItemCtrl.js
hello.hsp
So far so good, I define attributes in the controller (
foo
andbar
) and pass them from Hello template to<#myItem>
and everything works properly.Now, let's change line 4 in hello.hsp from:
to
i.e. let's pass some redundant attrib that is not defined in attributes of the controller.
What we get is a compilation failure plus a cryptic error message:
I think the code should still compile fine, only raising a warning, with a better description of the issue.
The text was updated successfully, but these errors were encountered: