#1035 ✓resolved
François-Pierre Bouchard

Element.Layout border/margin composite getters fail for hidden elements

Reported by François-Pierre Bouchard | April 14th, 2010 @ 07:56 PM | in 1.7

Both border-box-width and border-box-height rely on element.offsetHeight & offsetWidth, which return 0 if element is invisible, thus "breaking" margin-height and border-height (and their equivalent width measurements). The padding versions work since they rely on the 'prepared' height and width calls.

I've patched it locally by naively wrapping both calls with the 'prepare' helpers.

--- a/public/javascripts/prototype.js
+++ b/public/javascripts/prototype.js
@@ -4512,11 +4512,17 @@ delete Prototype._original_property;
       },
 
       '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) {

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

The Prototype JavaScript library.

Shared Ticket Bins

Referenced by

Pages