mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
Cleanup KnockoutJS
This commit is contained in:
parent
4c7ce61bc0
commit
4142526ba6
9 changed files with 121 additions and 279 deletions
|
|
@ -11,7 +11,7 @@ ko.bindingHandlers['attr'] = {
|
|||
// To cover cases like "attr: { checked:someProp }", we want to remove the attribute entirely
|
||||
// when someProp is a "no value"-like value (strictly null, false, or undefined)
|
||||
// (because the absence of the "checked" attr is how to mark an element as not checked, etc.)
|
||||
var toRemove = (attrValue === false) || (attrValue === null) || (attrValue === undefined);
|
||||
var toRemove = (attrValue === false) || (attrValue == null);
|
||||
if (toRemove) {
|
||||
namespace ? element.removeAttributeNS(namespace, attrName) : element.removeAttribute(attrName);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ ko.bindingHandlers['style'] = {
|
|||
ko.utils.objectForEach(value, (styleName, styleValue) => {
|
||||
styleValue = ko.utils.unwrapObservable(styleValue);
|
||||
|
||||
if (styleValue === null || styleValue === undefined || styleValue === false) {
|
||||
if (styleValue == null || styleValue === false) {
|
||||
// Empty string removes the value, whereas null/undefined have no effect
|
||||
styleValue = "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ ko.bindingHandlers['textInput'] = {
|
|||
var updateView = () => {
|
||||
var modelValue = ko.utils.unwrapObservable(valueAccessor());
|
||||
|
||||
if (modelValue === null || modelValue === undefined) {
|
||||
if (modelValue == null) {
|
||||
modelValue = '';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ ko.bindingHandlers['value'] = {
|
|||
// For file input elements, can only write the empty string
|
||||
updateFromModel = () => {
|
||||
var newValue = ko.utils.unwrapObservable(valueAccessor());
|
||||
if (newValue === null || newValue === undefined || newValue === "") {
|
||||
if (newValue == null || newValue === "") {
|
||||
element.value = "";
|
||||
} else {
|
||||
ko.dependencyDetection.ignore(valueUpdateHandler); // reset the model to match the element
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue