From 76738daff8c345682ef841333898bfec01d5de5d Mon Sep 17 00:00:00 2001 From: CommanderRoot Date: Mon, 6 Jun 2022 16:16:38 +0200 Subject: [PATCH] Replace deprecated String.prototype.substr() (#8988) String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated. Signed-off-by: Tobias Speicher --- modules/renderer/photos.js | 2 +- modules/ui/fields/combo.js | 2 +- modules/ui/success.js | 2 +- modules/util/util.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/renderer/photos.js b/modules/renderer/photos.js index 0fff47950..ee2705b84 100644 --- a/modules/renderer/photos.js +++ b/modules/renderer/photos.js @@ -54,7 +54,7 @@ export function rendererPhotos(context) { // validate the date var date = val && new Date(val); if (date && !isNaN(date)) { - val = date.toISOString().substr(0, 10); + val = date.toISOString().slice(0, 10); } else { val = null; } diff --git a/modules/ui/fields/combo.js b/modules/ui/fields/combo.js index a638a41ba..fffc86d96 100644 --- a/modules/ui/fields/combo.js +++ b/modules/ui/fields/combo.js @@ -434,7 +434,7 @@ export function uiFieldCombo(field, context) { var v = tags[k]; if (!v || (typeof v === 'string' && v.toLowerCase() === 'no')) continue; - var suffix = field.key ? k.substr(field.key.length) : k; + var suffix = field.key ? k.slice(field.key.length) : k; _multiData.push({ key: k, value: displayValue(suffix), diff --git a/modules/ui/success.js b/modules/ui/success.js index 43328b0b3..3e5ce044b 100644 --- a/modules/ui/success.js +++ b/modules/ui/success.js @@ -71,7 +71,7 @@ export function uiSuccess(context) { } const parsed = new Date(raw); - return new Date(parsed.toUTCString().substr(0, 25)); // convert to local timezone + return new Date(parsed.toUTCString().slice(0, 25)); // convert to local timezone } diff --git a/modules/util/util.js b/modules/util/util.js index f80128b61..13af49878 100644 --- a/modules/util/util.js +++ b/modules/util/util.js @@ -403,7 +403,7 @@ export function utilPrefixDOMProperty(property) { if (property in s) return property; - property = property.substr(0, 1).toUpperCase() + property.substr(1); + property = property.slice(0, 1).toUpperCase() + property.slice(1); while (++i < n) { if (prefixes[i] + property in s) {