diff options
| author | Igor Minar | 2011-09-27 16:56:54 +0200 | 
|---|---|---|
| committer | Igor Minar | 2011-09-28 23:57:00 +0200 | 
| commit | ca1e45beafd060b698933886f6425faf365bd31d (patch) | |
| tree | b0a64d34b885be9bb234053a9cd1d0eeb2b1f3c3 /src/jqLite.js | |
| parent | 084b83ffa909a2221008acd64fe59b326d30bc87 (diff) | |
| download | angular.js-ca1e45beafd060b698933886f6425faf365bd31d.tar.bz2 | |
fix(jqLite): css should convert dash-separated properties to camelCase
this fix is needed for Firefox or other browsers that strictly follow
dom/css spec which states that element.style should make properties
available in camelCased form.
Closes #569
Diffstat (limited to 'src/jqLite.js')
| -rw-r--r-- | src/jqLite.js | 21 | 
1 files changed, 19 insertions, 2 deletions
| diff --git a/src/jqLite.js b/src/jqLite.js index d7faa1e8..9ff90d7c 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -88,6 +88,16 @@ function getStyle(element) {    return current;  } + +/** + * Converts dash-separated names to camelCase. Useful for dealing with css properties. + */ +function camelCase(name) { +  return name.replace(/\-(\w)/g, function(all, letter, offset){ +    return (offset == 0 && letter == 'w') ? 'w' : letter.toUpperCase(); +  }); +} +  /////////////////////////////////////////////  function jqLiteWrap(element) {    if (isString(element) && element.charAt(0) != '<') { @@ -247,12 +257,14 @@ forEach({    hasClass: JQLiteHasClass,    css: function(element, name, value) { +    name = camelCase(name); +      if (isDefined(value)) {        element.style[name] = value;      } else {        var val; -      if (msie <=8) { +      if (msie <= 8) {          // this is some IE specific weirdness that jQuery 1.6.4 does not sure why          val = element.currentStyle && element.currentStyle[name];          if (val === '') val = 'auto'; @@ -260,7 +272,12 @@ forEach({        val = val || element.style[name]; -      return  (val === '') ? undefined : val; +      if (msie <= 8) { +        // jquery weirdness :-/ +        val = (val === '') ? undefined : val; +      } + +      return  val;      }    }, | 
