Skip to main content

Bug Tracker

Side navigation

#13782 closed bug (wontfix)

Opened April 16, 2013 12:04PM UTC

Closed April 16, 2013 03:44PM UTC

Uncaught exception in event handler will prevent subsequent script executing

Reported by: caikanxp Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Uncaught exception in event handler will prevent subsequent script executing.

<script type="text/javascript" src=""></script>
<button id="dom">DOM attached</button>
<button id="jq">jQuery attached</button>
<script type="text/javascript">
function log(msg) {
with ($('#dom')[0]) {
	addEventListener('click', function() {
		log('DOM 1');
	addEventListener('click', function() {
		null.log('DOM 2'); // throw an exception
	addEventListener('click', function() {
		log('DOM 3');
$('#jq').click(function(e) {
	log('jQuery 1');
}).click(function(e) {
	null.log('jQuery 2'); // throw an exception
}).click(function(e) {
	log('jQuery 3');

Chrome 26

jQuery 1.9.1

Click button "DOM attached", all 3 handlers will be called. Output:

jQuery 1
[Uncaught Error]
jQuery 2

Click button "jQuery attached", the last handler will not run. Output:

jQuery 1
[Uncaught Error]

IE attachEvent() has similar results, but only in an opposite execution order.


Attachments (0)
Change History (1)

Changed April 16, 2013 03:44PM UTC by timmywil comment:1

resolution: → wontfix
status: newclosed

In order to continue subsequent callbacks, jQuery would have to catch the error, which is not a good solution. If an error is acceptable, a try/catch can be implemented by the user.