https://bugzilla.wikimedia.org/show_bug.cgi?id=41688
Web browser: ---
Bug #: 41688
Summary: Buggy $.unique function fails for empty arrays,
breaking other scripts
Product: MediaWiki extensions
Version: master
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: Unprioritized
Component: TimedMediaHandler
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
Classification: Unclassified
Mobile Platform: ---
In the MwEmbedSupport extension,
MwEmbedModules/MwEmbedSupport/jquery/jquery.mwEmbedUtil.js contains the
following buggy code:
/**
* Extend Unique to work with strings and number values
* http://paulirish.com/2010/duck-punching-with-jquery/
*/
var _oldUnique = $.unique;
$.unique = function(arr){
// Do the default behavior only if we got an array of elements
if (!!arr[0].nodeType){
return _oldUnique.apply(this,arguments);
} else {
// reduce the array to contain no dupes via grep/inArray
return $.grep(arr,function(v,k){
return $.inArray(v,arr) === k;
});
}
};
!!arr[0].nodeType causes an exception for empty arrays. This broke one of the
Wikipedia user scripts I developed, which uses jquery.ui.tabs.
The proper fix is to put the array-specific code in a separate function rather
than trying to monkey patch a function "chiefly used internally by jQuery".
I'm just hesitant to do that myself because of how the TimedMediaHandler code
is spread across two Git repositories.
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l