While paring down my problem code to post a test case, I found that my project was using an outdated version of jQuery. Upgrading fixed my original problem (detecting the mouse leaving the document was meant to be a workaround). Thanks all for your help.