Opened 14 years ago
Closed 14 years ago
#3700 closed defect (fixed)
dijit._Template: weird error if template variable value is not defined.
Reported by: | James Burke | Owned by: | Adam Peller |
---|---|---|---|
Priority: | high | Milestone: | 0.9 |
Component: | Dijit | Version: | 0.9 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
I got a "_5 has no properties" error when using a templated widget that had a ${variable} in it that was not found via dojo.string.substitute's getObject call:
value = dojo.getObject(format,false,thisObject)(value);}
value ended up being null (or undefined, or not a string), and this bad value was passed to the "transform" function in dojo.string.substitute, which in dijit._Templated's case was this function (inside buildRendering function:
var tstr = dojo.string.substitute(cached, this, function(value){ // Safer substitution, see heading "Attribute values" in // http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2 return value.toString().replace(/"/g,"""); //TODO: support a more complete set of escapes? }, this);
Operating on the bad value inside of this function caused the problem. So maybe make this anonymous function aware of bad substitute values and/or make dojo.string.substitute return an empty string for values not found via the dojo.getObject() call?
Change History (6)
comment:1 Changed 14 years ago by
Milestone: | → 0.9 |
---|---|
Owner: | changed from bill to Adam Peller |
comment:2 Changed 14 years ago by
comment:3 Changed 14 years ago by
I tried writing that method to be very compact and just throw an exception naturally (but predictably) w/o putting in any special conditionals or error messages... The new transform step really does obfuscate things. I'll take another look at what we can do to make this more friendly.
comment:4 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 Changed 14 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
comment:6 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Another option might be to warn the user that a substitution could not be made. I overrode the dojo.string.substitute method and put in a warning to help find the original problem.