This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html Multipage: http://www.whatwg.org/C#event-handler-attributes Complete: http://www.whatwg.org/c#event-handler-attributes Referrer: Comment: No need to special case onerror event handler Posted from: 2620:0:1003:1017:2e41:38ff:fea6:f2aa User agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1951.5 Safari/537.36
I don't think we need to add new warts to http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#getting-the-current-value-of-the-event-handler window.onerror is pretty new to be consistently implemented in browsers and we (Blink & WebKit) do not expose source, lineno, colno, nor error as arguments.
> and we (Blink & WebKit) do not expose source, lineno, colno, nor error as > arguments. Uh.... <script> onerror = function(a, b, c, d, e, f) { document.write(Array.prototype.slice.call(arguments)); } throw new Error("haha"); </script> shows Uncaught Error: haha,file:///Users/bzbarsky/test.html,5,9,Error: haha for me in Blink. It shows Error: haha,file:///Users/bzbarsky/test.html,5 in Safari. So both have the source location and line number. Blink also has the column number and exception object.
Oh, and the exception object is a common web author request here; Gecko recently added it because of that.
Sorry, if this wasn't clear. I'm only talking about onerror as an attribute event handler. http://jsbin.com/halilova/1/ <!DOCTYPE html> <body onerror="console.log(source, lineno, colno, error)"> <script> syntax error </script> Chrome 35: does not add any of the above. Firefox 31: adds source and lineno but not colno or error. IE11: Does not invoke the handle. (Don't have access to a Mac at the moment)
I'm somewhat opposed to there being a difference between the "attribute event handler" case and the function being assigned to .onerror case. All that happens with the attribute is a function is compiled and then assigned, and they should behave identically. Current Firefox nightlies show a column number and exception object in your example. Safari 7.0.3 seems to not invoke the handler at all.
And in particular, consider this testcase: <body onerror="document.write(Array.prototype.slice.call(arguments));"> <script> onerror = onerror; throw new Error("haha"); </script> </body> Blink has different behavior depending on whether the "onerror = onerror" line is there, which seems pretty weird.
I agree with Boris here. I think it's good to be consistent between attribute event handler and IDL event handler. If you don't like <body onerror> then it seems more sane to argue that it shouldn't reflect window.onerror at all. (But then that would affect document.body.onerror also I guess...) In webdevdata data set 2013-09-01 102,000 pages I found one match for grep -Ei "<body\s+[^>]*onerror\s*=[^>]+>": http://www.lmt.lv/lv <body id="page-sakumlapa" class="lv" onerror="js_error_reporter(event, source, lineno);"> so it's not high usage but it's not zero either.
arv, are zcorpan and bz's comments sufficiently convincing for you here?
Yeah. bz has me convinced.
Cool.