mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-02 05:59:21 +03:00
Use JavaScript Optional chaining in vendors/*
This commit is contained in:
parent
e5e4675c1b
commit
ef8b1f40e4
28 changed files with 619 additions and 750 deletions
41
vendors/knockout/src/tasks.js
vendored
41
vendors/knockout/src/tasks.js
vendored
|
|
@ -1,18 +1,9 @@
|
|||
ko.tasks = (() => {
|
||||
var taskQueue = [],
|
||||
taskQueueLength = 0,
|
||||
nextHandle = 1,
|
||||
nextIndexToProcess = 0,
|
||||
|
||||
// Chrome 27+, Firefox 14+, IE 11+, Opera 15+, Safari 6.1+
|
||||
// From https://github.com/petkaantonov/bluebird * Copyright (c) 2014 Petka Antonov * License: MIT
|
||||
scheduler = (callback => {
|
||||
var div = document.createElement("div");
|
||||
new MutationObserver(callback).observe(div, {attributes: true});
|
||||
return () => div.classList.toggle("foo");
|
||||
})(scheduledProcess);
|
||||
|
||||
function processTasks() {
|
||||
processTasks = () => {
|
||||
if (taskQueueLength) {
|
||||
// Each mark represents the end of a logical group of tasks and the number of these groups is
|
||||
// limited to prevent unchecked recursion.
|
||||
|
|
@ -39,32 +30,28 @@ ko.tasks = (() => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
function scheduledProcess() {
|
||||
scheduledProcess = () => {
|
||||
processTasks();
|
||||
|
||||
// Reset the queue
|
||||
nextIndexToProcess = taskQueueLength = taskQueue.length = 0;
|
||||
}
|
||||
},
|
||||
|
||||
var tasks = {
|
||||
// Chrome 27+, Firefox 14+, IE 11+, Opera 15+, Safari 6.1+
|
||||
// From https://github.com/petkaantonov/bluebird * Copyright (c) 2014 Petka Antonov * License: MIT
|
||||
scheduler = (callback => {
|
||||
var div = document.createElement("div");
|
||||
new MutationObserver(callback).observe(div, {attributes: true});
|
||||
return () => div.classList.toggle("foo");
|
||||
})(scheduledProcess);
|
||||
|
||||
return {
|
||||
schedule: func => {
|
||||
if (!taskQueueLength) {
|
||||
scheduler(scheduledProcess);
|
||||
}
|
||||
taskQueueLength || scheduler(scheduledProcess);
|
||||
|
||||
taskQueue[taskQueueLength++] = func;
|
||||
return nextHandle++;
|
||||
},
|
||||
|
||||
cancel: handle => {
|
||||
var index = handle - (nextHandle - taskQueueLength);
|
||||
if (index >= nextIndexToProcess && index < taskQueueLength) {
|
||||
taskQueue[index] = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return tasks;
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue