Author: jmorliaguet
Date: Sat Feb 18 01:37:44 2006
New Revision: 2408

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/ctal.js
   
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html
Log:

- bug fix: new edge case where the information from the data structure became
  unavailable from inside the loop the third time the repeat loop was run.

  we do a deepcopy of the entire data structure



Modified: cpsskins/branches/jmo-perspectives/ui/framework/ctal.js
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/framework/ctal.js     (original)
+++ cpsskins/branches/jmo-perspectives/ui/framework/ctal.js     Sat Feb 18 
01:37:44 2006
@@ -163,24 +163,17 @@
       " iterator variable overwrites loop variable.");
   }
 
+  // do a deep copy of the data structure traversed by the repeat loop
+  // to avoid corrupting it.
+  var saved_data = ctal.deepcopy(data);
   for (var i=0; i<datas.length; i++) {
-    // do a deep copy of the data structure traversed by the repeat loop
-    // to avoid corrupting it.
-    var saved_data = new Object();
-    var current_data = data[nmx[0]];
-    if (typeof current_data != "undefined") {
-      saved_data = ctal.deepcopy(current_data);
-    }
     data[nmx[0]] = datas[i];
 
     var newnode = tmpl.cloneNode(true);
     ctal.node_insertbefore(parent, newnode, marker);
     // recurse
     ctal.process_ctal(newnode, data);
-    // restore the original data structure
-    if (saved_data) {
-      data = ctal.deepcopy(saved_data);
-    }
+    data = ctal.deepcopy(saved_data);
   }
   parent.removeChild(tmpl);
 }

Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html
  (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_ctal_test.html
  Sat Feb 18 01:37:44 2006
@@ -298,6 +298,10 @@
 <div id="e34"><p ctal:repeat="f f" ctal:content="f">...</p></div>
 
 
+<!-- the entire data structure must be accessible from inside the loop -->
+<div id="e35"><p ctal:repeat="item f"><span ctal:content="a"></span></p></div>
+
+
 <!-- Tests follow -->
 <script type="text/javascript">
 // <![CDATA[
@@ -510,6 +514,10 @@
 
       // XXX: this one does not pass yet
       assertEqual('', htmlOf("e34"));
+
+      assertEqual(
+             '<p><span>1</span></p><p><span>1</span></p><p><span>1</span></p>',
+             htmlOf("e35"));
     }}
 
   });
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to