prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.54k stars 640 forks source link

Element.makePositioned for TD tagname #166

Closed jwestbrook closed 9 years ago

jwestbrook commented 10 years ago

previous lighthouse ticket #1161 by BPere


I created a table with draggable elements ( div ) in droppable TD's. When I add the TD as a droppable, the Droppables.add function will execute the method Element.makePositioned as a fix for IE This is a correct function but it the style does not work correctly in IE when passing in TD element.

When dragging the elements into a new tablecell created after the current tablecell, everything is ok. When dragging the elements into a new tablecell created 'before' the current tablecell, the zindex is not correctly handled.

After some research I found out that the style position:'relative' causes that problem on TD elements.

Add in prototype.js line 1964

  makePositioned: function(element) {
    element = $(element);
    if (Prototype.Browser.IE && element.nodeName == 'TD') { return element; }   
    var pos = Element.getStyle(element, 'position');
    if (pos == 'static' || !pos) {
      element._madePositioned = true;
      element.style.position = 'relative';
      // Opera returns the offset relative to the positioning context, when an
      // element is position relative but top and left have not been defined
      if (Prototype.Browser.Opera) {
        element.style.top = 0;
        element.style.left = 0;
      }
    }
    return element;
  },

I didn't test this for TBODY, THEAD or TR