public
Description: Prototype JavaScript framework
Homepage: http://prototypejs.org/
Clone URL: git://github.com/sstephenson/prototype.git
The remainder of JDD's changes. Will update CHANGELOG soon.
Wed May 28 09:26:25 -0700 2008
commit  99cbf8ac20862072c0a66a06405194962aa57dfe
tree    a6cd6a27e40497086e7e62a701ab9c1ae72433e2
parent  f77caefe6611d309704425f3c7396feb131400ad
...
83
84
85
 
86
87
88
...
110
111
112
113
 
114
115
116
...
197
198
199
200
 
201
202
203
...
83
84
85
86
87
88
89
...
111
112
113
 
114
115
116
117
...
198
199
200
 
201
202
203
204
0
@@ -83,6 +83,7 @@ Ajax.Base = Class.create({
0
 
0
 Ajax.Request = Class.create(Ajax.Base, {
0
   _complete: false,
0
+  _allowStatusZero: false,
0
   
0
   initialize: function($super, url, options) {
0
     $super(options);
0
@@ -110,7 +111,7 @@ Ajax.Request = Class.create(Ajax.Base, {
0
       this.url = url;
0
       this.method = this.options.method;
0
       var params = Object.clone(this.options.parameters);
0
-      this.allowStatusZero = isFileProtocol(this.url) ||
0
+      this._allowStatusZero = isFileProtocol(this.url) ||
0
         (isRelative(url) && isFileProtocol(window.location.protocol));      
0
 
0
       if (!['get', 'post'].include(this.method)) {
0
@@ -197,7 +198,7 @@ Ajax.Request = Class.create(Ajax.Base, {
0
   
0
   success: function() {
0
     var status = this.getStatus();
0
-    return (!status && this.allowStatusZero) || (status >= 200 && status < 300);
0
+    return (!status && this._allowStatusZero) || (status >= 200 && status < 300);
0
   },
0
     
0
   getStatus: function() {
...
44
45
46
47
 
48
49
50
...
137
138
139
140
 
141
142
143
...
44
45
46
 
47
48
49
50
...
137
138
139
 
140
141
142
143
0
@@ -44,7 +44,7 @@ Class.Methods = {
0
       var property = properties[i], value = source[property];
0
       if (ancestor && Object.isFunction(value) &&
0
           value.argumentNames().first() == "$super") {
0
-        var method = value, value =(function(m) {
0
+        var method = value, value = (function(m) {
0
           return function() { return ancestor[m].apply(this, arguments) };
0
         })(property).wrap(method);
0
 
0
@@ -137,7 +137,7 @@ Object.extend(Object, {
0
   },
0
   
0
   isHash: function(object) {
0
-    return object instanceof Hash;
0
+    return object && object instanceof Hash;
0
   },
0
   
0
   isFunction: function(object) {
...
287
288
289
290
291
292
293
...
296
297
298
299
300
301
302
...
447
448
449
450
451
452
 
 
453
454
 
455
456
457
458
459
460
461
462
463
464
465
466
467
468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
469
470
471
...
574
575
576
577
578
579
 
580
581
582
 
583
584
585
586
587
588
 
 
 
 
 
 
589
590
591
 
592
593
594
595
 
 
 
 
 
 
 
 
596
597
598
 
 
599
600
601
602
 
 
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
 
 
 
 
620
621
 
622
623
624
625
626
627
 
 
628
629
 
 
630
631
 
632
633
634
 
 
635
636
637
 
 
 
 
638
639
640
641
642
643
644
645
 
 
 
646
647
 
 
 
648
649
650
651
652
653
 
 
 
 
 
 
 
 
 
 
654
655
656
657
658
 
 
 
 
 
 
 
 
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
 
 
 
 
 
684
685
686
687
688
689
 
 
690
691
692
693
694
695
696
697
698
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
699
700
701
...
782
783
784
785
786
 
 
 
787
788
789
 
790
791
792
...
797
798
799
800
801
802
 
 
803
 
804
805
806
807
808
809
 
 
 
 
 
 
810
811
 
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
...
1048
1049
1050
1051
 
 
 
1052
1053
 
 
1054
1055
1056
...
1111
1112
1113
 
 
1114
1115
1116
 
1117
1118
1119
...
1138
1139
1140
 
 
 
1141
1142
1143
...
1168
1169
1170
 
 
 
1171
1172
 
1173
1174
1175
...
287
288
289
 
290
291
292
...
295
296
297
 
298
299
300
...
445
446
447
 
 
 
448
449
450
 
451
452
 
 
 
 
 
 
 
 
 
 
 
 
 
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
...
576
577
578
 
579
 
580
581
582
 
583
584
585
 
 
 
 
586
587
588
589
590
591
592
593
 
594
595
 
 
596
597
598
599
600
601
602
603
604
605
 
 
606
607
608
609
 
 
610
611
612
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
613
614
615
616
617
 
618
619
620
621
622
 
 
623
624
625
 
626
627
628
629
630
631
632
 
633
634
635
 
 
636
637
638
639
640
 
 
 
 
 
 
 
641
642
643
644
 
645
646
647
648
 
 
 
 
 
649
650
651
652
653
654
655
656
657
658
659
660
 
 
 
661
662
663
664
665
666
667
668
669
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
670
671
672
673
674
675
 
 
 
 
 
676
677
678
 
 
 
 
 
 
 
 
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
...
871
872
873
 
 
874
875
876
877
878
879
880
881
882
883
...
888
889
890
 
 
 
891
892
893
894
895
896
 
 
 
 
897
898
899
900
901
902
903
 
904
905
906
907
908
909
 
 
 
 
 
 
 
910
911
912
...
1134
1135
1136
 
1137
1138
1139
1140
 
1141
1142
1143
1144
1145
...
1200
1201
1202
1203
1204
1205
1206
 
1207
1208
1209
1210
...
1229
1230
1231
1232
1233
1234
1235
1236
1237
...
1262
1263
1264
1265
1266
1267
1268
 
1269
1270
1271
1272
0
@@ -287,7 +287,6 @@ Element.Methods = {
0
     if (t.names[name]) name = t.names[name];
0
     
0
     if (Prototype.Browser.IE) {
0
-      var t = Element._attributeTranslations.read;
0
       // If we're reading from a form, avoid a conflict between an attribute
0
       // and a child name.
0
       if (element.tagName.toUpperCase() == 'FORM' &&
0
@@ -296,7 +295,6 @@ Element.Methods = {
0
         element = $(element.cloneNode(false));
0
       }
0
       if (t.values[name]) return t.values[name](element, name);
0
-      if (t.names[name]) name = t.names[name];
0
       if (name.include(':')) {
0
         return (!element.attributes || !element.attributes[name]) ? null : 
0
          element.attributes[name].value;
0
@@ -447,25 +445,29 @@ Element.Methods = {
0
   
0
   getDimensions: function(element) {
0
     element = $(element);
0
-    var display = element.getStyle('display');
0
-    if (display != 'none' && display != null) // Safari bug
0
-      return {width: element.offsetWidth, height: element.offsetHeight};
0
+    var display = element.getStyle('display'),
0
+     dimensions = { width: element.clientWidth, height: element.clientHeight };
0
     
0
-    // All *Width and *Height properties give 0 on elements with display none,
0
+    // All *Width and *Height properties give 0 on elements with display: none,
0
     // so enable the element temporarily
0
-    var els = element.style;
0
-    var originalVisibility = els.visibility;
0
-    var originalPosition = els.position;
0
-    var originalDisplay = els.display;
0
-    els.visibility = 'hidden';
0
-    els.position = 'absolute';
0
-    els.display = 'block';
0
-    var originalWidth = element.clientWidth;
0
-    var originalHeight = element.clientHeight;
0
-    els.display = originalDisplay;
0
-    els.position = originalPosition;
0
-    els.visibility = originalVisibility;
0
-    return {width: originalWidth, height: originalHeight};    
0
+    if (display === "none" || display === null) {
0
+      var els = element.style,
0
+       originalVisibility = els.visibility,
0
+       originalPosition   = els.position,
0
+       originalDisplay    = els.display;
0
+
0
+      els.visibility = 'hidden';
0
+      els.position = 'absolute';
0
+      els.display = 'block';
0
+      
0
+      dimensions = { width: element.clientWidth, height: element.clientHeight };
0
+
0
+      els.display = originalDisplay;
0
+      els.position = originalPosition;
0
+      els.visibility = originalVisibility;
0
+    }
0
+    
0
+    return dimensions;
0
   },
0
   
0
   makePositioned: function(element) {
0
@@ -574,128 +576,215 @@ Element.Methods = {
0
   relativize: function(element) {
0
     element = $(element);
0
     if (element.getStyle('position') == 'relative') return element;
0
-    // Position.prepare(); // To be done manually by Scripty when it needs it.
0
 
0
-    if(!element._originalTop){
0
+    if (!element._originalTop){
0
       /* fix bizarre IE position issue with empty elements */
0
       var isBuggy = element.outerHTML && element.innerHTML.blank();
0
-      if(isBuggy) element.innerHTML = '\x00';
0
+      if (isBuggy) element.innerHTML = '\x00';
0
       
0
       Object.extend(element, {
0
-        _originalTop:    element.offsetTop,
0
-        _originalLeft:   element.offsetLeft,
0
-        _originalWidth:  element.clientWidth  + 'px',
0
-        _originalHeight: element.clientHeight + 'px'
0
+        _originalTop:        element.offsetTop,
0
+        _originalLeft:       element.offsetLeft,
0
+        _originalWidth:      Element.getStyle(element, 'width'),
0
+        _originalHeight:     Element.getStyle(element, 'height'),
0
+        _originalMarginTop:  Element.getStyle(element, 'marginTop'),
0
+        _originalMarginLeft: Element.getStyle(element, 'marginLeft')
0
       });
0
       
0
-      if(isBuggy) element.innerHTML = '';
0
+      if (isBuggy) element.innerHTML = '';
0
     }
0
-
0
-    element.style.position = 'relative';
0
     
0
+    Element.setStyle(element, {
0
+      position:   'relative',
0
+      width:      element._originalWidth,
0
+      height:     element._originalHeight,
0
+      marginTop:  element._originalMarginTop,
0
+      marginLeft: element._originalMarginLeft
0
+    });
0
+
0
     var offsets = element.positionedOffset(),
0
-    top  = element._originalTop  - offsets.top,
0
-    left = element._originalLeft - offsets.left;
0
+     top  = element._originalTop  - offsets.top,
0
+     left = element._originalLeft - offsets.left;
0
     
0
     var isAuto = /^(auto|)$/;  
0
-    if(!isAuto.test(element.style.top))  top += element._originalTop;
0
-    if(!isAuto.test(element.style.left)) left+= element._originalLeft;
0
+    if (!isAuto.test(element.style.top))  top  += element._originalTop;
0
+    if (!isAuto.test(element.style.left)) left += element._originalLeft;
0
     
0
-    element.style.top    = top  + 'px';
0
-    element.style.left   = left + 'px';
0
-    element.style.height = element._originalHeight;
0
-    element.style.width  = element._originalWidth;
0
-    return element;
0
-  },
0
-
0
-  cumulativeScrollOffset: function(element) {
0
-    element = $(element);
0
-    var valueT = 0, valueL = 0,
0
-    endElement = (Prototype.Browser.Opera && opera.version() < 9.5) ? document.documentElement : document;
0
-    
0
-    do {
0
-      valueT += element.scrollTop  || 0;
0
-      valueL += element.scrollLeft || 0;
0
-    } while ((element = element.parentNode) && element != endElement);
0
+    Element.setStyle(element, {
0
+      top:  top + 'px',
0
+      left: left + 'px'
0
+    });
0
     
0
-    return Element._returnOffset(valueL, valueT);
0
+    return element;
0
   },
0
   
0
   getOffsetParent: function(element) {
0
     element = $(element);
0
-    var op = element.offsetParent;
0
-    if (op && op != document.documentElement) return $(op);
0
+    var op = element.offsetParent, docElement = document.documentElement;
0
+    if (op && op != docElement) return $(op);
0
 
0
-    while ((element = element.parentNode) && element.tagName.toUpperCase() != 'HTML')
0
+    while ((element = element.parentNode) && element !== docElement &&
0
+     element !== document) {
0
       if (Element.getStyle(element, 'position') != 'static')
0
         return $(element);
0
+    }
0
 
0
     return $(document.body);
0
-  },
0
+  }
0
+};
0
 
0
-  viewportOffset: function(forElement) {
0
-    forElement = $(forElement);
0
+Object.extend(Element.Methods, (function() {
0
+  function getNumericStyle(element, style) {
0
+    return parseFloat(Element.getStyle(element, style)) || 0;
0
+  }
0
 
0
-    var element = forElement, valueT = 0, valueL = 0,
0
-    endElement = (Prototype.Browser.Opera && opera.version() < 9.5) ? document.documentElement : document;
0
-    
0
-    do {
0
-      valueT += element.offsetTop  || 0;
0
-      valueL += element.offsetLeft || 0;
0
-    } while ((element = element.getOffsetParent()) != document.body);
0
+  function getStyleDiff(element, source, style) {
0
+    return getNumericStyle(source, style) - getNumericStyle(element, style);
0
+  }
0
 
0
-    element = forElement;
0
+  function cloneDimension(element, source, dimension) {
0
+    var d = Element.getDimensions(source), style = { };
0
+    style[dimension] = d[dimension] + 'px';
0
     
0
-    if (Element.getStyle(element, 'position') != 'fixed') {
0
-      while ((element = element.parentNode) && element != endElement) {
0
-        if (Element.getStyle(element, 'position') == 'fixed') break;
0
-        valueT -= element.scrollTop  || 0;
0
-        valueL -= element.scrollLeft || 0;
0
+    var styles = $w('margin padding');
0
+    var sides = (dimension === 'height') ? $w('top bottom') :
0
+     $w('left right');
0
+     
0
+    var property;
0
+    for (var i = 0; i < 2; i++) {
0
+      for (var j = 0; j < 2; j++) {
0
+        property = styles[i] + sides[j].capitalize();
0
+        style[property] = (getNumericStyle(element, property) + 
0
+         getStyleDiff(element, source, property)) + 'px';
0
       }
0
     }
0
-    
0
-    return Element._returnOffset(valueL, valueT);
0
-  },
0
+    Element.setStyle(element, style);
0
+  }
0
+  
0
+  return {
0
+    cumulativeScrollOffset: function(element) {
0
+      element = $(element);
0
+      var valueT = 0, valueL = 0, endElement = document;
0
+      var B = Prototype.Browser;
0
 
0
-  clonePosition: function(element, source) {
0
-    element = $(element);
0
-    var options = Object.extend({
0
-      setLeft:    true,
0
-      setTop:     true,
0
-      setWidth:   true,
0
-      setHeight:  true,
0
-      offsetTop:  0,
0
-      offsetLeft: 0
0
-    }, arguments[2] || { });
0
-
0
-    // find page position of source
0
-    source = $(source);
0
-    var p = source.viewportOffset();
0
-
0
-    // find coordinate system to use
0
-    var delta = [0, 0];
0
-    var parent = null;
0
-    // delta [0,0] will do fine with position: fixed elements, 
0
-    // position:absolute needs offsetParent deltas
0
-    if (Element.getStyle(element, 'position') == 'absolute') {
0
-      parent = element.getOffsetParent();
0
-      delta = parent.viewportOffset();
0
-    }
0
+      // Safari and Opera need to stop at document.body or else they'll
0
+      // report inaccurate values.
0
+      if (B.WebKit || B.Opera && opera.version() < 9.5) {
0
+        if ([document, document.body, document.documentElement].include(element))
0
+          return Element._returnOffset(0, 0);
0
 
0
-    // correct by body offsets (fixes Safari)
0
-    if (parent == document.body) {
0
-      delta[0] -= document.body.offsetLeft;
0
-      delta[1] -= document.body.offsetTop; 
0
-    }
0
+        endElement = document.body;
0
+      }
0
 
0
-    // set position
0
-    if (options.setLeft)   element.style.left  = (p[0] - delta[0] + options.offsetLeft) + 'px';
0
-    if (options.setTop)    element.style.top   = (p[1] - delta[1] + options.offsetTop) + 'px';
0
-    if (options.setWidth)  element.style.width = source.offsetWidth + 'px';
0
-    if (options.setHeight) element.style.height = source.offsetHeight + 'px';
0
-    return element;
0
-  }
0
-};
0
+      if (Element.getStyle(element, 'position') !== 'fixed') {
0
+        while ((element = element.parentNode) && element !== endElement) {
0
+          if (Element.getStyle(element, 'position') === 'fixed') break;
0
+          valueT += element.scrollTop  || 0;
0
+          valueL += element.scrollLeft || 0;
0
+        }
0
+      }
0
+      return Element._returnOffset(valueL, valueT);
0
+    },
0
+
0
+    cumulativeOffset: function(element) {
0
+      element = $(element);
0
+      var valueT = 0, valueL = 0;
0
+      do {
0
+        valueT += (element.offsetTop  || 0);
0
+        valueL += (element.offsetLeft || 0);
0
+      } while ((element = Element.getOffsetParent(element)) != document.body);
0
+
0
+      return Element._returnOffset(valueL, valueT);
0
+    },
0
+
0
+    positionedOffset: function(element) {
0
+      element = $(element);
0
+      var valueT = 0, valueL = 0;
0
+      do {
0
+        valueT += (element.offsetTop  || 0);
0
+        valueL += (element.offsetLeft || 0);
0
+        element = Element.getOffsetParent(element);
0
+      } while (element != document.body && 
0
+       Element.getStyle(element, 'position') == 'static');
0
+
0
+      return Element._returnOffset(valueL, valueT);
0
+    },
0
+
0
+    viewportOffset: function(forElement) {
0
+      forElement = $(forElement);
0
+      var op, element = forElement, valueT = 0, valueL = 0;
0
+
0
+      do {
0
+        valueT += (element.offsetTop  || 0);
0
+        valueL += (element.offsetLeft || 0);
0
+
0
+        // Safari fix
0
+        op = Element.getOffsetParent(element);
0
+        if (op == document.body && Element.getStyle(element,
0
+         'position') == 'absolute') break;
0
+      } while ((element = op) != document.body);
0
+
0
+      var scrollOffset = Element.cumulativeScrollOffset(forElement);
0
+      valueT -= scrollOffset.top;
0
+      valueL -= scrollOffset.left;
0
+
0
+      return Element._returnOffset(valueL, valueT);
0
+    },
0
+
0
+    clonePosition: function(element, source) {
0
+      element = $(element);
0
+      source = $(source);
0
+      var options = Object.extend({
0
+        setLeft:    true,
0
+        setTop:     true,
0
+        setWidth:   true,
0
+        setHeight:  true,
0
+        offsetTop:  0,
0
+        offsetLeft: 0
0
+      }, arguments[2] || { });
0
+
0
+      // find coordinate system to use
0
+      // delta [0,0] will do fine with position: fixed elements;
0
+      // position: absolute needs offsetParent deltas
0
+      var parent, delta = [0, 0];
0
+      if (Element.getStyle(element, 'position') == 'absolute') {
0
+        parent = Element.getOffsetParent(element);
0
+        delta  = Element.viewportOffset(parent);
0
+      }
0
+
0
+      // correct by body offsets (fixes Safari)
0
+      if (parent == document.body) {
0
+        delta[0] -= document.body.offsetLeft;
0
+        delta[1] -= document.body.offsetTop;
0
+      }
0
+
0
+      // set dimensions
0
+      if (options.setWidth)  cloneDimension(element, source, 'width');
0
+      if (options.setHeight) cloneDimension(element, source, 'height');
0
+
0
+      // find page position of source
0
+      var p = Element.viewportOffset(source),
0
+      borderOffset = ['borderLeftWidth', 'borderTopWidth'].map(
0
+       function(style) { return getStyleDiff(element, source, style); });
0
+
0
+      if (options.setLeft) {
0
+        var left = p[0] - delta[0] + borderOffset[0];
0
+        if (options.offsetLeft) 
0
+          left += options.offsetLeft + getNumericStyle(element, 'paddingLeft');
0
+          
0
+        element.style.left = left + 'px';
0
+      }
0
+      if (options.setTop) {
0
+        var top = p[1] - delta[1] + borderOffset[1];
0
+        if (options.offsetTop)
0
+          top += options.offsetTop + getNumericStyle(element, 'paddingTop');
0
+          
0
+        element.style.top = top + 'px';
0
+      }
0
+      return element;
0
+    }
0
+  };
0
+})());
0
 
0
 Element.Methods.identify.counter = 1;
0
 
0
@@ -782,11 +871,13 @@ else if (Prototype.Browser.IE) {
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
+      try { element.offsetParent; }
0
+      catch(e) { return $(document.body); }
0
+      
0
       var position = element.getStyle('position');
0
       if (position !== 'static') return proceed(element);
0
       element.setStyle({ position: 'relative' });
0
+
0
       var value = proceed(element);
0
       element.setStyle({ position: position });
0
       return value;
0
@@ -797,30 +888,25 @@ else if (Prototype.Browser.IE) {
0
     Element.Methods[method] = Element.Methods[method].wrap(
0
       function(proceed, element) {
0
         element = $(element);
0
-        try { element.offsetParent }
0
-        catch(e) { return Element._returnOffset(0,0) }
0
-        var position = element.getStyle('position');
0
+        
0
+        var position = Element.getStyle(element, 'position');
0
         if (position !== 'static') return proceed(element);
0
+        
0
         // Trigger hasLayout on the offset parent so that IE6 reports
0
         // accurate offsetTop and offsetLeft values for position: fixed.
0
-        var offsetParent = element.getOffsetParent();
0
-        if (offsetParent && offsetParent.getStyle('position') === 'fixed')
0
-          offsetParent.setStyle({ zoom: 1 });
0
-        element.setStyle({ position: 'relative' });
0
+        var offsetParent = Element.getOffsetParent(element),
0
+         style = { position: 'relative' }; 
0
+        if (Element.getOffsetParent(offsetParent, 'position') === 'fixed')
0
+          style.zoom = '1';
0
+        
0
+        Element.setStyle(element, style);
0
         var value = proceed(element);
0
-        element.setStyle({ position: position });
0
+        Element.setStyle(element, { position: position});
0
         return value;
0
       }
0
     );
0
   });
0
   
0
-  Element.Methods.cumulativeOffset = Element.Methods.cumulativeOffset.wrap(
0
-    function(proceed, element) {
0
-      try { $(element).offsetParent }
0
-      catch(e) { return Element._returnOffset(0,0) }
0
-      return proceed(element);
0
-    }
0
-  );
0
     
0
   Element.Methods.getStyle = function(element, style) {
0
     element = $(element);
0
@@ -1048,9 +1134,12 @@ if ('outerHTML' in document.createElement('div')) {
0
     content = Object.toHTML(content);
0
     var parent = element.parentNode, tagName = parent.tagName.toUpperCase();
0
     
0
-    if (Element._insertionTranslations.tags[tagName]) {
0
+    // Avoid outerHTML in IE because it incorrectly removes the replaced
0
+    // elements' child nodes.
0
+    if (Element._insertionTranslations.tags[tagName] || Prototype.Browser.IE) {
0
       var nextSibling = element.next();
0
-      var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts());
0
+      var fragments = Element._getContentFromAnonymousElement(tagName,
0
+       content.stripScripts());
0
       parent.removeChild(element);
0
       if (nextSibling)
0
         fragments.each(function(node) { parent.insertBefore(node, nextSibling) });
0
@@ -1111,9 +1200,11 @@ Element._insertionTranslations = {
0
 }).call(Element._insertionTranslations);
0
 
0
 Element.Methods.Simulated = {
0
+  // No use of $ in this function in order to keep things fast.
0
+  // Used by the Selector class.  
0
   hasAttribute: function(element, attribute) {
0
     attribute = Element._attributeTranslations.has[attribute] || attribute;
0
-    var node = $(element).getAttributeNode(attribute);
0
+    var node = element.getAttributeNode(attribute);
0
     return !!(node && node.specified);
0
   }
0
 };
0
@@ -1138,6 +1229,9 @@ Element.extend = (function() {
0
   var extend = Object.extend(function(element) {
0
     if (!element || element._extendedByPrototype || 
0
         element.nodeType != 1 || element == window) return element;
0
+        
0
+    // Filter out XML nodes in IE.
0
+    if (!(element.ownerDocument || element).body) return element;
0
 
0
     var methods = Object.clone(Methods),
0
       tagName = element.tagName.toUpperCase(), property, value;
0
@@ -1168,8 +1262,11 @@ Element.extend = (function() {
0
   return extend;
0
 })();
0
 
0
+
0
+// No use of $ in this function in order to keep things fast.
0
+// Used by the Selector class.
0
 Element.hasAttribute = function(element, attribute) {
0
-  if ((element = $(element)).hasAttribute) return element.hasAttribute(attribute);
0
+  if (element.hasAttribute) return element.hasAttribute(attribute);
0
   return Element.Methods.Simulated.hasAttribute(element, attribute);
0
 };
0
 
...
410
411
412
413
 
 
414
415
416
...
410
411
412
 
413
414
415
416
417
0
@@ -410,7 +410,8 @@ Object.extend(document, {
0
     }
0
   }
0
   
0
-  // WebKit builds lower than 525.13 don't support DOMContentLoaded
0
+  
0
+  // Safari <3.1 doesn't support DOMContentLoaded
0
   if (Prototype.Browser.WebKit && (navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1] < 525)) {
0
     timer = setInterval(function() {
0
       if (/loaded|complete/.test(document.readyState))
...
5
6
7
8
 
9
10
 
 
 
11
12
13
14
15
16
17
18
19
20
21
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
24
 
 
 
 
 
 
 
 
 
 
25
26
27
...
5
6
7
 
8
9
 
10
11
12
13
14
 
 
 
 
 
 
 
 
 
 
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
45
46
47
48
49
50
51
52
53
54
55
56
57
0
@@ -5,23 +5,53 @@ var Form = {
0
   },
0
   
0
   serializeElements: function(elements, options) {
0
-    if (typeof options != 'object') options = { hash: !!options };
0
+    if (typeof options !== 'object') options = { hash: !!options };
0
     else if (Object.isUndefined(options.hash)) options.hash = true;
0
-    var key, value, submitted = false, submit = options.submit;
0
+    
0
+    var key, value, type, isImageType, isSubmitButton, submitSerialized;
0
+    var submit = options.submit;
0
     
0
     var data = elements.inject({ }, function(result, element) {
0
-      if (!element.disabled && element.name) {
0
-        key = element.name; value = $(element).getValue();
0
-        if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
0
-            submit !== false && (!submit || key == submit) && (submitted = true)))) { 
0
-          if (key in result) {
0
-            // a key is already present; construct an array of values
0
-            if (!Object.isArray(result[key])) result[key] = [result[key]];
0
-            result[key].push(value);
0
-          }
0
-          else result[key] = value;
0
+      element = $(element);
0
+      key     = element.name;
0
+      value   = element.getValue();
0
+      type    = element.type;
0
+      
0
+      isImageType    = type === 'image';
0
+      isSubmitButton = (type === 'submit' || isImageType);
0
+      
0
+      // Null values don't get serialized
0
+      if (value === null) return result;
0
+      // Disabled elements don't get serialized
0
+      if (element.disabled) return result;
0
+      // <input type="file|reset" /> doesn't get serialized
0
+      if (type === 'file' || type === 'reset') return result;
0
+      // Non-active submit buttons don't get serialized
0
+      if (isSubmitButton &&
0
+       (submit === false || submitSerialized ||
0
+       (submit && !(key === submit || element === submit))))
0
+        return result;
0
+        
0
+      if (isSubmitButton) {
0
+        submitSerialized = true;
0
+        if (isImageType) {
0
+          var prefix = key ? key + '.' : '',
0
+           x = options.x || 0, y = options.y || 0;
0
+           
0
+          result[prefix + 'x'] = x;
0
+          result[prefix + 'y'] = y;
0
+          return result;
0
         }
0
-      }
0
+      } 
0
+      
0
+      else if (!key) return result;
0
+      
0
+      if (key in result) {
0
+        // a key is already present; construct an array of values
0
+        if (!Object.isArray(result[key])) result[key] = [result[key]];
0
+        result[key].push(value);
0
+      } else result[key] = value;
0
+      
0
       return result;
0
     });
0
     
...
460
461
462
463
464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
465
466
467
...
460
461
462
 
 
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
0
@@ -460,8 +460,20 @@ Object.extend(Selector, {
0
     
0
     id: function(nodes, root, id, combinator) {
0
       var targetNode = $(id), h = Selector.handlers;
0
-      if (!targetNode) return [];
0
-      if (!nodes && root == document) return [targetNode];
0
+      if (!targetNode) {
0
+        // IE doesn't find elements by ID if they're not attached to the
0
+        // document.
0
+        if (Prototype.Browser.IE && (root.sourceIndex < 1 || root === document)) {
0
+          var nodes = root.getElementsByTagName('*');
0
+          for (var i = 0, node; node = nodes[i]; i++) {
0
+            if (node[id] = id) {
0
+              targetNode = node; break;
0
+            }
0
+          } if (!targetNode) return [];
0
+        } else return [];
0
+      }
0
+
0
+      if (!nodes && root === document) return [targetNode];
0
       if (nodes) {
0
         if (combinator) {
0
           if (combinator == 'child') {

Comments

tobie Wed Sep 03 22:29:08 -0700 2008

er…. This absolutely needs to be broken down into separate, tested commits.

kneath Thu Sep 04 00:32:10 -0700 2008

Woah, yeah… I’d love to see these in separate commits in the future :) Right now it’s just a huge mob of craziness.

savetheclocktower Thu Sep 04 09:29:58 -0700 2008

Yeah, sorry; these über-commits were kludges so I could keep up with future fixes from JDD. That was a dumb idea on my part.