Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Maintain backward compatibility and fix misordered Element.undoAbsolu…

…tize & Element.undoRelativize calls.
  • Loading branch information...
commit 0ae2caf56d44b6e2b7d1032c3d5d875f57551e9e 1 parent c9a2d1a
Sébastien Grosjean authored December 17, 2010
11  src/prototype/dom/layout.js
@@ -1041,12 +1041,17 @@
1041 1041
    *  Turns `element` into an absolutely-positioned element _without_
1042 1042
    *  changing its position in the page layout.
1043 1043
    *
  1044
+   *  It also reverts back a previous [[Element.relativize]] call
  1045
+   *  on this `element`.
  1046
+   *
1044 1047
    *  To revert back to `element`'s original position,
1045 1048
    *  use [[Element.undoAbsolutize]].
1046 1049
   **/
1047 1050
   function absolutize(element) {
1048 1051
     element = $(element);
1049 1052
     
  1053
+    element.undoRelativize();
  1054
+    
1050 1055
     if (Element.getStyle(element, 'position') === 'absolute') {
1051 1056
       return element;
1052 1057
     }
@@ -1106,11 +1111,17 @@
1106 1111
    *  Turns `element` into a relatively-positioned element without changing
1107 1112
    *  its position in the page layout.
1108 1113
    *
  1114
+   *  It also reverts back a previous [[Element.absolutize]] call
  1115
+   *  on this `element`.
  1116
+   *
1109 1117
    *  To revert back to `element`'s original position,
1110 1118
    *  use [[Element.undoRelativize]].
1111 1119
   **/
1112 1120
   function relativize(element) {
1113 1121
     element = $(element);
  1122
+    
  1123
+    element.undoAbsolutize();
  1124
+    
1114 1125
     if (Element.getStyle(element, 'position') === 'relative') {
1115 1126
       return element;
1116 1127
     }
18  test/unit/dom_test.js
@@ -1469,6 +1469,24 @@ new Test.Unit.Runner({
1469 1469
     var element = $('position-untouched');
1470 1470
     this.assertEqual(element, element.undoRelativize());
1471 1471
   },
  1472
+  
  1473
+  testAbsolutizeThenRelativize: function() {
  1474
+    var element = $('position-static');
  1475
+    element.absolutize();
  1476
+    element.relativize();
  1477
+    element.undoAbsolutize();
  1478
+    element.undoRelativize();
  1479
+    this.assertEqual('static', element.getStyle('position'));
  1480
+  },
  1481
+  
  1482
+  testRelativizeThenAbsolutize: function() {
  1483
+    var element = $('position-static');
  1484
+    element.relativize();
  1485
+    element.absolutize();
  1486
+    element.undoRelativize();
  1487
+    element.undoAbsolutize();
  1488
+    this.assertEqual('static', element.getStyle('position'));
  1489
+  },
1472 1490
 
1473 1491
   testViewportDimensions: function() {
1474 1492
     preservingBrowserDimensions(function() {

0 notes on commit 0ae2caf

Please sign in to comment.
Something went wrong with that request. Please try again.