Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于engine.bind 和 engine.unbind 的一点疑问 #6

Open
ziluo opened this issue May 9, 2014 · 4 comments
Open

关于engine.bind 和 engine.unbind 的一点疑问 #6

ziluo opened this issue May 9, 2014 · 4 comments

Comments

@ziluo
Copy link

ziluo commented May 9, 2014

根据bind的代码可以看出,el实际上绑定的回调函数其实是将handler包装后的proxy。在unbind函数中,当handler不存在的情况下,默认是解绑el上evt类型的所有回调函数,代码里面解绑的回调函授是从el.listeners取出来的,可el. listeners中的函数都是未包装的handler函数,因此,我认为这种情况下unbind是没有效果的,求解~~

@huang-xin
Copy link
Contributor

同学你太细心了~
确实是个bug, 着手修复.

@MichaelGong
Copy link

这个问题还没有修复?也就是说现在只能绑定事件,并不能解除事件绑定?

@clg333zzz
Copy link

好像一直没去修复这个bug。
删除
if (!el.listeners[evt]) { el.listeners[evt] = [handler]; } else { el.listeners[evt].push(handler); }


this.proxies.push(proxy);
后面添加
if(!el.listeners[evt]) { el.listeners[evt] = [proxy]; } else { el.listeners[evt].push(proxy); }

@466102061
Copy link

WechatIMG1

解绑函数的这个地方也有问题吧,这边this显然不是engine,是不是可以改成以下方式?

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants