Use JavaScript Optional chaining in vendors/*

This commit is contained in:
the-djmaze 2022-09-12 22:07:51 +02:00
parent e5e4675c1b
commit ef8b1f40e4
28 changed files with 619 additions and 750 deletions

View file

@ -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;
})();