Strange behaviour overriding ComboBox.dispatchEvent

28 views
Skip to first unread message

Guido Tapia

unread,
May 28, 2012, 6:40:06 PM5/28/12
to closure-lib...@googlegroups.com
Hi All,

I'm trying to do my own ComboBox that extends goog.ui.ComboBox; just so I can keep track of the selected MenuItem rather than just work with the text captions. So I thought overriding the dispatchEvent method would be the best way to do this so I have:

/** @inheritDoc */
my.MyComboBox.prototype.dispatchEvent = function(e) {
   my.MyComboBox.superClass_.dispatchEvent.call(this, e);
};

But, just adding this code breaks the ComboBox (the selector panel does not hide upon selection).  To me this code pretty much looks like it has no side effects, how did it break the events? 

Note: Removing these 3 lines of code and everything works as expected.

Thanks in advance

Nick Santos

unread,
May 29, 2012, 10:23:01 AM5/29/12
to closure-lib...@googlegroups.com
That seems pretty weird. Have you been able to reproduce it in isolation?

Peter Pallos

unread,
May 29, 2012, 10:34:28 AM5/29/12
to closure-lib...@googlegroups.com
I see one potential issue.
MyComboBox#dispatchEvent doesn't return anything, while the original method has boolean return value.

Peter

Guido Tapia

unread,
May 29, 2012, 4:31:46 PM5/29/12
to closure-lib...@googlegroups.com
I stared at this code for soooo long, I cannot believe I missed the return!! I have just confirmed that this was in fact the bug.

Well I guess to save face I'll say this was a graphic demonstration of a compiler feature request.  I would have loved to see a warning here.

Thanks for the help guys
Reply all
Reply to author
Forward
0 new messages