public
Description: Prototype JavaScript framework
Homepage: http://prototypejs.org/
Clone URL: git://github.com/sstephenson/prototype.git
Remove the redefinition of Element#getOffsetParent in IE.
Sun Jun 29 12:48:51 -0700 2008
commit  6f27d553226bc27740ff5e64f0f281279d7e0db7
tree    8f6f4a91b09a67d9fc3a3d8046f0e5049cb58c1f
parent  e3313cb75d24cedbbc85188e7c5c26ca8601397b
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+* Remove the redefinition of Element#getOffsetParent in IE. [staaky, jddalton]
0
+
0
 * Make Element#getDimensions always use offset(Height|Width) rather than client(Height|Width). [staaky, jddalton]
0
 
0
 * Make Function#argumentNames use Function.prototype.toString. [Garrett Smith, jddalton, kangax]
...
594
595
596
 
 
 
 
597
598
599
 
 
 
 
 
600
601
602
...
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
...
870
871
872
873
 
874
875
876
...
594
595
596
597
598
599
600
601
 
 
602
603
604
605
606
607
608
609
...
842
843
844
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
845
846
847
...
860
861
862
 
863
864
865
866
0
@@ -594,9 +594,16 @@ Element.Methods = {
0
   
0
   getOffsetParent: function(element) {
0
     element = $(element);
0
+
0
+ // IE throws an error if the element is not in the document.
0
+ if (element.sourceIndex < 1) return $(document.body);
0
+
0
     var op = element.offsetParent, docElement = document.documentElement;
0
- if (op && op != docElement) return $(op);
0
-
0
+ if (op && op !== docElement &&
0
+ Element.getStyle(op, 'position') !== 'static') {
0
+ return $(op);
0
+ }
0
+
0
     while ((element = element.parentNode) && element !== docElement &&
0
      element !== document) {
0
       if (Element.getStyle(element, 'position') !== 'static')
0
@@ -835,23 +842,6 @@ if (Prototype.Browser.Opera) {
0
 else if (Prototype.Browser.IE) {
0
   // IE doesn't report offsets correctly for static elements, so we change them
0
   // to "relative" to get the values, then change them back.
0
- Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
0
- function(proceed, element) {
0
- element = $(element);
0
- // IE throws an error if element is not in document
0
- try { element.offsetParent }
0
- catch(e) { return $(document.body) }
0
-
0
- var position = Element.getStyle(element, 'position');
0
- if (position !== 'static') return proceed(element);
0
- Element.setStyle(element, { position: 'relative' });
0
-
0
- var value = proceed(element);
0
- Element.setStyle(element, { position: position });
0
- return value;
0
- }
0
- );
0
-
0
   $w('positionedOffset viewportOffset').each(function(method) {
0
     Element.Methods[method] = Element.Methods[method].wrap(
0
       function(proceed, element) {
0
@@ -870,7 +860,7 @@ else if (Prototype.Browser.IE) {
0
         
0
         Element.setStyle(element, style);
0
         var value = proceed(element);
0
- Element.setStyle(element, { position: position });
0
+ element.style.position = position;
0
         return value;
0
       }
0
     );

Comments

    No one has commented yet.