Skip to content
Permalink
Browse files

Fix issue with retrieving border-box-(height|width) of hidden element…

…s. [#1035 state:resolved] (Francois-Pierre Bouchard, Andrew Dupont)
  • Loading branch information...
savetheclocktower committed May 18, 2010
1 parent ff6cc3e commit 7a4a5c706a819037b40b72b67d6a691cac20d34a
Showing with 18 additions and 8 deletions.
  1. +2 −0 CHANGELOG
  2. +8 −2 src/dom/layout.js
  3. +8 −6 test/unit/layout_test.js
@@ -1,3 +1,5 @@
* Fix issue with retrieving border-box-(height|width) of hidden elements. [#1035 state:resolved] (Francois-Pierre Bouchard, Andrew Dupont)

* Ensure we clean up after ourselves for all `width` and `height` computations in `Element.Layout`. (Sam Stephenson, Andrew Dupont)

*1.7_rc2* (May 12, 2010)
@@ -493,11 +493,17 @@
},

'border-box-height': function(element) {
return element.offsetHeight;
if (!this._preComputing) this._begin();
var height = element.offsetHeight;
if (!this._preComputing) this._end();
return height;
},

'border-box-width': function(element) {
return element.offsetWidth;
if (!this._preComputing) this._begin();
var width = element.offsetWidth;
if (!this._preComputing) this._end();
return width;
},

'margin-box-height': function(element) {
@@ -41,9 +41,10 @@ new Test.Unit.Runner({

this.assert(!isDisplayed($('box3')), '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(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');
},
@@ -61,10 +62,11 @@ new Test.Unit.Runner({

this.assert(!isDisplayed($('box3')), 'box should be hidden');

this.assertEqual(364, layout.get('width'), 'width');
this.assertEqual(364, layout.get('width'), 'width');
this.assertEqual(400, layout.get('margin-box-width'), 'margin-box-width');
this.assertEqual(3, layout.get('border-right'), 'border-top');
this.assertEqual(10, layout.get('padding-bottom'), 'padding-right');
this.assertEqual(390, layout.get('border-box-width'), 'border-box-width');
this.assertEqual(3, layout.get('border-right'), 'border-top');
this.assertEqual(10, layout.get('padding-bottom'), 'padding-right');

// Ensure that we cleaned up after ourselves.
this.assert(!isDisplayed($('box3')), 'box should still be hidden');

0 comments on commit 7a4a5c7

Please sign in to comment.
You can’t perform that action at this time.