Skip to content

Update required for jQuery 3.x - jQuery.fn.offset() requires an element connected to a document #278

@JamoCA

Description

@JamoCA

I was encountering the following warning while using jquery-sortable 0.9.13 (from 2015) with jQuery 3.2.1 and the unminified version of jQuery Migrate 3.1.0.

jQuery.fn.offset() requires an element connected to a document

I reviewed the sortable plugin, determined what jQuery Migrate was doing to provide fallback support and made the following edit to function getRelativePosition() on line 190.

function getRelativePosition(pointer, element) {
    var docElem = ( element.ownerDocument || window.document ).documentElement;
    var offset = { top: 0, left: 0 };
    if ( $.contains(docElem, element) ) {
        offset = element.offset();
    }
...

This appears to works correctly now with jQuery 3.x. Please review and determine if there are any problems with this approach. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions