https://bugzilla.wikimedia.org/show_bug.cgi?id=42926

       Web browser: ---
            Bug ID: 42926
           Summary: mwEmbed overwrites jquery.ui.autocomplete (JavaScript)
           Product: MediaWiki extensions
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: TimedMediaHandler
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified
   Mobile Platform: ---

Activation of mwEmbed at Wikimedia Commons leads to some bugs. Therefore, I
call it a regression. Writing this bug report presumably took me more time than
fixing the bug but if I don't get dev-access, it's not my problem.

Browsers: all.
OS: all.

Error symptoms:
jquery.ui.autocomplete ([f1]
https://bits.wikimedia.org/static-1.21wmf5/resources/jquery.ui/jquery.ui.autocomplete.js
) does not work when used on a page with video

Exact error message:
"this.menu is undefined"

But this is only the symptom. The error happens before: While creating the
autocomplete, the wrong "menu" is created. The mw-embed menu (see below) does
not assign a "data" attribute. So calling .data( "menu" ) [cf. l. 208, f1] will
return undefined to this.menu [cf. l. 131, f1] in the _create method of
jquery.ui.autocomplate. It won't immediately throw an error. But when the
jQuery autocomplete is used the first time...

Reason:
On pages with embedded videos, mw-embed is loaded. mw-embed contains a module
"jquery.menu"
Confer to:
[f2]
https://bits.wikimedia.org/static-1.21wmf5/extensions/MwEmbedSupport/MwEmbedModules/MwEmbedSupport/jquery.menu/jquery.menu.js
Evidence: (l.61) "$.fn.menu = function( options ) {"

This overwrites the native jQuery "menu" implementation in jQuery autocomplete:
[f1]
https://bits.wikimedia.org/static-1.21wmf5/resources/jquery.ui/jquery.ui.autocomplete.js
Evidence: (l.468) "$.widget("ui.menu", {"

$.fn.menu now points to the mw-embed menu. 
After mw-embed is loaded, all autocomplete-enhanced inputs will throw errors.
No autocomplete will be shown.
NOTE THAT THE ORDER IN WHICH THE MODULES WERE LOADED, IS ESSETIALLY IMPORTANT
WHEN TRYING TO REPRODUCE THIS BEHAVIOUR. I recommend activating a gadget, which
has a dependency to jquery.ui.autocomplate (like cat-a-lot) when you try to
reproduce it. This will likely load jquery.ui.autocomplate before mw-embed. YOU
MUST TEST IT ON A PAGE WITH EMBEDDED VIDEO. Then simply create an autocomplete
according to http://jqueryui.com

I tested it with Cat-A-Lot enabled in my prefs at 
https://commons.wikimedia.org/wiki/Commons:Forum?useskin=vector&debug=true&withJS=MediaWiki:VisualFileChange.js

Expected behaviour:
mw-embed does not interfere with jQuery's native stuff.

FixIt:
Please rename "$.fn.menu = function( options ) {" in mw-embed to something
different e.g. "$.fn.embedMenu"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are watching all bug changes.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to