Bug Tracker

Modify

Ticket #3982 (closed bug: fixed)

Opened 4 years ago

Last modified 14 months ago

jQuery.error event gets incorrect arguments

Reported by: dmethvin Owned by: brandon
Priority: major Milestone: 1.4
Component: event Version: 1.3.1
Keywords: error onerror Cc:
Blocking: Blocked by:

Description

The $(window).error() event/method doesn't pass the documented arguments correctly.

 http://docs.jquery.com/Events/error#fn

A normal event gets one object, which is the event on most browsers (except IE which has a global event object). The window.onerror hander is defined to get THREE arguments: message, url, line number. Returning true prevents the default browser error dialog from being displayed. This is the opposite of a normal event where returning false prevents the default action.

In the test case attached, Firefox does call the jQuery handler but it gets only an incorrect event object. IE doesn't seem to call the jQuery handler.

A few possible solutions: 1) Drop support for the error event and have people use the native window.onerror. 2) Support the event as the native handler is documented, with three arguments and returning true to avoid a browser dialog. 3) Support the event but pass a special event object with properties similar to IE's and return false to avoid a browser dialog.

Attachments

test-3982.html Download (593 bytes) - added by dmethvin 4 years ago.
Test for window.onerror event

Change History

Changed 4 years ago by dmethvin

Test for window.onerror event

comment:1 Changed 4 years ago by brandon

  • Milestone changed from 1.3.2 to 1.3.3

Hmm. We could probably implement this as a special event but my current thinking is just to recommend the native option or use a plugin for this scenario.

comment:2 Changed 4 years ago by dmethvin

Given how crazy the error event is, and how frequently it's used, I agree that it's easiest to remove support for it. I've added a note to the docs already since it didn't work anyway.

comment:3 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to fixed

Fixed via docs.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.