Hi there. I don't know if this mailing list is the right place to post
this message. I'd like to discuss a choice made in Prototype.

I have a problem with the Event.fire function and the event.memo
property. Prototype 1.6.1 says

      event.memo = memo || { }; // line 4070

So any memo value that evaluates to false is discarded and replaced by
{}, be it "", 0, false, null or undefined. I find it rather annoying,
since my event observer wants to receive false values untouched (in my
case, a string that can be empty).

Is this substitution necessary? It doesn't look like the default memo
value is used anywhere in Prototype. Why not set event.memo to
undefined if the memo argument is not provided:

      event.memo = memo;

Or, if the default {} value is important, set it only if
arguments.length < 3:

      event.memo = arguments.length > 2 ? memo : {};

All in all, I think the practice of replacing an argument based on its
boolean evaluation to be dangerous, and I would like to know your
opinion on the case of event.memo.

-- 
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en

To unsubscribe from this group, send email to 
prototype-core+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to