JavaScript string compare '' is always a ToBoolean

See https://www.ecma-international.org/ecma-262/5.1/#sec-9.2
This commit is contained in:
djmaze 2020-07-28 17:20:14 +02:00
parent 82bed1ed80
commit 2ba34532c2
57 changed files with 213 additions and 218 deletions

20
dev/External/ko.js vendored
View file

@ -160,12 +160,12 @@ ko.bindingHandlers.tooltip = {
}
});
if ('' === sValue) {
if (sValue) {
element.__opentip.activate();
} else {
element.__opentip.hide();
element.__opentip.deactivate();
element.__opentip.setContent('');
} else {
element.__opentip.activate();
}
if (isI18N) {
@ -245,11 +245,7 @@ ko.bindingHandlers.tooltipErrorTip = {
openTips = element.__opentip;
if (openTips) {
if ('' === value) {
openTips.hide();
openTips.deactivate();
openTips.setContent('');
} else {
if (value) {
setTimeout(() => {
if ($el.is(':visible')) {
openTips.setContent(value);
@ -261,6 +257,10 @@ ko.bindingHandlers.tooltipErrorTip = {
openTips.setContent('');
}
}, Magics.Time100ms);
} else {
openTips.hide();
openTips.deactivate();
openTips.setContent('');
}
}
}
@ -1087,7 +1087,7 @@ ko.observable.fn.validateEmail = function() {
this.hasError = ko.observable(false);
this.subscribe((value) => {
this.hasError('' !== value && !/^[^@\s]+@[^@\s]+$/.test(value));
this.hasError(value && !/^[^@\s]+@[^@\s]+$/.test(value));
});
this.valueHasMutated();
@ -1098,7 +1098,7 @@ ko.observable.fn.validateSimpleEmail = function() {
this.hasError = ko.observable(false);
this.subscribe((value) => {
this.hasError('' !== value && !/^.+@.+$/.test(value));
this.hasError(value && !/^.+@.+$/.test(value));
});
this.valueHasMutated();