Removed usage of bitwise assignment operators in logical operations

JavaScript &= and |= are bitwise operators. They are shortened version of:
 foo = foo & bar
 foo = foo | bar

In some places they were used as shortened version of logical operation and assignment.
 foo = foo && bar

It lead to type conversion to Number which is wrong (0 !== false).

This patch replaces such occurances with full version of logical operation and asignment.

https://fedorahosted.org/freeipa/ticket/2040
This commit is contained in:
Petr Vobornik 2011-12-05 13:39:30 +01:00 committed by Endi S. Dewata
parent c5ca34f41d
commit 1ffbec9942
5 changed files with 8 additions and 8 deletions

View File

@ -508,7 +508,7 @@ IPA.details_facet = function(spec) {
var fields = that.fields.get_fields();
for (var i=0; i<fields.length; i++) {
var field = fields[i];
valid &= field.validate() && field.validate_required();
valid = field.validate() && field.validate_required() && valid;
}
return valid;
};

View File

@ -99,7 +99,7 @@ IPA.dialog = function(spec) {
var fields = that.fields.get_fields();
for (var i=0; i<fields.length; i++) {
var field = fields[i];
valid &= field.validate() && field.validate_required();
valid = field.validate() && field.validate_required() && valid;
}
return valid;
};

View File

@ -301,8 +301,8 @@ IPA.field = function(spec) {
if (!value) empty = true;
if (value instanceof Array) {
empty |= (value.length === 0) ||
(value.length === 1) && (value[0] === '');
empty = empty || value.length === 0 ||
(value.length === 1) && (value[0] === '');
}
if (value === '') empty = true;
@ -480,7 +480,7 @@ IPA.multivalued_field = function(spec) {
that.test_dirty = function() {
var dirty = that.field_test_dirty();
dirty |= that.widget.test_dirty(); //also checks order
dirty = dirty || that.widget.test_dirty(); //also checks order
return dirty;
};

View File

@ -725,8 +725,8 @@ IPA.concurrent_command = function(spec) {
for(var i=0; i < that.commands.length; i++) {
var command_info = that.commands[i];
all_completed &= command_info.completed;
all_success &= command_info.success;
all_completed = all_completed && command_info.completed;
all_success = all_success && command_info.success;
}
if(all_completed) {

View File

@ -515,7 +515,7 @@ IPA.multivalued_text_widget = function(spec) {
var dirty = false;
for(var i=0; i < that.rows.length; i++) {
dirty |= that.test_dirty_row(that.rows[i]);
dirty = dirty || that.test_dirty_row(that.rows[i]);
}
return dirty;