Skip to content

Commit 9a76522

Browse files
committed
jquery core: SHOULD fix jquery#2802. Caching document.defaultView, instead of defaultView.getComputedStyle as it fails on Safari 2.
1 parent 54867a9 commit 9a76522

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/core.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,10 @@ jQuery.extend = jQuery.fn.extend = function() {
596596
};
597597

598598
var expando = "jQuery" + now(), uuid = 0, windowData = {},
599-
600-
// exclude the following css properties to add px
599+
// exclude the following css properties to add px
601600
exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
602-
// cache getComputedStyle
603-
getComputedStyle = document.defaultView && document.defaultView.getComputedStyle;
601+
// cache defaultView
602+
defaultView = document.defaultView || {};
604603

605604
jQuery.extend({
606605
noConflict: function( deep ) {
@@ -830,8 +829,8 @@ jQuery.extend({
830829
if ( !jQuery.browser.safari )
831830
return false;
832831

833-
// getComputedStyle is cached
834-
var ret = getComputedStyle( elem, null );
832+
// defaultView is cached
833+
var ret = defaultView.getComputedStyle( elem, null );
835834
return !ret || ret.getPropertyValue("color") == "";
836835
}
837836

@@ -857,15 +856,15 @@ jQuery.extend({
857856
if ( !force && style && style[ name ] )
858857
ret = style[ name ];
859858

860-
else if ( getComputedStyle ) {
859+
else if ( defaultView.getComputedStyle ) {
861860

862861
// Only "float" is needed here
863862
if ( name.match( /float/i ) )
864863
name = "float";
865864

866865
name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
867866

868-
var computedStyle = getComputedStyle( elem, null );
867+
var computedStyle = defaultView.getComputedStyle( elem, null );
869868

870869
if ( computedStyle && !color( elem ) )
871870
ret = computedStyle.getPropertyValue( name );

0 commit comments

Comments
 (0)