Hi,

While using MochiKit.DOM's showElement function, I have come across some
wierd behaviour that I believe is worthy of a fix. showElement always
sets the display of the element to show to 'block', regardless of the
element's type (it's a partial application of this.setDisplayForElement
to 'block').

This doesn't work properly for tables, who should have their display set
to 'table'. If set to block their width won't be set to 100% in firefox
if a CSS rule says it should be.

There are other elements that should have their display set to other
values, as listed here: http://www.w3schools.com/css/pr_class_display.asp

For now, Martyn Smith prepared a patch that provides a basic
implementation that handles the 'table' case. However, rather than
completing it, we were wondering if the patch looks like the right way
to go about fixing this issue.

If so, we may be able to prepare a more complete patch for setting the
display for other elements too.

For now, the patch is here:

Index: Style.js
===================================================================
--- Style.js    (revision 1250)
+++ Style.js    (working copy)
@@ -424,13 +424,26 @@

     __new__: function () {
         var m = MochiKit.Base;
+        var d = MochiKit.DOM;

         this.elementPosition = this.getElementPosition;
         this.elementDimensions = this.getElementDimensions;

         this.hideElement = m.partial(this.setDisplayForElement, 'none');
-        this.showElement = m.partial(this.setDisplayForElement, 'block');
+        var self = this;
+        this.showElement = function(elem) {
+            elem = d.getElement(elem);

+            switch(elem.nodeName) {
+                case 'TABLE':
+                    self.setDisplayForElement('table', elem);
+                    break;
+                default:
+                    self.setDisplayForElement('block', elem);
+                    break;
+            }
+        }
+
         this.EXPORT_TAGS = {
             ':common': this.EXPORT,
             ':all': m.concat(this.EXPORT, this.EXPORT_OK)

Nigel McNie

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to