Skip to content
Permalink
Browse files

Fix: Compatibility with jQuery 1.x. Misalignment of the fill icon due…

… to a difference in behaviour of `$().position()` for tables

- DD-8
  • Loading branch information...
Allan Jardine
Allan Jardine committed Mar 8, 2019
1 parent e6bb09e commit 2c949946b5c0729364969a0344b55be325c12eb5
Showing with 10 additions and 8 deletions.
  1. +10 −8 js/dataTables.autoFill.js
@@ -585,9 +585,8 @@ $.extend( AutoFill.prototype, {
_getPosition: function ( node, targetParent )
{
var
currNode = $(node),
currNode = node,
currOffsetParent,
position,
top = 0,
left = 0;

@@ -596,23 +595,26 @@ $.extend( AutoFill.prototype, {
}

do {
position = currNode.position();
// Don't use jQuery().position() the behaviour changes between 1.x and 3.x for
// tables
var positionTop = currNode.offsetTop;
var positionLeft = currNode.offsetLeft;

// jQuery doesn't give a `table` as the offset parent oddly, so use DOM directly
currOffsetParent = $( currNode[0].offsetParent );
currOffsetParent = $( currNode.offsetParent );

top += position.top + currOffsetParent.scrollTop();
left += position.left + currOffsetParent.scrollLeft();
top += positionTop + currOffsetParent.scrollTop();
left += positionLeft + currOffsetParent.scrollLeft();

top += parseInt( currOffsetParent.css('margin-top') ) * 1;
top += parseInt( currOffsetParent.css('border-top-width') ) * 1;

// Emergency fall back. Shouldn't happen, but just in case!
if ( currNode.get(0).nodeName.toLowerCase() === 'body' ) {
if ( currNode.nodeName.toLowerCase() === 'body' ) {
break;
}

currNode = currOffsetParent; // for next loop
currNode = currOffsetParent.get(0); // for next loop
}
while ( currOffsetParent.get(0) !== targetParent.get(0) )

0 comments on commit 2c94994

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