Updated Branches:
  refs/heads/wicket-1.5.x 7efa1eed5 -> 84c355d60

don't use for-loop to iterate over array

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/84c355d6
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/84c355d6
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/84c355d6

Branch: refs/heads/wicket-1.5.x
Commit: 84c355d6029431ab4039a72ddbc1ee2ab02be423
Parents: 7efa1ee
Author: svenmeier <[email protected]>
Authored: Sun Feb 3 16:54:19 2013 +0100
Committer: svenmeier <[email protected]>
Committed: Sun Feb 3 16:54:19 2013 +0100

----------------------------------------------------------------------
 .../wicket/markup/html/form/CheckSelector.js       |   30 ++++-----------
 1 files changed, 8 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/84c355d6/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
index 8344eff..0e5f252 100644
--- 
a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
+++ 
b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/CheckSelector.js
@@ -38,9 +38,8 @@
                 */
                updateAllCheckboxes: function(newCheckedState, findCheckboxes) {
        
-                       var i,
-                               checkboxes = findCheckboxes();
-                       for (i in checkboxes) {
+                       var checkboxes = findCheckboxes();
+                       for (var i = 0; i < checkboxes.length; i++) {
                                var checkbox = checkboxes[i];
                                if (checkbox.checked !== newCheckedState) {
                                        checkbox.click();
@@ -61,13 +60,10 @@
                 *            associated checkboxes
                 */
                updateSelectorState: function(selectorId, findCheckboxes) {
-                       "use strict";
-       
-                       var i,
-                               checkboxes = findCheckboxes(),
+                       var checkboxes = findCheckboxes(),
                                allChecked = true;
        
-                       for (i in checkboxes) {
+                       for (var i = 0; i < checkboxes.length; i++) {
                                if (!(checkboxes[i].checked)) {
                                        allChecked = false;
                                        break;
@@ -88,15 +84,12 @@
                 *            associated checkboxes
                 */
                attachUpdateHandlers: function(selectorId, findCheckboxes) {
-                       "use strict";
-       
-                       var i,
-                               checkboxes = findCheckboxes(),
+                       var checkboxes = findCheckboxes(),
                                clickHandler = function() {
                                        
Wicket.CheckboxSelector.updateSelectorState(selectorId, findCheckboxes);
                                };
        
-                       for (i in checkboxes) {
+                       for (var i = 0; i < checkboxes.length; i++) {
                                Wicket.Event.add(checkboxes[i], 'click', 
clickHandler);
                        }
                        // update selector state once to get the right initial 
state
@@ -112,8 +105,6 @@
                 *            associated checkboxes
                 */
                initializeSelector: function(selectorId, findCheckboxes) {
-                       "use strict";
-       
                        var selector = document.getElementById(selectorId);
                        Wicket.Event.add(selector, 'click', function() {
                                
Wicket.CheckboxSelector.updateAllCheckboxes(selector.checked, findCheckboxes);
@@ -128,8 +119,6 @@
                 *            The markup ID of the containing form component
                 */
                findCheckboxesFunction: function(parentId, name) {
-                       "use strict";
-       
                        return function() {
                                var result = [];
                                var inputNodes = 
document.getElementById(parentId).getElementsByTagName('input');
@@ -151,13 +140,10 @@
                 *            selector should control.
                 */
                getCheckboxesFunction: function(checkBoxIDs) {
-                       "use strict";
-       
                        return function() {
-                               var i,
-                                       result = [];
+                               var result = [];
        
-                               for (i in checkBoxIDs) {
+                               for (var i = 0; i < checkBoxIDs.length; i++) {
                                        var checkBox = 
document.getElementById(checkBoxIDs[i]);
                                        result.push(checkBox);
                                }

Reply via email to