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

Changeset 5659

Show
Ignore:
Timestamp:
12/01/06 14:16:44 (3 years ago)
Author:
madrobby
Message:

Prototype: make Element.getStyle() work with camelCased argument, fixes #6686 [Tobie]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinoffs/prototype/CHANGELOG

    r5650 r5659  
     1* Make Element.getStyle() work with camelCased argument, fixes #6686 [Tobie] 
     2 
    13* Fix a redundant check in Array.prototype.compact, fixes #4739 [wlodarcz, mislav] 
    24 
  • spinoffs/prototype/src/dom.js

    r5649 r5659  
    283283  getStyle: function(element, style) { 
    284284    element = $(element); 
    285     var inline = (style == 'float' ?  
     285    var camelizedStyle = (style == 'float' ?  
    286286      (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat') : style).camelize(); 
    287     var value = element.style[inline]; 
     287    var value = element.style[camelizedStyle]; 
    288288    if (!value) { 
    289289      if (document.defaultView && document.defaultView.getComputedStyle) { 
    290290        var css = document.defaultView.getComputedStyle(element, null); 
    291         value = css ? css.getPropertyValue(style) : null; 
     291        value = css ? css[camelizedStyle] : null; 
    292292      } else if (element.currentStyle) { 
    293         value = element.currentStyle[inline]; 
     293        value = element.currentStyle[camelizedStyle]; 
    294294      } 
    295295    } 
  • spinoffs/prototype/test/unit/dom.html

    r5649 r5659  
    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     
     
    456456        assertEqual(0.3, $('op4-ie').getStyle('opacity')); 
    457457      } 
    458  
     458      // verify that value is stil found when using camelized 
     459      // strings (function previously used getPropertyValue() 
     460      // which expected non-camelized strings) 
     461      assertEqual("12px", $('style_test_1').getStyle('fontSize')); 
    459462    }}, 
    460463