r112451 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112450‎ | r112451 | r112452 >
Date:22:46, 26 February 2012
Author:tstarling
Status:resolved (Comments)
Tags:
Comment:
* Fix r111983 (bug 34662): make mw.toolbar.addButton() work even after DOM ready
* Don't use an empty array as the default for $toolbar, use false which will throw an exception on a logic error.
* Fix exception handling in mw.loader: have handlePending() rethrow its exception so that the exception handler in execute() can run, so that the exception gets logged. But don't rethrow the exception in execute(), because that may break other modules.
Modified paths:
  • /trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/resources/mediawiki.action/mediawiki.action.edit.js
@@ -3,12 +3,17 @@
44 var currentFocused = $( '#wpTextbox1' );
55
66 mw.toolbar = {
7 - $toolbar : [],
 7+ $toolbar : false,
88 buttons : [],
 9+ isReady : false,
910 // If you want to add buttons, use
1011 // mw.toolbar.addButton( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText );
1112 addButton : function() {
12 - this.buttons.push( [].slice.call( arguments ) );
 13+ if ( isReady ) {
 14+ this.insertButton.apply( this, arguments );
 15+ } else {
 16+ this.buttons.push( [].slice.call( arguments ) );
 17+ }
1318 },
1419 insertButton : function( imageFile, speedTip, tagOpen, tagClose, sampleText, imageId, selectText ) {
1520 var image = $('<img>', {
@@ -42,18 +47,20 @@
4348 init : function() {},
4449
4550 onReady : function() {
46 - mw.toolbar.$toolbar = $( '#toolbar' );
 51+ this.$toolbar = $( '#toolbar' );
 52+ isReady = true;
4753 // Legacy
4854 // Merge buttons from mwCustomEditButtons
4955 var buttons = [].concat( this.buttons, window.mwCustomEditButtons );
5056 for ( var i = 0; i < buttons.length; i++ ) {
5157 if ( $.isArray( buttons[i] ) ) {
5258 // Passes our button array as arguments
53 - mw.toolbar.insertButton.apply( this, buttons[i] );
 59+ this.insertButton.apply( this, buttons[i] );
5460 } else {
5561 // Legacy mwCustomEditButtons is an object
5662 var c = buttons[i];
57 - mw.toolbar.insertButton( c.imageFile, c.speedTip, c.tagOpen, c.tagClose, c.sampleText, c.imageId, c.selectText );
 63+ this.insertButton( c.imageFile, c.speedTip, c.tagOpen,
 64+ c.tagClose, c.sampleText, c.imageId, c.selectText );
5865 }
5966 }
6067 return true;
Index: trunk/phase3/resources/mediawiki/mediawiki.js
@@ -630,6 +630,7 @@
631631 j -= 1;
632632 }
633633 }
 634+ throw e;
634635 }
635636 }
636637
@@ -785,7 +786,6 @@
786787 console.log( 'mw.loader::execute> Exception thrown by ' + module + ': ' + e.message );
787788 }
788789 registry[module].state = 'error';
789 - throw e;
790790 }
791791 }
792792

Follow-up revisions

RevisionCommit summaryAuthorDate
r112456Release notes for added feature in r112451 which fixed bug 33952krinkle23:47, 26 February 2012
r112567Fix scoping in r112451: isReady was accidentally used as a global variablecatrope02:36, 28 February 2012
r1125701.19wmf1: MFT r111983, r112384, r112451, r112561, r112562, r112567catrope02:55, 28 February 2012
r112573[mediawiki.action.edit] Clean up and bug fixes...krinkle03:17, 28 February 2012
r112647MFT r112384, r112400, r112408, r112451, r112456, r112474, r112526, r112533, r...reedy21:21, 28 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r88392Changing console.log(e) to a throw. console.log makes it go toString() which ...krinkle20:31, 18 May 2011
r111983* Fixed failure of the edit toolbar to load when $wgResourceLoaderExperimenta...tstarling23:29, 20 February 2012

Comments

#Comment by Wikinaut (talk | contribs)   23:44, 26 February 2012

this fixes at least bug34662 "no toolbar (editbar) icons in trunk since r111983" (closed now).

Status & tagging log