"jQuery.fn.offset() requires an element connected to a document" when using jquery-migrate to migrate to jQuery 3.x


#1

Working on DNN Platform v9.3.1 which uses jQuery v3.2.1. Through browser inspection I get a jquery-migrate warning of ‘jQuery.fn.offset() requires an element connected to a document’. Would like to know if this will be corrected in the near future?


#2

This seems to be a jQuery question, not a Select2 question. I don’t know what “DNN Platform” is, but perhaps there is a support forum for that product that would be a better place to pose your question.

(If you believe this truly is a Select2 issue, can you explain why you believe that? In other words, what information in the warning leads you to believe the issue is in the Select2 code?)


#3

Hi, thank you for your reply.

The ‘jquery-migrate’ warning message may bring context regarding that jQuery.fn.offset() requires an element connected to a document.
https://github.com/jquery/jquery-migrate/blob/master/warnings.md#jqmigrate-jqueryfnoffset-requires-an-element-connected-to-a-document

As of jQuery 3.0+, .offset() only works for elements that are currently in the document. In earlier versions, this would return the value but in jQuery 3.0 this throws an error.
My questions:

  • What version of jQuery is recommended for select2 v4+?
  • Would like to know if select2 would be updated in the future to fully work with jQuery3+ without throwing JQMigrate warnings?

s2_2019-11-14_10-12-44