Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

do not allow getComputedStyle to return null, default value for an ex…

…isting and unset style is the empty string
  • Loading branch information...
commit 511da30954854021d102607af4857dd798b71621 1 parent 85017cf
@gonchuki gonchuki authored arian committed
View
2  Source/Element/Element.Style.js
@@ -79,7 +79,7 @@ Element.implement({
if (this.currentStyle) return this.currentStyle[property.camelCase()];
var defaultView = Element.getDocument(this).defaultView,
computed = defaultView ? defaultView.getComputedStyle(this, null) : null;
- return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : null;
+ return (computed) ? computed.getPropertyValue((property == floatName) ? 'float' : property.hyphenate()) : '';
},
setStyle: function(property, value){
View
15 Specs/1.4client/Element/Element.Style.js
@@ -117,7 +117,7 @@ describe('Element.Style', function(){
});
});
-
+
describe('getStyle height / width / borders from auto values', function(){
var element;
@@ -130,14 +130,14 @@ describe('Element.Style', function(){
display: 'block'
}
});
-
+
var child = new Element('div', {
styles: {
width: '200px',
height: '100px'
}
});
-
+
element.adopt(child).inject(document.body);
});
@@ -148,7 +148,7 @@ describe('Element.Style', function(){
it('should get a pixel based width', function(){
expect(element.getStyle('width')).toMatch(/\d+px/);
});
-
+
it('should have a 0px border left', function(){
expect(element.getStyle('borderLeftWidth')).toEqual('0px');
});
@@ -168,4 +168,11 @@ describe('Element.Style', function(){
});
+ describe('getComputedStyle margin-left on detached element', function(){
+
+ it('should have a non-null margin-left', function(){
+ expect(new Element('div').getComputedStyle('margin-left')).not.toEqual(null);
+ });
+
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.