From c7f184f199564d53b6962fd308cf05362dcb3b24 Mon Sep 17 00:00:00 2001 From: Mark Salsbery Date: Tue, 27 Aug 2013 10:10:55 -0700 Subject: [PATCH] Reverted breaking change for issue #201 To be grouped with other breaking changes for major version release. Also, minor formatting fix in src/eventhandler.js --- src/eventhandler.js | 4 ++-- src/tilesource.js | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/eventhandler.js b/src/eventhandler.js index 0fafc743..56fbf080 100644 --- a/src/eventhandler.js +++ b/src/eventhandler.js @@ -122,9 +122,9 @@ $.EventHandler.prototype = { Array.apply( null, events ); return function ( source, args ) { var i, - length = events.length; + length = events.length; for ( i = 0; i < length; i++ ) { - if (events[ i ]) { + if ( events[ i ] ) { args.userData = events[ i ].userData; events[ i ].handler( source, args ); } diff --git a/src/tilesource.js b/src/tilesource.js index 220e8f6f..923806b2 100644 --- a/src/tilesource.js +++ b/src/tilesource.js @@ -117,8 +117,15 @@ $.TileSource = function( width, height, tileSize, tileOverlap, minLevel, maxLeve for ( i = 0; i < arguments.length; i++ ) { if ( $.isFunction( arguments[ i ] ) ) { callback = arguments[ i ]; - this.addHandler( 'ready', function ( placeHolderSource, placeHolderArgs ) { - callback( placeHolderArgs.tileSource ); + // TODO Send generic object wrapping readySource as a property (breaking change) + // TODO Maybe placeHolderSource should be passed to callback as well for consistency + // with event handler signature? + // Should be this (although technically it works as-is): + //this.addHandler( 'ready', function ( placeHolderSource, placeHolderArgs ) { + // callback( placeHolderArgs ); + //} ); + this.addHandler( 'ready', function ( placeHolderSource, readySource ) { + callback( readySource ); } ); //only one callback per constructor break; @@ -301,7 +308,10 @@ $.TileSource.prototype = { options = $TileSource.prototype.configure.apply( _this, [ data, url ]); readySource = new $TileSource( options ); _this.ready = true; - _this.raiseEvent( 'ready', { tileSource: readySource } ); + // TODO Send generic object wrapping readySource as a property (breaking change) + // Should be this: + //_this.raiseEvent( 'ready', { tileSource: readySource } ); + _this.raiseEvent( 'ready', readySource ); }; if( url.match(/\.js$/) ){