Browse files

Fix failing layout test case in Opera.

  • Loading branch information...
1 parent 87b2fda commit 23a144404b189e4072d34fb40f0dcd8eeb4ec2bf @savetheclocktower savetheclocktower committed Nov 15, 2010
Showing with 10 additions and 2 deletions.
  1. +8 −0 src/dom/layout.js
  2. +2 −2 test/unit/layout_test.js
View
8 src/dom/layout.js
@@ -307,6 +307,14 @@
var position = element.getStyle('position'),
width = element.getStyle('width');
+ if (width === "0px" || width === null) {
+ // Opera won't report the true width of the element through
+ // `getComputedStyle` if it's hidden. If we got a nonsensical value,
+ // we need to show the element and try again.
+ element.style.display = 'block';
+ width = element.getStyle('width');
+ }
+
// Preserve the context in case we get a percentage value.
var context = (position === 'fixed') ? document.viewport :
element.parentNode;
View
4 test/unit/layout_test.js
@@ -39,14 +39,14 @@ new Test.Unit.Runner({
'test layout on elements with display: none and exact width': function() {
var layout = $('box2').getLayout();
- this.assert(!isDisplayed($('box3')), 'box should be hidden');
+ this.assert(!isDisplayed($('box2')), 'box should be hidden');
this.assertEqual(500, layout.get('width'), 'width');
this.assertEqual( 3, layout.get('border-right'), 'border-right');
this.assertEqual( 10, layout.get('padding-bottom'), 'padding-bottom');
this.assertEqual(526, layout.get('border-box-width'), 'border-box-width');
- this.assert(!isDisplayed($('box3')), 'box should still be hidden');
+ this.assert(!isDisplayed($('box2')), 'box should still be hidden');
},
'test layout on elements with negative margins': function() {

0 comments on commit 23a1444

Please sign in to comment.