Page MenuHomePhabricator

ULS causes JQMIGRATE: jQuery.fn.offset() requires a valid DOM element
Closed, DuplicatePublicBUG REPORT

Description

Steps to reproduce:

  • Load https://www.mediawiki.org/wiki/MediaWiki
  • Click into Search MediaWiki input field. --> A keyboard symbol with a triangle is visible.
  • Click on the symbol. --> A dialog comes.
  • Click on the gear wheel symbol. --> A further dialog comes.

In the JavaScript console occurs the following warning message:

JQMIGRATE: jQuery.fn.offset() requires a valid DOM element

The reason for this warning is the code: https://phabricator.wikimedia.org/diffusion/EULS/browse/master/resources/js/ext.uls.inputsettings.js$354-358

if ( $( '.uls-settings-trigger' ).offset().left > $( window ).width() / 2 ) {
	uls.$menu.removeClass( 'selector-left' ).addClass( 'selector-right' );
} else {
	uls.$menu.removeClass( 'selector-right' ).addClass( 'selector-left' );
}

The code exist since rEULS86c636fd0acb.

The class uls-settings-trigger does not exist in this situation:

$( '.uls-settings-trigger' ).length
// 0

jQuery migrate triggers the warning when .offset() is called on an empty list of jQuery elements.