Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-12-05 Thread Klaus Hartl
Jörn Zaefferer schrieb:
> Klaus Hartl schrieb:
>> Brian Miller schrieb:
>>   
>>> Is this patch generalized enough to add to the core?  Just a thought...
>>> 
>> Brian, it's actually just a check if the object is not null before 
>> accessing it:
>>
>> As it is:
>> ret =
>> document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
>>
>>
>> The patch (with Dave's proposal to avoid two calls):
>>
>> var computedStyle = document.defaultView.getComputedStyle(this, null);
>> ret = computedStyle && computedStyle.getPropertyValue(prop);
>>
>> I think that one does no harm. ret may be null in certain cases in 
>> Safari but that's better than throwing a nullpointer, right?
>>
>> It could also return an empty string if that's more robust:
>> ret = computedStyle && computedStyle.getPropertyValue(prop) || '';
>>   
> Could you file that as a bug report if you think it should be fixed in core?


I worked around that bug at Plazes, so I have an unpatched jQuery now. 
Nonetheless I have created a ticket because I think it makes sense to 
fix this:

http://jquery.com/dev/bugs/bug/467/

You can decide on this.


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-11-30 Thread Jörn Zaefferer
Klaus Hartl schrieb:
> Brian Miller schrieb:
>   
>> Is this patch generalized enough to add to the core?  Just a thought...
>> 
>
> Brian, it's actually just a check if the object is not null before 
> accessing it:
>
> As it is:
> ret =
> document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
>
>
> The patch (with Dave's proposal to avoid two calls):
>
> var computedStyle = document.defaultView.getComputedStyle(this, null);
> ret = computedStyle && computedStyle.getPropertyValue(prop);
>
> I think that one does no harm. ret may be null in certain cases in 
> Safari but that's better than throwing a nullpointer, right?
>
> It could also return an empty string if that's more robust:
> ret = computedStyle && computedStyle.getPropertyValue(prop) || '';
>   
Could you file that as a bug report if you think it should be fixed in core?

-- 
Jörn Zaefferer

http://bassistance.de


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-11-30 Thread Klaus Hartl
Brian Miller schrieb:
> Is this patch generalized enough to add to the core?  Just a thought...

Brian, it's actually just a check if the object is not null before 
accessing it:

As it is:
ret =
document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);


The patch (with Dave's proposal to avoid two calls):

var computedStyle = document.defaultView.getComputedStyle(this, null);
ret = computedStyle && computedStyle.getPropertyValue(prop);

I think that one does no harm. ret may be null in certain cases in 
Safari but that's better than throwing a nullpointer, right?

It could also return an empty string if that's more robust:
ret = computedStyle && computedStyle.getPropertyValue(prop) || '';



-- Klaus


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-11-29 Thread Brian Miller
Is this patch generalized enough to add to the core?  Just a thought...

- Brian

> John Resig schrieb:
>> Unfortunately, the hack to work around that is too monstrous to
>> comprehend. For now, it works fine in Safari for most cases, and
>> that's what matters.
>
> That is exactly the problem I have. So I will have to live with my
> patched version for Plazes?
>
>
> -- Klaus



___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-11-29 Thread Klaus Hartl
John Resig schrieb:
> Yeah, this has been fixed for a while now. The one case that isn't
> accounted for (yet) is having a parent element that has a display set
> to none - that kills computedStyle for all sub-elements.
> Unfortunately, the hack to work around that is too monstrous to
> comprehend. For now, it works fine in Safari for most cases, and
> that's what matters.

That is exactly the problem I have. So I will have to live with my 
patched version for Plazes?


-- Klaus

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-11-29 Thread John Resig
Yeah, this has been fixed for a while now. The one case that isn't
accounted for (yet) is having a parent element that has a display set
to none - that kills computedStyle for all sub-elements.
Unfortunately, the hack to work around that is too monstrous to
comprehend. For now, it works fine in Safari for most cases, and
that's what matters.

--John

On 11/29/06, Klaus Hartl <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> A while ago I reported a bug, which I couldn't really narrow down, so it
> never went into a ticket:
> http://jquery.com/discuss/2006-August/010401/
>
> The problem was that in line 1315:
>
> ret =
> document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
>
> document.defaultView.getComputedStyle(this,null) returns null causing an
> error in Safari obviously.
>
> I fixed it with the following:
>
> ret = document.defaultView.getComputedStyle(this,null) &&
> document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
>
> A few minutes ago I stumbled upon a post, which exactly explains that bug:
> http://snook.ca/archives/javascript/safari2_display-none_getcomputedstyle/
>
> So I wonder if we should merge the fix into jQuery finally?
>
>
> -- Klaus
>
> ___
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Bug: "display: none" plus getComputedStyle in Safari

2006-11-29 Thread Dave Methvin
> A while ago I reported a bug, which I couldn't really 
> narrow down, so it never went into a ticket:
> http://jquery.com/discuss/2006-August/010401/
> 
> The problem was that in line 1315:
> ret =
document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
> 
> document.defaultView.getComputedStyle(this,null) returns
> null causing an error in Safari obviously.
> 
> I fixed it with the following:
> 
> ret = document.defaultView.getComputedStyle(this,null) &&
document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
> 
> A few minutes ago I stumbled upon a post, which 
> exactly explains that bug:
> http://snook.ca/archives/javascript/safari2_display-none_getcomputedstyle/


I think the code has changed since August though. Notice that now it's in a
swap that sets display:block. So if it was invisible it should now be
visible and not return null. Unless visibility:hidden does it too, and in
that case the swap should add visibility:visible to the swap list. I can't
test on Safari so I've depended on the kindness of others in tracking down
these sort of bugs.

If the workaround is still needed I'd avoid two calls to getComputedStyle,
which may be expensive.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/