The real issue is listeners attached twice, and since the call to reshare is immediately preceded by the call to window.confirm I thought it to be redundant. But now I see it's more clear the way you outlined and also it would be good to add a test to check the action upon cancelling the confirmation window.