From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- resources/mediawiki/mediawiki.log.js | 65 +++++++++++++++++++++++++++++++++--- 1 file changed, 60 insertions(+), 5 deletions(-) (limited to 'resources/mediawiki/mediawiki.log.js') diff --git a/resources/mediawiki/mediawiki.log.js b/resources/mediawiki/mediawiki.log.js index ee08b12b..75e4c961 100644 --- a/resources/mediawiki/mediawiki.log.js +++ b/resources/mediawiki/mediawiki.log.js @@ -1,4 +1,4 @@ -/** +/*! * Logger for MediaWiki javascript. * Implements the stub left by the main 'mediawiki' module. * @@ -8,16 +8,21 @@ ( function ( mw, $ ) { + /** + * @class mw.log + * @singleton + */ + /** * Logs a message to the console. * * In the case the browser does not have a console API, a console is created on-the-fly by appending - * a
element to the bottom of the body and then appending this and future + * a `
` element to the bottom of the body and then appending this and future * messages to that, instead of the console. * - * @param {String} First in list of variadic messages to output to console. + * @param {string...} msg Messages to output to console. */ - mw.log = function ( /* logmsg, logmsg, */ ) { + mw.log = function () { // Turn arguments into an array var args = Array.prototype.slice.call( arguments ), // Allow log messages to use a configured prefix to identify the source window (ie. frame) @@ -54,7 +59,7 @@ hovzer.update(); } $log.append( - $( '
' ) + $( '
' ) .css( { borderBottom: 'solid 1px #DDDDDD', fontSize: 'small', @@ -68,4 +73,54 @@ } ); }; + /** + * Write a message the console's warning channel. + * Also logs a stacktrace for easier debugging. + * Each action is silently ignored if the browser doesn't support it. + * + * @param {string...} msg Messages to output to console + */ + mw.log.warn = function () { + var console = window.console; + if ( console && console.warn ) { + console.warn.apply( console, arguments ); + if ( console.trace ) { + console.trace(); + } + } + }; + + /** + * Create a property in a host object that, when accessed, will produce + * a deprecation warning in the console with backtrace. + * + * @param {Object} obj Host object of deprecated property + * @param {string} key Name of property to create in `obj` + * @param {Mixed} val The value this property should return when accessed + * @param {string} [msg] Optional text to include in the deprecation message. + */ + mw.log.deprecate = !Object.defineProperty ? function ( obj, key, val ) { + obj[key] = val; + } : function ( obj, key, val, msg ) { + msg = 'MWDeprecationWarning: Use of "' + key + '" property is deprecated.' + + ( msg ? ( ' ' + msg ) : '' ); + try { + Object.defineProperty( obj, key, { + configurable: true, + enumerable: true, + get: function () { + mw.log.warn( msg ); + return val; + }, + set: function ( newVal ) { + mw.log.warn( msg ); + val = newVal; + } + } ); + } catch ( err ) { + // IE8 can throw on Object.defineProperty + obj[key] = val; + } + }; + }( mediaWiki, jQuery ) ); -- cgit v1.2.3-54-g00ecf