Skip to main content

Bug Tracker

Side navigation

#467 closed bug (fixed)

Opened December 05, 2006 12:14PM UTC

Closed December 11, 2006 09:22AM UTC

Last modified June 19, 2007 07:11AM UTC

Safari 2.0: getComputedStyle returns null if parent has "display: none"

Reported by: klaus.hartl@stilbuer Owned by:
Priority: major Milestone: 1.1a
Component: core Version: 1.1a
Keywords: Cc:
Blocked by: Blocking:
Description

The method getPropertyValue is invoked on null in this case, causing an error obviously. This happens if css() is used for an element, of which some parent element has its display property declared to "none".

The following patch fixes the nullpointer at least and returns an empty string instead (the retrieval of the CSS property in question is not fixed):

jQuery.swap(elem, { display: 'block' }, function() {
    var computedStyle = document.defaultView.getComputedStyle(this, '');
    ret = computedStyle && computedStyle.getPropertyValue(prop) || '';
});

As is now:

jQuery.swap(elem, { display: 'block' }, function() {
    ret = document.defaultView.getComputedStyle(this,null).getPropertyValue(prop);
});

Additional Information:

http://snook.ca/archives/javascript/safari2_display-none_getcomputedstyle/

Attachments (0)
Change History (1)

Changed December 11, 2006 09:22AM UTC by joern comment:1

resolution: → fixed
status: newclosed

Fixed in SVN.