YAHOO.util.Event.throwErrors is important and often ignored in YUI. The default value for this is false. As a result, any javascript error will be caught and ignored(but written in YUI debug console) in event callback.

e.g.
consider following code:

var evnt = new YAHOO.util.CustomEvent("myevent",{name:"scope"});
evnt.subscribe(
	function(type, args, me){
		console.log(this);
		console.log(args);
		console.log(me);
	},
	{name:"me"})
evnt.fire({name:"args"});

it works fine and print out values in FireBug console. what happen if we make typo

var evnt = new YAHOO.util.CustomEvent("myevent",{name:"scope"});
evnt.subscribe(
	function(type, args, me){
		console.log(this);
		console.lg(args); //typo
		console.log(me);
	},
	{name:"me"})
evnt.fire({name:"args"});

ops….nothing happens. no error message! if one doesn’t spot the typo at first, going to take long time to debug.

the trick is simple and easy

YAHOO.util.Event.throwErrors = true;
Advertisements