Skip to content

Commit

Permalink
Fix 'walks like a window, quacks like a window' test
Browse files Browse the repository at this point in the history
In some browsers (at least Opera and IE) the inclusion of the prototype
library can cause the tested window properties to become available in
other HTML elements.

An effect of this is that the change introduced in [6313] causes the
width to be reported incorrectly on these elements (the document width
is used instead of the actual element width).

This is solved by checking for parentNode, which is null or undefined
on window and document objects but not on HTML elements.

Fixes #6088
  • Loading branch information
Oblomov committed Sep 5, 2010
1 parent 97cbd76 commit 7ac80fa
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/dimensions.js
Expand Up @@ -31,7 +31,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
});
}

return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
return ("scrollTo" in elem && elem.document && !elem.parentNode) ? // does it walk and quack like a window?
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
elem.document.body[ "client" + name ] :
Expand Down

0 comments on commit 7ac80fa

Please sign in to comment.