mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
JavaScript inArray()/indexOf() to .includes()
This commit is contained in:
parent
ec3fd5b7e4
commit
db2d95d684
20 changed files with 69 additions and 86 deletions
9
dev/External/ko.js
vendored
9
dev/External/ko.js
vendored
|
|
@ -948,18 +948,17 @@ ko.extenders.posInterer = (target, defaultVal) => {
|
|||
};
|
||||
|
||||
ko.extenders.limitedList = (target, limitedList) => {
|
||||
const Utils = require('Common/Utils'),
|
||||
result = ko
|
||||
const result = ko
|
||||
.computed({
|
||||
read: target,
|
||||
write: (newValue) => {
|
||||
const currentValue = ko.unwrap(target),
|
||||
list = ko.unwrap(limitedList);
|
||||
|
||||
if (Utils.isNonEmptyArray(list)) {
|
||||
if (-1 < Utils.inArray(newValue, list)) {
|
||||
if (Array.isArray(list) && 0 < list.length) {
|
||||
if (list.includes(newValue)) {
|
||||
target(newValue);
|
||||
} else if (-1 < Utils.inArray(currentValue, list)) {
|
||||
} else if (list.includes(currentValue, list)) {
|
||||
target(currentValue + ' ');
|
||||
target(currentValue);
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue