Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 12 years ago

#467 closed bug (fixed)

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

Reported by: klaus.hartl@… 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/

Change History (1)

comment:1 Changed 13 years ago by joern

Resolution: fixed
Status: newclosed

Fixed in SVN.

Note: See TracTickets for help on using tickets.