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.

Event Timeline

Fomafix created this task.Jan 28 2019, 6:35 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 28 2019, 6:35 PM
Fomafix changed the subtype of this task from "Task" to "Bug Report".Feb 28 2019, 7:57 AM
Fomafix updated the task description. (Show Details)May 11 2019, 10:48 AM