Improving Function.prototype.bind

Brendan Eich brendan at mozilla.com
Sun Jan 8 21:29:21 PST 2012


On Jan 8, 2012, at 7:20 PM, John J Barton wrote:

> On Sun, Jan 8, 2012 at 3:35 PM, Brendan Eich <brendan at mozilla.com> wrote:
>> Firebug uses a library bind a lot, and we continually struggled with the memoization problem; we did not try to solve it in part because we hated Firebug's bind: it made debugging even more painful since it messes up the call stack. Using the ES bind() ends up not being a win, since I now have exactly the same problems.
> 
> I have a question: why is bind used so much in Firebug for event listeners, when the DOM guarantees to dispatch them with the event target bound to |this|? Way back in '95, I created event handlers but did not add bind (it had to be discovered later). But dynamic |this| binding combined with DOM event target-based listening and handling kept this properly bound. What has changed?
> 
> Sorry I don't know what you mean here.

Why all the this-binding in Firebug if (as you suggested and a grep seems to confirm [but I skimmed]) the methods being this-bound are all or mostly event listeners? The DOM dispatches event handlers on the correct |this|. Why not use dynamic (unbound) |this|?

/be

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120108/608bdafe/attachment-0001.html>


More information about the es-discuss mailing list