瀏覽代碼

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 );
+
+			}
 
 		}