Prevent mem-leak in buttons

Event handler should not have a reference to the DOM node in its context
This commit is contained in:
Kovid Goyal 2015-11-12 11:58:52 +05:30
parent 6f263dd3fc
commit 191381f7da

View File

@ -13,7 +13,7 @@ def create_button(text, icon=None, action=None, tooltip=None):
text = '\xa0' + text
ans = E.button(E.i(class_=cls), text, class_='calibre-push-button', type='button', title=tooltip or '')
if action is not None:
ans.addEventListener('click', def(event): event.preventDefault(), action(event, ans);)
ans.addEventListener('click', def(event): event.preventDefault(), action(event);)
return ans
create_button.style = build_rule('button.calibre-push-button',