Permalink
Browse files

clean up and optimizations based on suggestions by @ibolmo and @arian

  • Loading branch information...
1 parent 1e400ff commit 3fa2f76f8b29bed9360aed9f4a0136ee8cc77e3b @gonchuki gonchuki committed Aug 17, 2012
Showing with 8 additions and 9 deletions.
  1. +6 −8 Source/Element/Element.Style.js
  2. +2 −1 Specs/1.4client/Element/Element.Style.js
@@ -122,12 +122,12 @@ Element.implement({
}
result = this.getComputedStyle(property);
}
- if (hasBackgroundPositionXY && /^backgroundPosition[XY]$/.test(property) || property == 'backgroundPosition' && /(top|right|bottom|left)/.test(result)){
- return result.replace(/(\w+)/g, function(value) { return value && namedPositions[value] || value || '0px'; }) || '0px';
- }
- if (!result && property == 'backgroundPosition') {
- return '0px 0px';
+ if (hasBackgroundPositionXY && /^backgroundPosition[XY]?$/.test(property)){
+ return result.replace(/(top|right|bottom|left)/g, function(position){
+ return namedPositions[position];
+ }) || '0px';
}
+ if (!result && property == 'backgroundPosition') return '0px 0px';
if (result){
result = String(result);
var color = result.match(/rgba?\([\d\s,]+\)/);
@@ -232,7 +232,5 @@ Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, bor
Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';
});
-if (hasBackgroundPositionXY) {
- Object.merge(Element.ShortStyles, {backgroundPosition: {backgroundPositionX: '@', backgroundPositionY: '@'}});
-}
+if (hasBackgroundPositionXY) Element.ShortStyles.backgroundPosition = {backgroundPositionX: '@', backgroundPositionY: '@'};
})();
@@ -178,7 +178,7 @@ describe('Element.Style', function(){
describe('getStyle background-position', function(){
beforeEach(function(){
- var className = String.uniqueID();
+ var className = 'getStyleBackgroundPosition';
var style = this.style = $(document.createElement('style'));
style.type = 'text/css';
var definition = [
@@ -202,6 +202,7 @@ describe('Element.Style', function(){
afterEach(function(){
this.style.destroy();
this.element.destroy();
+ this.element = null;
});
it('should have non-empty background-position shorthand', function(){

0 comments on commit 3fa2f76

Please sign in to comment.