enchant.js で clearEventListener すると Collection から削除される

enchant.js で clearEventListener すると Collection から削除される

clearEventListener
enchant.Entity

enchant.js
Copied!
// enchant.Entity = ...
{
clearEventListener: function() {
_nodePrototypeClearEventListener.apply(this, arguments);
if (this.scene) {
this._removeSelfFromCollection(); // 問題のコード
}
},
// ...
_removeSelfFromCollection: function() {
if (!this._isContainedInCollection) {
return;
}

var Constructor = this.getConstructor();
Constructor._collectionTarget.forEach(function(C) {
var i = C.collection.indexOf(this);
if (i !== -1) {
C.collection.splice(i, 1);
}
}, this);

this._isContainedInCollection = false;
},
}

本来の挙動は「イベントリスナーから特定のタイプのイベントハンドラを全て除去する」であるはず
最初の行だけでそれは達成しているはずだが、 enchant.Entity はなぜかそれをオーバーライドして、コレクションからオブジェクトを削除している
Powered by Helpfeel