[Proto-Scripty] Re: wrap getStyle

2009-01-14 Thread Mona Remlawi

the thing is by the time the element.getStyle executes, element would
have ceised to exist!
twisted logic i'm trying to workaround phh

On Wed, Jan 14, 2009 at 2:46 PM, kangax  wrote:
>
> On Jan 14, 6:29 am, Mona Remlawi  wrote:
>> hello prototypers,
>> for some reason, i need to wrap getStyle method by a try/catch.
>
> Is `getStyle` throwing errors? If so, it might be a bug which needs to
> be fixed/documented.
>
>> obviously, best way would be the wrap method (doh!)
>> but doesn't seem to work here. i can use another pair of eyes for help
>>
>> --
>> // wrap getStyle function with try/catch
>> // as IE6 throws errors
>> Element.Methods.getStyle = Element.Methods.getStyle.wrap(
>> function(proceed, element, style) {
>> try {return proceed(element, style) }
>> catch(e) {return null}
>> }
>> );
>> --
>>
>> thanks a milllion
>
> You need to call `addMethods`. Simple method overwriting doesn't
> actually change much:
>
> Element.addMethods({
>  getStyle: Element.Methods.getStyle.wrap(
>function($p, element, style){
>  try { return $p(element, style) }
>  catch(e) { return null }
>}
>  )
> });
>
> --
> kangax
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



[Proto-Scripty] Re: wrap getStyle

2009-01-14 Thread kangax

On Jan 14, 6:29 am, Mona Remlawi  wrote:
> hello prototypers,
> for some reason, i need to wrap getStyle method by a try/catch.

Is `getStyle` throwing errors? If so, it might be a bug which needs to
be fixed/documented.

> obviously, best way would be the wrap method (doh!)
> but doesn't seem to work here. i can use another pair of eyes for help
>
> --
> // wrap getStyle function with try/catch
> // as IE6 throws errors
> Element.Methods.getStyle = Element.Methods.getStyle.wrap(
>     function(proceed, element, style) {
>         try {return proceed(element, style) }
>         catch(e) {return null}
>     }
> );
> --
>
> thanks a milllion

You need to call `addMethods`. Simple method overwriting doesn't
actually change much:

Element.addMethods({
  getStyle: Element.Methods.getStyle.wrap(
function($p, element, style){
  try { return $p(element, style) }
  catch(e) { return null }
}
  )
});

--
kangax
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---