Hi romain, yoshi,

I would have done that instead of a specific hash_wrapper function:

$H.wrap(
  function(originalFunction,myVar){
    if (myVar && (myVar.constructor == Array) && (myVar.length == 0))
{
      return originalFunction();
    }
    return originalFunction(myVar);
  }
)

var aTest=[123,'abc'];
alert($H(aTest).inspect());
var aTest=[];
alert($H(aTest).inspect());

so you 'll don't have to change anything in the code, the $H call stay
$H calls and everything is done in the wrap function insrtead.

Btw, I think you should think to convert all elements to the new
syntax !
@Romain, I think now I understand your trouble, which was not evident
on you proper thread.

--
david

On 8 oct, 19:40, yoshi <yosh...@hotmail.com> wrote:
> just thinking out loud here, when you $H ur array object, is it
> hashing  all the extra functions prototype put in Array.prototype like
> find(), findAll(), etc?
>
> cuz if i do
> var hash1 = $H([1,2,3])
> hash1.size() is not equal to hash1.length because
>
> length is an array property and size is a hash method
>
> On Oct 8, 7:16 am, Romain Dequidt <dequidt.rom...@gmail.com> wrote:
>
> > Would that be a relevant wrapper?
> >     function hash_wrapper(var)
> >     {
> >         if (var && (var.constructor == Array) && (var.length == 0)) {
> >             return;
> >         }
> >         return $H(var);
> >     }
>
> > On 8 oct, 15:55, Romain Dequidt <dequidt.rom...@gmail.com> wrote:
>
> > > My problem (http://groups.google.fr/group/prototype-scriptaculous/t/
> > > 313d3a8b674d5b28?hl=fr) comes from that issue.
> > > The "errors" object is actually a empty array when there is no error.
> > > But when I try to create my hash by doing:
> > > $H(transport.responseJSON.errors)
> > > the result is a weird hash (size() == 38!!!!!)
>
> > > yoshi, how do you fixed it? what kind of test should I do before the
> > > hash creation?
>
> > > On 8 oct, 00:34, yoshi <yosh...@hotmail.com> wrote:
>
> > > > i m trying to upgrade prototype 1.5.1 to 1.6.1, then realized that the
> > > > $H changed, and not compatible with '[]' anymore.
>
> > > > the code base is huge, and $H is used very often. i m wondering if
> > > > theres a smarter way then
> > > > 1) writing my own wrapper around $H, so it works with old code, or
> > > > 2) surgically update all variables using $H
>
> > > > thanks in advance
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
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