Permalink
Browse files

dojo/on: added on.handleError for addListener

  • Loading branch information...
1 parent bcdbeab commit a4b672a4cf847796e7c4cece999d03fcf964df16 @miksago miksago committed Mar 6, 2013
Showing with 11 additions and 1 deletion.
  1. +11 −1 on.js
View
12 on.js
@@ -105,7 +105,17 @@ define(["./has!dom-addeventlistener?:./aspect", "./_base/kernel", "./has"], func
return addListener(target, type, listener, dontFix, matchesTarget);
};
var touchEvents = /^touch/;
- function addListener(target, type, listener, dontFix, matchesTarget){
+ function addListener(target, type, _listener, dontFix, matchesTarget){
+ var listener = _listener;
+ if(typeof on.handleError === "function"){
+ listener = function(){
+ try{
+ return _listener.apply(this, arguments);
+ }catch(err){
+ on.handleError(err);
+ }
+ };
+ }
// event delegation:
var selector = type.match(/(.*):(.*)/);
// if we have a selector:event, the last one is interpreted as an event, and we use event delegation

0 comments on commit a4b672a

Please sign in to comment.