Drop ko.extenders.limitedList

This commit is contained in:
the-djmaze 2022-09-26 11:55:26 +02:00
parent deeb86bd5f
commit d1d820da73
8 changed files with 14 additions and 77 deletions

24
dev/External/ko.js vendored
View file

@ -2,7 +2,7 @@ import ko from 'ko';
import { i18nToNodes } from 'Common/Translator';
import { doc, createElement } from 'Common/Globals';
import { SaveSettingsStep } from 'Common/Enums';
import { arrayLength, isFunction, forEachObjectEntry } from 'Common/Utils';
import { isFunction, forEachObjectEntry } from 'Common/Utils';
export const
errorTip = (element, value) => value
@ -146,28 +146,6 @@ Object.assign(ko.bindingHandlers, {
// extenders
ko.extenders.limitedList = (target, limitedList) => {
const result = ko
.computed({
read: target,
write: newValue => {
let currentValue = target(),
list = ko.unwrap(limitedList);
list = arrayLength(list) ? list : [''];
if (!list.includes(newValue)) {
newValue = list.includes(currentValue, list) ? currentValue : list[0];
target(newValue + ' ');
}
target(newValue);
}
})
.extend({ notify: 'always' });
result(target());
return result;
};
ko.extenders.toggleSubscribeProperty = (target, options) => {
const prop = options[1];
if (prop) {