Prototype: some more Element.setStyle optimizations

This commit is contained in:
Thomas Fuchs 2007-03-02 12:16:42 +00:00
parent 94d8333448
commit 91dd60c5a2
1 changed files with 7 additions and 10 deletions

View File

@ -318,16 +318,13 @@ Element.Methods = {
setStyle: function(element, styles) {
element = $(element);
var elementStyle = element.style;
for (var property in styles) {
var value = styles[property];
if (property == 'opacity') {
element.setOpacity(value)
} else {
property = (property == 'float' || property == 'cssFloat') ?
((elementStyle.styleFloat === undefined) ? 'cssFloat' : 'styleFloat') : property.camelize();
elementStyle[property] = value;
}
}
for (var property in styles)
if (property == 'opacity') element.setOpacity(styles[property])
else
elementStyle[(property == 'float' || property == 'cssFloat') ?
(elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : property.camelize()] = styles[property];
return element;
},