Skip to content

Commit

Permalink
don't loop over characters in css() string property
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Mar 2, 2013
1 parent ddd3f41 commit fadcb09
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/zepto.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,17 +605,18 @@ var Zepto = (function() {
return this[0] && (this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property))

var css = ''
for (key in property)
if (!property[key] && property[key] !== 0)
this.each(function(){ this.style.removeProperty(dasherize(key)) })
else
css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'

if (typeof property == 'string')
if (type(property) == 'string') {
if (!value && value !== 0)
this.each(function(){ this.style.removeProperty(dasherize(property)) })
else
css = dasherize(property) + ":" + maybeAddPx(property, value)
} else {
for (key in property)
if (!property[key] && property[key] !== 0)
this.each(function(){ this.style.removeProperty(dasherize(key)) })
else
css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';'
}

return this.each(function(){ this.style.cssText += ';' + css })
},
Expand Down

0 comments on commit fadcb09

Please sign in to comment.