From cb20b5aa5a68d8f925adf7acc2c3e748d5a66ad2 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 14 May 2014 15:45:27 +0200 Subject: [PATCH] Add mw.track calls for jquery.migrate Can't use mw.log.deprecate because many of these are fired for specific behaviour within a method, not for access to the method itself. And mustn't fire the events with topic "mw.deprecate" as we can't satisfy all the requires properties of that event schema (such as having a search phrase to find offending code). These tracking hits would be for hit counts only, not for finding where it comes from (we'll still have wikiid, pagename, revision id and referral information from EventLogging though). Change-Id: I6c868f2ce831d74889ed58b6ab4a69b233b3923f --- resources/lib/jquery/jquery.migrate.js | 80 ++++++++++++++++++-------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/resources/lib/jquery/jquery.migrate.js b/resources/lib/jquery/jquery.migrate.js index 25b6c81314..5b18236659 100644 --- a/resources/lib/jquery/jquery.migrate.js +++ b/resources/lib/jquery/jquery.migrate.js @@ -2,6 +2,8 @@ * jQuery Migrate - v1.2.1 - 2013-05-08 * https://github.com/jquery/jquery-migrate * Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors; Licensed MIT + * + * Patched for MediaWiki to add mw.track calls. --Krinkle 2014-04-14 */ (function( jQuery, window, undefined ) { // See http://bugs.jquery.com/ticket/13335 @@ -32,8 +34,36 @@ jQuery.migrateReset = function() { jQuery.migrateWarnings.length = 0; }; -function migrateWarn( msg) { +function migrateWarn( msg, key ) { var console = window.console; + /* + MediaWiki patch for tracking usage. + + Custom keys: + - andSelf + - attr-pass + - attr-prop + - bind-error + - clean + - create-html + - data-events + - die + - event-ajax + - event-global + - event-hover + - event-handle + - input-type + - json-invalid + - live + - sub + - toggle-handle + + Prop keys: + - attrFn + - browser + */ + mw.track( "jquery.migrate", key || "unknown" ); + if ( !warnedAbout[ msg ] ) { warnedAbout[ msg ] = true; jQuery.migrateWarnings.push( msg ); @@ -46,7 +76,7 @@ function migrateWarn( msg) { } } -function migrateWarnProp( obj, prop, value, msg ) { +function migrateWarnProp( obj, prop, value, msg, key ) { if ( Object.defineProperty ) { // On ES5 browsers (non-oldIE), warn if the code tries to get prop; // allow property to be overwritten in case some other plugin wants it @@ -55,11 +85,11 @@ function migrateWarnProp( obj, prop, value, msg ) { configurable: true, enumerable: true, get: function() { - migrateWarn( msg ); + migrateWarn( msg, key || prop ); return value; }, set: function( newValue ) { - migrateWarn( msg ); + migrateWarn( msg, key || prop ); value = newValue; } }); @@ -102,7 +132,7 @@ jQuery.attr = function( elem, name, value, pass ) { // Since pass is used internally, we only warn for new jQuery // versions where there isn't a pass arg in the formal params if ( oldAttr.length < 4 ) { - migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); + migrateWarn("jQuery.fn.attr( props, pass ) is deprecated", "attr-pass" ); } if ( elem && !rnoAttrNodeType.test( nType ) && (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { @@ -113,7 +143,7 @@ jQuery.attr = function( elem, name, value, pass ) { // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking // for disconnected elements we don't warn on $( "