mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 22:17:03 +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
|
||||
|
|
|
|||
7
vendors/knockout/src/tasks.js
vendored
7
vendors/knockout/src/tasks.js
vendored
|
|
@ -24,8 +24,9 @@ ko.tasks = (() => {
|
|||
if (nextIndexToProcess > mark) {
|
||||
if (++countMarks >= 5000) {
|
||||
nextIndexToProcess = taskQueueLength; // skip all tasks remaining in the queue since any of them could be causing the recursion
|
||||
setTimeout(() =>
|
||||
throw Error(`'Too much recursion' after processing ${countMarks} task groups.`), 0)
|
||||
setTimeout(() => {
|
||||
throw Error(`'Too much recursion' after processing ${countMarks} task groups.`)
|
||||
}, 0)
|
||||
break;
|
||||
}
|
||||
mark = taskQueueLength;
|
||||
|
|
@ -33,7 +34,7 @@ ko.tasks = (() => {
|
|||
try {
|
||||
task();
|
||||
} catch (ex) {
|
||||
setTimeout(() => throw ex, 0);
|
||||
setTimeout(() => { throw ex }, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue