Skip to content

Commit

Permalink
Merge pull request #2405 from gonchuki/fix_2391
Browse files Browse the repository at this point in the history
add feature detect and fix for oldIE to normalize order of border style
  • Loading branch information
arian committed Aug 16, 2012
2 parents d31018a + 18e20b0 commit 85017cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Source/Element/Element.Style.js
Expand Up @@ -24,6 +24,11 @@ var el = document.createElement('div');
el.style.color = 'red';
el.style.color = null;
var doesNotRemoveStyles = el.style.color == 'red';

// check for oldIE, which returns border* shorthand styles in the wrong order (color-width-style instead of width-style-color)
var border = '1px solid #123abc';
el.style.border = border;
var returnsBordersInWrongOrder = el.style.border != border;
el = null;
//</ltIE9>

Expand Down Expand Up @@ -131,6 +136,11 @@ Element.implement({
if ((/^border(.+)Width|margin|padding/).test(property) && isNaN(parseFloat(result))){
return '0px';
}
//<ltIE9>
if (returnsBordersInWrongOrder && /^border(Top|Right|Bottom|Left)?$/.test(property) && /^#/.test(result)){
return result.replace(/^(.+)\s(.+)\s(.+)$/, '$2 $3 $1');
}
//</ltIE9>
}
return result;
},
Expand Down
9 changes: 9 additions & 0 deletions Specs/1.4client/Element/Element.Style.js
Expand Up @@ -158,5 +158,14 @@ describe('Element.Style', function(){
});

});

describe('getStyle border after setStyle', function(){

it('should have same order when getting a previously set border', function(){
var border = '2px solid #123abc';
expect(new Element('div').setStyle('border', border).getStyle('border')).toEqual(border);
});

});

});

0 comments on commit 85017cf

Please sign in to comment.