r59815 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59814‎ | r59815 | r59816 >
Date:01:11, 8 December 2009
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
Added some handling for the event argument of trigger to be optional.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -251,8 +251,14 @@
252252
253253 context.fn = {
254254 'trigger': function( name, event ) {
255 - // Make a place for extra information to live
256 - event.data = {};
 255+ // Event is an optional argument, but from here on out, at least the type field should be dependable
 256+ if ( event == undefined ) {
 257+ event = { 'type': 'custom' };
 258+ }
 259+ // Ensure there's a place for extra information to live
 260+ if ( event.data == undefined ) {
 261+ event.data = {};
 262+ }
257263 // Allow filtering to occur
258264 if ( name in context.evt ) {
259265 if ( !context.evt[name]( event ) ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r59825UsabilityInitiative: Recombine JS and bump style versions for r59813, r59814,...catrope13:54, 8 December 2009
r59834Fixed unsafe check for undefined in r59815.tparscal18:01, 8 December 2009

Comments

#Comment by Catrope (talk | contribs)   13:39, 8 December 2009
+				event = { 'type': 'custom' };

Shouldn't this be 'type': name?

+			if ( event == undefined ) {

Please use typeof event == 'undefined', the above throws errors under certain conditions in certain browsers (Firefox at least; for once "certain browsers" does not mean IE/Opera).

#Comment by Trevor Parscal (WMF) (talk | contribs)   18:00, 8 December 2009

Good catch.

Status & tagging log