This is a "please help me understand X" question, not a "please help me fix X" question.
I was doing some work on a site with a legacy proprietary CMS that only works with jQuery 1.4.4 (ugh) when I realised my code must be hitting an error, but no error messages were showing in the console (in all browsers I tried - Chrome, Firefox, Safari, IE...).
Lots of trial and error later, I figured out that within any code triggered by jQuery 1.4.4's mouseenter
event (and therefore also its hover
shorthand), errors weren't being shown in the console. console.log
still logged just fine, and the code would fall over as would be expected, but silently.
I don't understand how this is possible. I'd like to know how it is possible so that, if in future I end up in a similar position where code is hitting silent errors, I know what to look for - and so I know how to avoid causing a similar situation by accident.
Prior research
I've tried searching for old jQuery bug reports, which might include relevant information, but I couldn't find any. I've read through a lot of SO questions from people trying to cause JS error suppression, but the answers suggest it's a user preference that couldn't apply to some lines of code but not others. I've looked through the jQuery 1.4.4 source code, but nothing looks relevant to my eye.
I'm not interested in fixing the problem (that's as simple as updating jQuery) - but I'd like to understand what causes this to happen, because I can't see how it's possible.
Simple live demo
$(document).ready(function(){
$('.mouseenter').mouseenter(function(){
console.log("FAIL .mouseenter");
FAIL; // fails silently
console.log("hit error, so this code isn't reached");
});
$('.mouseover').mouseover(function(){
console.log("FAIL .mouseover");
FAIL; // shows error as expected
console.log("hit error, so this code isn't reached");
});
});
div { height: 60px; background: #c1c1c1; margin: 10px; padding: 10px; }
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
</head>
<body>
<div class="mouseenter">mouseenter - hides error on hover</div>
<div class="mouseover">mouseover - shows error on hover</div>
</body>
After mouseovering around the console looks like this - mouseover
shows error in console, mouseenter
doesn't, but both hit the error and fall over: