Skip to content

Commit

Permalink
Everything to ES2020
Browse files Browse the repository at this point in the history
  • Loading branch information
the-djmaze committed Apr 2, 2024
1 parent 84ffe1e commit 78178ec
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
// extends: ['eslint:recommended', 'plugin:prettier/recommended'],
extends: ['eslint:recommended'],
parserOptions: {
ecmaVersion: 6,
ecmaVersion: 11,
sourceType: 'module'
},
env: {
Expand Down
2 changes: 1 addition & 1 deletion dev/Common/Translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const
* @returns {string}
*/
i18n = (key, valueList, defaulValue) => {
let result = null == defaulValue ? key : defaulValue;
let result = defaulValue ?? key;
let path = key.split('/');
if (I18N_DATA[path[0]] && path[1]) {
result = I18N_DATA[path[0]][path[1]] || result;
Expand Down
2 changes: 1 addition & 1 deletion dev/Component/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class CheckboxComponent {
: ko.observable(!!params.value);

this.enable = ko.isObservable(params.enable) ? params.enable
: ko.observable(undefined === params.enable || !!params.enable);
: ko.observable(params.enable ?? 1);

this.label = params.label;
}
Expand Down
2 changes: 1 addition & 1 deletion dev/DAV/JCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class JCard {
// VCardProperty argument
else if (arg instanceof VCardProperty) {
let propArray = this.props.get(arg.getField());
if (!(propArray === null || propArray === void 0 ? void 0 : propArray.includes(arg)))
if (!propArray?.includes(arg))
throw Error("Attempted to remove VCardProperty VCard does not have: ".concat(arg));
propArray.splice(propArray.indexOf(arg), 1);
if (propArray.length === 0)
Expand Down
2 changes: 1 addition & 1 deletion dev/Remote/AbstractFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class AbstractFetchRemote

fetchJSON(sAction, getURL(sGetAdd),
sGetAdd ? null : (params || {}),
undefined === iTimeout ? 30000 : pInt(iTimeout),
pInt(iTimeout ?? 30000),
async data => {
let iError = 0;
if (data) {
Expand Down
2 changes: 1 addition & 1 deletion dev/Screen/AbstractSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export class AbstractSettingsScreen extends AbstractScreen {
rules = {
subname: /^(.*)$/,
normalize_: (rquest, vals) => {
vals.subname = null == vals.subname ? defaultRoute : pString(vals.subname);
vals.subname = pString(vals.subname ?? defaultRoute);
return [vals.subname];
}
};
Expand Down
2 changes: 1 addition & 1 deletion dev/Storage/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ try {
data = data ? decodeURIComponent(data[2]) : null;
data = data ? JSON.parse(data) : {};
win[sName] = {
getItem: key => data[key] == null ? null : data[key],
getItem: key => data[key] ?? null,
setItem: (key, value) => {
data[key] = ''+value; // forces the value to a string
document.cookie = sName+'='+encodeURIComponent(JSON.stringify(data))
Expand Down
4 changes: 2 additions & 2 deletions dev/dragdropgecko.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
// create drag image from custom element or drag source
img = src.cloneNode(true);
copyStyle(src, img);
img._x = xOffset == null ? src.clientWidth / 2 : xOffset;
img._y = yOffset == null ? src.clientHeight / 2 : yOffset;
img._x = xOffset ?? src.clientWidth / 2;
img._y = yOffset ?? src.clientHeight / 2;
}
},

Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ let terserConfig = {
},
keep_classnames: true, // Required for AbstractModel and AbstractCollectionModel
compress:{
ecma: 6,
ecma: 2020,
drop_console: true
/*
,hoist_props: false
Expand Down
15 changes: 5 additions & 10 deletions vendors/knockout/build/output/knockout-latest.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ ko.observable = initialValue => {
observable[observableLatestValue] = initialValue;

Object.defineProperty(observable, length, {
get: () => null == observable[observableLatestValue] ? undefined : observable[observableLatestValue][length]
get: () => observable[observableLatestValue]?.[length]
});

// Inherit from 'subscribable'
Expand Down Expand Up @@ -1294,7 +1294,7 @@ ko.selectExtensions = {
break;
case 'SELECT':
// A blank string or null value will select the caption
var selection = -1, noValue = ("" === value || null == value),
var selection = -1, noValue = ("" === (value ?? "")),
i = element.options.length, optionValue;
while (i--) {
optionValue = ko.selectExtensions.readValue(element.options[i]);
Expand All @@ -1309,7 +1309,7 @@ ko.selectExtensions = {
}
break;
default:
element.value = (value == null) ? "" : value;
element.value = value ?? "";
break;
}
}
Expand Down Expand Up @@ -2660,7 +2660,6 @@ ko.bindingHandlers['options'] = {
previousScrollTop = (!selectWasPreviouslyEmpty && multiple) ? element.scrollTop : null,
unwrappedArray = ko.utils.unwrapObservable(valueAccessor()),
arrayToDomNodeChildrenOptions = {},
captionValue,
filteredArray,
previousSelectedValues = [],

Expand Down Expand Up @@ -2701,7 +2700,7 @@ ko.bindingHandlers['options'] = {
unwrappedArray = [unwrappedArray];

// Filter out any entries marked as destroyed
filteredArray = unwrappedArray.filter(item => item || item == null);
filteredArray = unwrappedArray.filter(item => item ?? 1);
} else {
// If a falsy value is provided (e.g. null), we'll simply empty the select element
}
Expand Down Expand Up @@ -2847,11 +2846,7 @@ ko.bindingHandlers['textInput'] = {
};

var updateView = () => {
var modelValue = ko.utils.unwrapObservable(valueAccessor());

if (modelValue == null) {
modelValue = '';
}
var modelValue = ko.utils.unwrapObservable(valueAccessor()) ?? '';

if (elementValueBeforeEvent !== undefined && modelValue === elementValueBeforeEvent) {
setTimeout(updateView, 4);
Expand Down
Loading

0 comments on commit 78178ec

Please sign in to comment.