OSDN Git Service

Version 0.6.129, fix X.Node.
[pettanr/clientJs.git] / 0.6.x / js / 01_core / 13_XEventDispatcher.js
index b3763fc..25c2d11 100644 (file)
@@ -120,6 +120,14 @@ X.EventDispatcher =
                 * @type {boolean}\r
                 */\r
                        '_killReserved' : false,\r
+\r
+               /**\r
+                * asyncDispatch 中に kill が呼ばれた場合に、X.EventDispatcher インスタンスの削除を最後のタイマーの発火後にずらすために立てるフラグ。\r
+                * TODO asyncDispatch の解除はどうする?\r
+                * @private\r
+                * @type {boolean}\r
+                */\r
+                       '_lastLazyID' : false,\r
                        \r
            /**\r
             * X.EventDispatcher のコンストラクタの実体。\r
@@ -229,7 +237,7 @@ X.EventDispatcher =
                                        e = delay;\r
                                        delay = 0;\r
                                };\r
-                               return X.Timer.add( delay, 1, this, this.dispatch, [ e ] );\r
+                               return this[ '_lastLazyID' ] = X.Timer.add( delay, 1, this, X_EventDispatcher_dispatch, [ e ] );\r
                        }\r
                }\r
        );\r
@@ -297,6 +305,11 @@ function X_EventDispatcher_dispatch( e ){
        };\r
        \r
        if( ( --this._dispatching ) === 0 ){\r
+               \r
+               if( this[ '_lastLazyID' ] && X_Timer_currentUID === this[ '_lastLazyID' ] ){\r
+                       delete this[ '_lastLazyID' ];\r
+               };\r
+               \r
                // dispatch 中に unlisten された要素の削除\r
                unlistens = this._unlistens;\r
                delete this._dispatching;\r
@@ -304,6 +317,7 @@ function X_EventDispatcher_dispatch( e ){
                // _unlistens に入っている callbackHash は、lock をクリアしている\r
                X_EventDispatcher_unlock = true;\r
                for( type in unlistens ){\r
+                       //if( X_EMPTY_OBJECT[ type ] ) continue;\r
                        list = unlistens[ type ];\r
                        for( i = list.length; i; ){\r
                                this.unlisten( type, list[ --i ] );\r
@@ -419,6 +433,7 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){
        if( opt_type === undefined ){\r
                // 全て削除\r
                for( opt_type in list ){\r
+                       //if( X_EMPTY_OBJECT[ opt_type ] ) continue;\r
                        _list = list[ opt_type ];\r
                        for( i = _list.length; i; ){\r
                                this.unlisten( opt_type, _list[ --i ] ); // override されていることがあるので、必ず unlisten を使用\r
@@ -521,7 +536,6 @@ var X_EventDispatcher_actualAddEvent =
                        } else {\r
                                console.log( 'event > ' + type );\r
                                that._handleEvent || ( that._handleEvent = X_Callback_create( that, X_EventDispatcher_actualHandleEvent ) );\r
-                               \r
 \r
                                if( raw.addEventListener ){\r
                                        raw.addEventListener( type, that._handleEvent, false );\r
@@ -754,6 +768,7 @@ function X_EventDispatcher_toggleAllEvents( that, add ){
                type;\r
        if( !list || !raw ) return;\r
        for( type in list ){\r
+               //if( X_EMPTY_OBJECT[ type ] ) continue;\r
                // 数字イベントの除外\r
                if( '' + parseFloat( type ) !== type ){\r
                        // TODO type rename はここ\r