mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-04 06:57:03 +03:00
Remove some unused Knockout code
This commit is contained in:
parent
6a715da1ac
commit
81ccee1152
5 changed files with 89 additions and 106 deletions
|
|
@ -29,14 +29,13 @@ ko.bindingProvider = new class
|
|||
var bindingsString = getBindingsString(node);
|
||||
if (bindingsString) {
|
||||
try {
|
||||
let options = { 'valueAccessors': true },
|
||||
cacheKey = bindingsString,
|
||||
let cacheKey = bindingsString,
|
||||
bindingFunction = bindingCache.get(cacheKey);
|
||||
if (!bindingFunction) {
|
||||
// Build the source for a function that evaluates "expression"
|
||||
// For each scope variable, add an extra level of "with" nesting
|
||||
// Example result: with(sc1) { with(sc0) { return (expression) } }
|
||||
var rewrittenBindings = ko.expressionRewriting.preProcessBindings(bindingsString, options),
|
||||
var rewrittenBindings = ko.expressionRewriting.preProcessBindings(bindingsString),
|
||||
functionBody = "with($context){with($data||{}){return{" + rewrittenBindings + "}}}";
|
||||
bindingFunction = new Function("$context", "$element", functionBody);
|
||||
bindingCache.set(cacheKey, bindingFunction);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,8 @@ ko.bindingHandlers['checked'] = {
|
|||
// currently checked, replace the old elem value with the new elem value
|
||||
// in the model array.
|
||||
if (isChecked) {
|
||||
writableValue.push(elemValue);
|
||||
writableValue.remove(saveOldValue);
|
||||
writableValue.push(elemValue);
|
||||
writableValue.remove(saveOldValue);
|
||||
}
|
||||
} else {
|
||||
// When we're responding to the user having checked/unchecked a checkbox,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,9 @@ ko.expressionRewriting = (() => {
|
|||
// A comma signals the end of a key/value pair if depth is zero
|
||||
if (c === 44) { // ","
|
||||
if (depth <= 0) {
|
||||
result.push((key && values.length) ? {key: key, value: values.join('')} : {'unknown': key || values.join('')});
|
||||
result.push((key && values.length)
|
||||
? {key: key, value: values.join('')}
|
||||
: {'unknown': key || values.join('')});
|
||||
key = depth = 0;
|
||||
values = [];
|
||||
continue;
|
||||
|
|
@ -111,33 +113,24 @@ ko.expressionRewriting = (() => {
|
|||
// Two-way bindings include a write function that allow the handler to update the value even if it's not an observable.
|
||||
twoWayBindings = new Set,
|
||||
|
||||
preProcessBindings = (bindingsStringOrKeyValueArray, bindingOptions) => {
|
||||
preProcessBindings = (bindingsStringOrKeyValueArray) => {
|
||||
|
||||
var resultStrings = [],
|
||||
propertyAccessorResultStrings = [],
|
||||
makeValueAccessors = bindingOptions?.['valueAccessors'],
|
||||
bindingParams = bindingOptions?.['bindingParams'],
|
||||
keyValueArray = typeof bindingsStringOrKeyValueArray === "string" ?
|
||||
parseObjectLiteral(bindingsStringOrKeyValueArray) : bindingsStringOrKeyValueArray,
|
||||
keyValueArray = parseObjectLiteral(bindingsStringOrKeyValueArray),
|
||||
|
||||
processKeyValue = (key, val) => {
|
||||
var writableVal,
|
||||
callPreprocessHook = obj =>
|
||||
obj?.['preprocess'] ? (val = obj['preprocess'](val, key, processKeyValue)) : true;
|
||||
if (!bindingParams) {
|
||||
if (!callPreprocessHook(ko.bindingHandlers[key]))
|
||||
return;
|
||||
var writableVal, obj = ko.bindingHandlers[key];
|
||||
if (obj?.['preprocess'] && !obj['preprocess'](val, key, processKeyValue))
|
||||
return;
|
||||
|
||||
if (twoWayBindings.has(key) && (writableVal = getWriteableValue(val))) {
|
||||
// For two-way bindings, provide a write method in case the value
|
||||
// isn't a writable observable.
|
||||
propertyAccessorResultStrings.push("'" + key + "':function(_z){" + writableVal + "=_z}");
|
||||
}
|
||||
if (twoWayBindings.has(key) && (writableVal = getWriteableValue(val))) {
|
||||
// For two-way bindings, provide a write method in case the value
|
||||
// isn't a writable observable.
|
||||
propertyAccessorResultStrings.push("'" + key + "':function(_z){" + writableVal + "=_z}");
|
||||
}
|
||||
// Values are wrapped in a function so that each value can be accessed independently
|
||||
if (makeValueAccessors) {
|
||||
val = 'function(){return ' + val + ' }';
|
||||
}
|
||||
val = 'function(){return ' + val + ' }';
|
||||
resultStrings.push("'" + key + "':" + val);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue