mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
ko.utils.setTimeout to native setTimeout
This commit is contained in:
parent
9014f08f35
commit
5cb4d338a1
5 changed files with 7 additions and 9 deletions
|
|
@ -24,7 +24,7 @@ ko.bindingHandlers['textInput'] = {
|
||||||
// updates that are from the previous state of the element, usually due to techniques
|
// updates that are from the previous state of the element, usually due to techniques
|
||||||
// such as rateLimit. Such updates, if not ignored, can cause keystrokes to be lost.
|
// such as rateLimit. Such updates, if not ignored, can cause keystrokes to be lost.
|
||||||
elementValueBeforeEvent = element.value;
|
elementValueBeforeEvent = element.value;
|
||||||
timeoutHandle = ko.utils.setTimeout(updateModel, 4);
|
timeoutHandle = setTimeout(updateModel, 4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ ko.bindingHandlers['textInput'] = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elementValueBeforeEvent !== undefined && modelValue === elementValueBeforeEvent) {
|
if (elementValueBeforeEvent !== undefined && modelValue === elementValueBeforeEvent) {
|
||||||
ko.utils.setTimeout(updateView, 4);
|
setTimeout(updateView, 4);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ ko.bindingHandlers['value'] = {
|
||||||
// techniques like rateLimit can trigger model changes at critical moments that will
|
// techniques like rateLimit can trigger model changes at critical moments that will
|
||||||
// override the user's inputs, causing keystrokes to be lost.
|
// override the user's inputs, causing keystrokes to be lost.
|
||||||
elementValueBeforeEvent = ko.selectExtensions.readValue(element);
|
elementValueBeforeEvent = ko.selectExtensions.readValue(element);
|
||||||
ko.utils.setTimeout(valueUpdateHandler, 0);
|
setTimeout(valueUpdateHandler, 0);
|
||||||
};
|
};
|
||||||
eventName = eventName.substring(5);
|
eventName = eventName.substring(5);
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,7 @@ ko.bindingHandlers['value'] = {
|
||||||
var elementValue = ko.selectExtensions.readValue(element);
|
var elementValue = ko.selectExtensions.readValue(element);
|
||||||
|
|
||||||
if (elementValueBeforeEvent !== null && newValue === elementValueBeforeEvent) {
|
if (elementValueBeforeEvent !== null && newValue === elementValueBeforeEvent) {
|
||||||
ko.utils.setTimeout(updateFromModel, 0);
|
setTimeout(updateFromModel, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ var computedFn = {
|
||||||
throttleEvaluationTimeout = computedObservable['throttleEvaluation'];
|
throttleEvaluationTimeout = computedObservable['throttleEvaluation'];
|
||||||
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {
|
||||||
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
clearTimeout(this[computedState].evaluationTimeoutInstance);
|
||||||
this[computedState].evaluationTimeoutInstance = ko.utils.setTimeout(() =>
|
this[computedState].evaluationTimeoutInstance = setTimeout(() =>
|
||||||
computedObservable.evaluateImmediate(true /*notifyChange*/)
|
computedObservable.evaluateImmediate(true /*notifyChange*/)
|
||||||
, throttleEvaluationTimeout);
|
, throttleEvaluationTimeout);
|
||||||
} else if (computedObservable._evalDelayed) {
|
} else if (computedObservable._evalDelayed) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function throttle(callback, timeout) {
|
||||||
var timeoutInstance;
|
var timeoutInstance;
|
||||||
return () => {
|
return () => {
|
||||||
if (!timeoutInstance) {
|
if (!timeoutInstance) {
|
||||||
timeoutInstance = ko.utils.setTimeout(() => {
|
timeoutInstance = setTimeout(() => {
|
||||||
timeoutInstance = 0;
|
timeoutInstance = 0;
|
||||||
callback();
|
callback();
|
||||||
}, timeout);
|
}, timeout);
|
||||||
|
|
@ -43,7 +43,7 @@ function debounce(callback, timeout) {
|
||||||
var timeoutInstance;
|
var timeoutInstance;
|
||||||
return () => {
|
return () => {
|
||||||
clearTimeout(timeoutInstance);
|
clearTimeout(timeoutInstance);
|
||||||
timeoutInstance = ko.utils.setTimeout(callback, timeout);
|
timeoutInstance = setTimeout(callback, timeout);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
2
vendors/knockout/src/utils.js
vendored
2
vendors/knockout/src/utils.js
vendored
|
|
@ -94,8 +94,6 @@ ko.utils = {
|
||||||
|
|
||||||
domNodeIsAttachedToDocument: node => ko.utils.domNodeIsContainedBy(node, node.ownerDocument.documentElement),
|
domNodeIsAttachedToDocument: node => ko.utils.domNodeIsContainedBy(node, node.ownerDocument.documentElement),
|
||||||
|
|
||||||
setTimeout: (handler, timeout) => setTimeout(handler, timeout),
|
|
||||||
|
|
||||||
triggerEvent: (element, eventType) => {
|
triggerEvent: (element, eventType) => {
|
||||||
if (!(element && element.nodeType))
|
if (!(element && element.nodeType))
|
||||||
throw new Error("element must be a DOM node when calling triggerEvent");
|
throw new Error("element must be a DOM node when calling triggerEvent");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue