Finally, I got it!

In the inside of Hash.initialize Object.clone is called:

var Hash = Class.create(Enumerable, (function() {
  function initialize(object) {
    if(typeof object == 'undefined'){alert(arguments.callee)}
    this._object = Object.isHash(object) ? object.toObject() : 
Object.clone(object);
  }
..cut..
}

 .. and it takes an empty object literal to extended it with all the 
properties of the source object:

  function clone(object) {
    return extend({ }, object);
  }

So, there is a returned "empty" object literal even if Hash.initialize is 
called without the expected "object" argument just like in 
Element.Layout.initialize.

This is NOT AT ALL an intuitive solution and can only  create much 
confusion about how Class creation works in Prototype. The transparent ( 
commonly used ) solution is to default the object argument to an empty 
object literal in the inside of Hash.initialize:

 function initialize(object) {
    if(Object.isUndefined(object)){ object = {};}
    this._object = Object.isHash(object) ? object.toObject() : 
Object.clone(object);
  }
Thanx guys!
 



-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/_vrqRFqNck8J.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to