From 91dd60c5a267ab96bf9c0f23a540e0d6c495ef6e Mon Sep 17 00:00:00 2001 From: Thomas Fuchs Date: Fri, 2 Mar 2007 12:16:42 +0000 Subject: [PATCH] Prototype: some more Element.setStyle optimizations --- src/dom.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/dom.js b/src/dom.js index 6168877..b4eaa02 100644 --- a/src/dom.js +++ b/src/dom.js @@ -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; },