Skip to content

Commit

Permalink
Migrate from document.defaultView => window. Fixes #10373
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Sep 28, 2011
1 parent 22fcc77 commit 89f12a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
21 changes: 9 additions & 12 deletions src/css.js
Expand Up @@ -13,8 +13,8 @@ var ralpha = /alpha\([^)]*\)/i,
cssHeight = [ "Top", "Bottom" ],
curCSS,

getComputedStyle,
currentStyle;
getComputedStyle = window.getComputedStyle,
computedStyle, currentStyle;

jQuery.fn.css = function( name, value ) {
// Setting 'undefined' is a no-op
Expand Down Expand Up @@ -262,18 +262,15 @@ jQuery(function() {
}
});

if ( document.defaultView && document.defaultView.getComputedStyle ) {
getComputedStyle = function( elem, name ) {
var ret, defaultView, computedStyle;
if ( getComputedStyle ) {
computedStyle = function( elem, name ) {
var ret,
computed = getComputedStyle( elem, null );

name = name.replace( rupper, "-$1" ).toLowerCase();

if ( !(defaultView = elem.ownerDocument.defaultView) ) {
return undefined;
}

if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
ret = computedStyle.getPropertyValue( name );
if ( computed ) {
ret = computed.getPropertyValue( name );
if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
ret = jQuery.style( elem, name );
}
Expand Down Expand Up @@ -317,7 +314,7 @@ if ( document.documentElement.currentStyle ) {
};
}

curCSS = getComputedStyle || currentStyle;
curCSS = computedStyle || currentStyle;

function getWH( elem, name, extra ) {

Expand Down
5 changes: 3 additions & 2 deletions src/support.js
Expand Up @@ -4,6 +4,7 @@ jQuery.support = (function() {

var div = document.createElement( "div" ),
documentElement = document.documentElement,
getComputedStyle = window.getComputedStyle,
all,
a,
select,
Expand Down Expand Up @@ -219,13 +220,13 @@ jQuery.support = (function() {
// info see bug #3333
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
if ( document.defaultView && document.defaultView.getComputedStyle ) {
if ( getComputedStyle ) {
marginDiv = document.createElement( "div" );
marginDiv.style.width = "0";
marginDiv.style.marginRight = "0";
div.appendChild( marginDiv );
support.reliableMarginRight =
( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
( parseInt( ( getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
}

// Remove the body element we added
Expand Down

0 comments on commit 89f12a4

Please sign in to comment.