Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #6686: getStyle.diff

File getStyle.diff, 1.9 kB (added by Tobie, 2 years ago)

js + tests

  • test/unit/dom.html

    old new  
    1111  /* <![CDATA[ */ 
    1212    #testcss1 { font-size:11px; color: #f00; } 
    1313    #testcss2 { font-size:12px; color: #0f0; display: none; } 
    14     #style_test_1 { cursor: pointer 
     14    #style_test_1 { cursor: pointer; font-size:12px;
    1515    div.style-test { margin-left: 1px } 
    1616     
    1717    #not_floating_style { float: none } 
     
    452452        assertEqual('alpha(opacity=30)', $('op3').getStyle('filter')); 
    453453        assertEqual(0.3, $('op4-ie').getStyle('opacity')); 
    454454      } 
    455  
     455      // verify that value is stil found when using camelized 
     456      // strings (function previously used getPropertyValue() 
     457      // which expected non-camelized strings) 
     458      assertEqual("12px", $('style_test_1').getStyle('fontSize')); 
    456459    }}, 
    457460     
    458461    testElementReadAttribute: function() {with(this) { 
  • src/dom.js

    old new  
    283283   
    284284  getStyle: function(element, style) { 
    285285    element = $(element); 
    286     var inline = (style == 'float' ?  
     286    var camelizedStyle = (style == 'float' ?  
    287287      (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat') : style).camelize(); 
    288     var value = element.style[inline]; 
     288    var value = element.style[camelizedStyle]; 
    289289    if (!value) { 
    290290      if (document.defaultView && document.defaultView.getComputedStyle) { 
    291291        var css = document.defaultView.getComputedStyle(element, null); 
    292         value = css ? css.getPropertyValue(style) : null; 
     292        value = css ? css[camelizedStyle] : null; 
    293293      } else if (element.currentStyle) { 
    294         value = element.currentStyle[inline]; 
     294        value = element.currentStyle[camelizedStyle]; 
    295295      } 
    296296    } 
    297297