prototype: Fix template evaluation with empty replacements. Closes #9692.
This commit is contained in:
parent
8327ffd8ae
commit
b83ae95d90
|
@ -1,9 +1,13 @@
|
|||
*1.6.0_rc1* (October 16, 2007)
|
||||
*SVN*
|
||||
|
||||
* Fix template evaluation with empty replacements. Closes #9692. [Ryan McGeary]
|
||||
|
||||
* Hash#toTemplateReplacements is an alias for Hash#toObject so you can once again pass hashes to Template#evaluate and String#interpolate. [sam]
|
||||
|
||||
* Fix Event#is(Left|Middle|Right)Click in IE. Closes #7520 (again). [Mislav Marohnić]
|
||||
|
||||
*1.6.0_rc1* (October 16, 2007)
|
||||
|
||||
* Ensure Event.* generic methods work in IE, even when the event is not extended. [Viktor Kojouharov, Andrew Dupont]
|
||||
|
||||
* Don't translate "keypress" events into "keydown" events. [sam]
|
||||
|
|
|
@ -246,7 +246,7 @@ var Template = Class.create({
|
|||
|
||||
var ctx = object, expr = match[3];
|
||||
var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr);
|
||||
if (match == null) return '';
|
||||
if (match == null) return before;
|
||||
|
||||
while (match != null) {
|
||||
var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
|
||||
|
|
|
@ -305,6 +305,15 @@
|
|||
template.evaluate({}));
|
||||
}},
|
||||
|
||||
testTemplateEvaluationWithEmptyReplacement: function() {with(this) {
|
||||
var template = new Template('##{}');
|
||||
assertEqual('#', template.evaluate({}));
|
||||
assertEqual('#', template.evaluate({foo: 'bar'}));
|
||||
|
||||
template = new Template('#{}');
|
||||
assertEqual('', template.evaluate({}));
|
||||
}},
|
||||
|
||||
testTemplateEvaluationWithFalses: function() {with(this) {
|
||||
var source = '<tr><td>#{zero}</td><td>#{false_}</td><td>#{undef}</td><td>#{null_}</td><td>#{empty}</td></tr>';
|
||||
var falses = {zero:0, false_:false, undef:undefined, null_:null, empty:""};
|
||||
|
|
Loading…
Reference in New Issue