开发者

JavaScript event binding level 1 or level 2?

开发者 https://www.devze.com 2023-01-20 19:32 出处:网络
Since IE 开发者_高级运维does not support event capturing, is it a waste of time using W3C event binding techniques?

Since IE 开发者_高级运维does not support event capturing, is it a waste of time using W3C event binding techniques?

I'm thinking of just going with the level 1 event binding here - http://dean.edwards.name/weblog/2005/10/add-event/ , but I'm having a hard time understanding the need for the hash tabling.


You'll kill yourself implementing your own event system. Just use jQuery's. It's going to be better than anything you'll come up with unless you spend dedicated years on it.

The reason for hash tables is so the event handlers attached can be referenced easily and removed, and can be tracked down easily as well.

To removeEventListener you have to have a reference to the function. If you fed an anonymous one, you don't have a reference to it. That is why the hash tables map the events to the event handlers internally so you don't have to.

0

精彩评论

暂无评论...
验证码 换一张
取 消