Bug 1105237 - [Loop] Move 'share' logic to a separate handler r=crdlc

I need to check if there is `onerror` before, that's why it's here.