[Rt-commit] rt branch, 4.0/cascade-cf-with-multi-selected-parent, updated. rt-4.0.14rc1-4-ga691bb0

Thomas Sibley trs at bestpractical.com
Wed Jul 17 18:29:55 EDT 2013


The branch, 4.0/cascade-cf-with-multi-selected-parent has been updated
       via  a691bb0971a0b48739af286ef12a22dc6936d4b1 (commit)
       via  9f49ac9dd0e2e07a61a0bb33e63d2761bc420691 (commit)
      from  1030b884c928f309e6e9261c45986399d0e1455f (commit)

Summary of changes:
 share/html/NoAuth/js/cascaded.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit 9f49ac9dd0e2e07a61a0bb33e63d2761bc420691
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jul 17 14:52:54 2013 -0700

    Iterate JS arrays with a C-style for loop, not for-in
    
    for-in is not guaranteed to walk the arrays in order (although it often
    does on most browsers).  Preserving order is important since we're
    cloning and appending elements into another select.

diff --git a/share/html/NoAuth/js/cascaded.js b/share/html/NoAuth/js/cascaded.js
index 787d06d..f1a5eed 100644
--- a/share/html/NoAuth/js/cascaded.js
+++ b/share/html/NoAuth/js/cascaded.js
@@ -65,14 +65,14 @@ function filter_cascade (id, vals) {
 
         var cloned_labels = {};
         var cloned_empty_label;
-        for ( i in vals ) {
-            val = vals[i];
+        for ( var j = 0; j < vals.length; j++ ) {
+            val = vals[j];
             if ( val == '' && arguments.length == 3 ) {
                 // no category, and the category is from a hierchical cf;
                 // leave this set of options empty
             } else if ( val == '' ) {
                 // no category, let's clone all node
-                for (i in complete_children) {
+                for (i = 0; i < complete_children.length; i++) {
                     if ( complete_children[i].cloneNode ) {
                         new_option = complete_children[i].cloneNode(true);
                         select.appendChild(new_option);
@@ -82,7 +82,7 @@ function filter_cascade (id, vals) {
             }
             else {
                 var labels_to_clone = {};
-                for (i in complete_children) {
+                for (i = 0; i < complete_children.length; i++) {
                     if (!complete_children[i].label ||
                           (complete_children[i].hasAttribute &&
                                 !complete_children[i].hasAttribute('label') ) ) {
@@ -118,7 +118,7 @@ function filter_cascade (id, vals) {
     }
     else {
 // for back compatibility
-        for (i in children) {
+        for (i = 0; i < children.length; i++) {
             if (!children[i].label) { continue };
             if ( val == '' && arguments.length == 3 ) {
                 hide(children[i]);

commit a691bb0971a0b48739af286ef12a22dc6936d4b1
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Wed Jul 17 15:26:57 2013 -0700

    Use local variable declarations instead of polluting global space

diff --git a/share/html/NoAuth/js/cascaded.js b/share/html/NoAuth/js/cascaded.js
index f1a5eed..7559e40 100644
--- a/share/html/NoAuth/js/cascaded.js
+++ b/share/html/NoAuth/js/cascaded.js
@@ -66,7 +66,7 @@ function filter_cascade (id, vals) {
         var cloned_labels = {};
         var cloned_empty_label;
         for ( var j = 0; j < vals.length; j++ ) {
-            val = vals[j];
+            var val = vals[j];
             if ( val == '' && arguments.length == 3 ) {
                 // no category, and the category is from a hierchical cf;
                 // leave this set of options empty
@@ -74,7 +74,7 @@ function filter_cascade (id, vals) {
                 // no category, let's clone all node
                 for (i = 0; i < complete_children.length; i++) {
                     if ( complete_children[i].cloneNode ) {
-                        new_option = complete_children[i].cloneNode(true);
+                        var new_option = complete_children[i].cloneNode(true);
                         select.appendChild(new_option);
                     }
                 }
@@ -101,7 +101,7 @@ function filter_cascade (id, vals) {
                     }
 
                     if ( complete_children[i].cloneNode ) {
-                        new_option = complete_children[i].cloneNode(true);
+                        var new_option = complete_children[i].cloneNode(true);
                         select.appendChild(new_option);
                     }
                 }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list