Snippets code from my daily experience

July 7, 2007

Short-circuits, innocent code and nsIDOMEvent targets

Filed under: firefox,flock,mozilla,xpcom,xul — dafi @ 6:08 pm

An user on AMI tells me that my bonsai RichFeedButton doesn’t work when installed together with another extension.

I install the offended extension and discover that RichFeedButton breaks this little jewel!

The solution was simple but the bug hunting was hard 😦

The problem was into an innocent function associated with a listener that simply checks the nsIDOMEvent‘s target id and attrName as shown below
if ( == "xxx" && event.attrName == "yyy") {

For some motivations the “” expression breaks the other extension.

I suspect at some event stage isn’t valid and generates internally some error corrupting (???) the full event queue or simply I’m a bad programmer 😦

The solution??

Simply swaps first equality test with second one

if (event.attrName == "yyy" && == "xxx") {

The javascript short-circuit evaluation ensures me is parsed only if first condition is true. πŸ™‚

Every day I learn something about XUL and its implementation… πŸ˜‰


Blog at

%d bloggers like this: