Page MenuHomePhabricator

Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" from maybeShowMetaDialog
Open, LowPublic1 Estimated Story Points

Description

When using VisualEditor, frequently seeing this:

JQMIGRATE: jQuery.fn.offset() requires an element connected to a document
OO.ui.PopupWidget.computePosition
OO.ui.mixin.FloatableElement.position

Not sure, but probably from this line:
https://github.com/wikimedia/oojs-ui/blob/bd15ed511c345db718dfdc6567224a6053e0fd36/src/widgets/PopupWidget.js#L502

Documentation

Release notes:
https://jquery.com/upgrade-guide/3.0/#breaking-change-invalid-input-to-the-offset-method

Migration legend:
https://github.com/jquery/jquery-migrate/blob/e967c3b98b/warnings.md#jqmigrate-jqueryfnoffset-requires-an-element-connected-to-a-document

Event Timeline

Where do you see this? It sounds like a bug in the calling code, not in OOjs UI. You're not supposed to try to display popups that are not connected to the document.

It happens unconditionally on any load of VE for me, on Beta cluster. Here's the rest of the stack trace:

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

OO.ui.PopupWidget.computePosition
OO.ui.mixin.FloatableElement.position
OO.ui.mixin.FloatableElement.togglePositioning
OO.ui.PopupWidget.toggle
(jQuery.Promise#always)
ve.init.mw.DesktopArticleTarget.maybeShowMetaDialog
ve.init.mw.DesktopArticleTarget.surfaceReady
(setTimeout [async])
ve.init.mw.Target.setupSurface
ve.init.mw.Target.documentReady
ve..init.mw.ArticleTarget.documentReady
ve.init.mw.ArticleTarget.loadSuccess
ve.init.mw.DesktopArticleTarget.loadSuccess
(jQuery.Promise#done)
ve.init.mw.ArticleTarget.load
ve.init.mw.DesktopArticleTarget.activate
	// Show "switched" popup
	popup = new mw.libs.ve.SwitchPopupWidget( 'visual' );
	target.actionsToolbar.tools.editModeSource.toolGroup.$element.append( popup.$element );
	popup.toggle( true );

@matmarex This suggests it is attached somewhere before toggling. But perhaps the parent element is itself not yet attached here?

Krinkle renamed this task from Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" in PopupWidget to Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" in SwitchPopupWidget.Jul 3 2017, 11:38 PM

I can't reproduce. Even in case where I get the "You have switched to visual editing" popup, this warning doesn't appear.

Hm.. me neither now. I'll assume something fixed it recently.

Deskana set the point value for this task to 0.Jul 6 2017, 12:53 PM

I can't reproduce. Even in case where I get the "You have switched to visual editing" popup, this warning doesn't appear.

I can reproduce it again.

  1. On https://en.wikipedia.beta.wmflabs.org/, localStorage.clear(); sessionStorage.clear();, Log out
  2. Log in, and press Sandbox (red link for me) – https://en.wikipedia.beta.wmflabs.org/w/index.php?title=User:Krinkle/sandbox&action=edit

Screen Shot 2017-07-11 at 18.28.47.png (1×2 px, 519 KB)

Same stack trace.

Krinkle renamed this task from Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" in SwitchPopupWidget to Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" from maybeShowMetaDialog.Jul 12 2017, 2:23 AM
Deskana moved this task from To Triage to TR1: Releases on the VisualEditor board.
Deskana changed the point value for this task from 0 to 1.Oct 27 2017, 3:08 PM