diff --git a/CHANGELOG b/CHANGELOG index 4c903da..5054169 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix Element#positionedOffset and Element#getOffsetParent for static elements on IE. [Thomas Fuchs] + * Make sure event handlers and their wrappers are removed from the cache by Event.stopObserving. [sam, Severin Heiniger] * Add line numbers to failures when unit testing in Firefox. Closes #9231. [John Resig] diff --git a/src/dom.js b/src/dom.js index deeab3b..937b636 100644 --- a/src/dom.js +++ b/src/dom.js @@ -552,7 +552,7 @@ Element.Methods = { getOffsetParent: function(element) { if (element.offsetParent) return $(element.offsetParent); if (element == document.body) return $(element); - + while ((element = element.parentNode) && element != document.body) if (Element.getStyle(element, 'position') != 'static') return $(element); @@ -735,6 +735,20 @@ if (Prototype.Browser.Opera) { } else if (Prototype.Browser.IE) { + ['positionedOffset','getOffsetParent'].each(function(method){ + Element.Methods[method] = Element.Methods[method].wrap( + function(proceed, element){ + element = $(element); + if (element.getStyle('position') == 'static') return proceed(element); + var position = element.getStyle(position); + element.setStyle({position: 'relative'}); + var value = proceed(element); + element.setStyle({position: position}); + return value; + } + ); + }); + Element.Methods.getStyle = function(element, style) { element = $(element); style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); diff --git a/test/unit/dom.html b/test/unit/dom.html index 719695d..a800a18 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -225,7 +225,7 @@