Skip to content

Commit

Permalink
Fixed the case where getComputedStyled was assumed to exist if getBou…
Browse files Browse the repository at this point in the history
…ndingClientRect did (which isn't the case on the Playstation 3). Fixes #5467.
  • Loading branch information
jeresig committed Nov 7, 2009
1 parent 339708c commit 9a371e2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/offset.js
Expand Up @@ -35,13 +35,13 @@ if ( "getBoundingClientRect" in document.documentElement ) {
var offsetParent = elem.offsetParent, prevOffsetParent = elem,
doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
body = doc.body, defaultView = doc.defaultView,
prevComputedStyle = defaultView.getComputedStyle( elem, null ),
prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
top = elem.offsetTop, left = elem.offsetLeft;

while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; }

computedStyle = defaultView.getComputedStyle(elem, null);
computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
top -= elem.scrollTop;
left -= elem.scrollLeft;

Expand Down

2 comments on commit 9a371e2

@jdalton
Copy link
Member

@jdalton jdalton commented on 9a371e2 Nov 7, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or IE for that matter, which supports getBoundingClientRect, but not document.defaultView

@jeresig
Copy link
Member Author

@jeresig jeresig commented on 9a371e2 Nov 9, 2009

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mis-typed in the commit message, it's "Fixed the case where getComputedStyled was assumed to exist if getBoundingClientRect doesn't" (since, naturally, the code already worked in IE).

Please sign in to comment.