Inconsistency in getting size of an element under IE8 when Prototype is loaded
Prototype add a "scrollTo" function to elements, which make a test fail for jquery under IE8 standard mode
In jquery-1.4.2.js, around line 6200, there's a function to get/set width or height of an element.
It ends by this piece of code :
- return ("scrollTo" in elem && elem.document) ? // 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 ] :
// Get document width or height
(elem.nodeType === 9) ? // is it a document
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
Math.max(
elem.documentElement["client" + name],
elem.body["scroll" + name], elem.documentElement["scroll" + name],
elem.body["offset" + name], elem.documentElement["offset" + name]
) :
// Get or set width or height on the element
size === undefined ?
// Get width or height on the element
jQuery.css( elem, type ) :
// Set the width or height on the element (default to pixels if value is unitless)
this.css( type, typeof size === "string" ? size : size + "px" );
As you can see, at the beginning it checks an existing function "scrollTo" to determine if the element is a window.
Under IE8 standard, when you try to get size of an element which is not the window, the test always return true because of Prototype adding it (and elem.document returning true too, which is not under Firefox). And then, the size returned is the one of the window, not the element's.
Not sure i've been clear (without mentionning i'm not perfectly fluent in english, hum..)