only try to normalize the units to px on IE if it's not set on style attribute #2417

Closed
wants to merge 1 commit into
from
@@ -142,7 +142,7 @@ Element.implement({
if (color) result = result.replace(color[0], color[0].rgbToHex());
}
if (Browser.opera || Browser.ie){
- if ((/^(height|width)$/).test(property) && !(/px$/.test(result))){
+ if ((/^(height|width)$/).test(property) && !(/px$/.test(result)) && !this.style[property]){
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;
values.each(function(value){
size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();
@@ -96,6 +96,14 @@ describe('Element.Style', function(){
it('should get the width from the CSS', function(){
expect(element.getStyle('width')).toMatch(/\d+px/);
});
+
+ it('should not mangle the units from inline width in %', function(){
+ expect(new Element('div').setStyle('width', '40%').getStyle('width')).toEqual('40%');
+ });
+
+ it('should not mangle the units from inline auto width', function(){
+ expect(new Element('div').setStyle('width', 'auto').getStyle('width')).toEqual('auto');
+ });
it('should get the left margin from the CSS', function(){
// FireFox returns px (and maybe even as floats)