reverted change in 1.5: the param object passed might not be a javascript object, but a wrapped map, therefor can't use clone(). instead call Object.prototype.reduce to convert the object into a js object.

This commit is contained in:
grob 2007-02-22 18:08:41 +00:00
parent afec346b39
commit 0c3af1fc19

View file

@ -10,8 +10,8 @@
* *
* $RCSfile: Html.js,v $ * $RCSfile: Html.js,v $
* $Author: robert $ * $Author: robert $
* $Revision: 1.4 $ * $Revision: 1.5 $
* $Date: 2007/01/30 14:49:57 $ * $Date: 2007/02/22 14:48:34 $
*/ */
@ -233,7 +233,7 @@ helma.Html.prototype.hidden = function(param) {
res.write("[Html.hidden: insufficient arguments]"); res.write("[Html.hidden: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
attr.type = "hidden"; attr.type = "hidden";
attr.value = (attr.value != null) ? encodeForm(attr.value) : ""; attr.value = (attr.value != null) ? encodeForm(attr.value) : "";
this.tag("input", attr); this.tag("input", attr);
@ -262,7 +262,7 @@ helma.Html.prototype.input = function(param) {
res.write("[Html.input: insufficient arguments]"); res.write("[Html.input: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
attr.type = "text"; attr.type = "text";
if (!attr.size) if (!attr.size)
attr.size = 20; attr.size = 20;
@ -293,7 +293,7 @@ helma.Html.prototype.textArea = function(param) {
res.write("[Html.textArea: insufficient arguments]"); res.write("[Html.textArea: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
var value = (attr.value != null) ? encodeForm(attr.value) : ""; var value = (attr.value != null) ? encodeForm(attr.value) : "";
delete attr.value; delete attr.value;
this.openTag("textarea", attr); this.openTag("textarea", attr);
@ -324,7 +324,7 @@ helma.Html.prototype.checkBox = function(param) {
res.write("[Html.checkBox: insufficient arguments]"); res.write("[Html.checkBox: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
attr.type = "checkbox"; attr.type = "checkbox";
if (attr.selectedValue != null) { if (attr.selectedValue != null) {
if (helma.Html.isSelected(param.value, param.selectedValue)) if (helma.Html.isSelected(param.value, param.selectedValue))
@ -359,7 +359,7 @@ helma.Html.prototype.radioButton = function(param) {
res.write("[Html.radioButton: insufficient arguments]"); res.write("[Html.radioButton: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
attr.type = "radio"; attr.type = "radio";
if (attr.selectedValue != null) { if (attr.selectedValue != null) {
if (attr.value == attr.selectedValue) if (attr.value == attr.selectedValue)
@ -394,7 +394,7 @@ helma.Html.prototype.submit = function(param) {
res.write("[Html.submit: insufficient arguments]"); res.write("[Html.submit: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
attr.type = "submit"; attr.type = "submit";
if (!attr.name) if (!attr.name)
attr.name = attr.type; attr.name = attr.type;
@ -425,7 +425,7 @@ helma.Html.prototype.button = function(param) {
res.write("[Html.button: insufficient arguments]"); res.write("[Html.button: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
attr.type = "button"; attr.type = "button";
if (!attr.name) if (!attr.name)
attr.name = attr.type; attr.name = attr.type;
@ -462,7 +462,7 @@ helma.Html.prototype.dropDown = function(param, options, selectedValue, firstOpt
res.write("[Html.dropDown: insufficient arguments]"); res.write("[Html.dropDown: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
if (!attr.size) if (!attr.size)
attr.size = 1; attr.size = 1;
this.openTag("select", attr); this.openTag("select", attr);
@ -535,7 +535,7 @@ helma.Html.prototype.map = function(name, param) {
return; return;
} }
this.openTag("map", {name: name}); this.openTag("map", {name: name});
var areas = param.clone(); var attr = Object.prototype.reduce.call(param);
for (var i in areas) { for (var i in areas) {
if (!areas[i].alt) if (!areas[i].alt)
areas[i].alt = ""; areas[i].alt = "";
@ -587,7 +587,7 @@ helma.Html.prototype.table = function(headers, data, param) {
res.write("[Html.table: insufficient arguments]"); res.write("[Html.table: insufficient arguments]");
return; return;
} }
var attr = param.clone(); var attr = Object.prototype.reduce.call(param);
if (!attr.trHead) attr.trHead = attr.tr; if (!attr.trHead) attr.trHead = attr.tr;
if (!attr.trEven) attr.trEven = attr.tr; if (!attr.trEven) attr.trEven = attr.tr;
if (!attr.trOdd) attr.trOdd = attr.tr; if (!attr.trOdd) attr.trOdd = attr.tr;