ソースを参照

EventDispatched: Added check for existing array in removeListener as per #4202.

Mr.doob 11 年 前
コミット
673d5dc5f7
1 ファイル変更9 行追加3 行削除
  1. 9 3
      src/core/EventDispatcher.js

+ 9 - 3
src/core/EventDispatcher.js

@@ -58,11 +58,17 @@ THREE.EventDispatcher.prototype = {
 		if ( this._listeners === undefined ) return;
 
 		var listeners = this._listeners;
-		var index = listeners[ type ].indexOf( listener );
+		var listenerArray = listeners[ type ];
 
-		if ( index !== - 1 ) {
+		if ( listenerArray !== undefined ) {
 
-			listeners[ type ].splice( index, 1 );
+			var index = listenerArray.indexOf( listener );
+
+			if ( index !== - 1 ) {
+
+				listenerArray.splice( index, 1 );
+
+			}
 
 		}