]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Replace deprecated String.prototype.substr() (#10243)
authorCommanderRoot <CommanderRoot@users.noreply.github.com>
Fri, 18 Mar 2022 21:38:28 +0000 (22:38 +0100)
committerGitHub <noreply@github.com>
Fri, 18 Mar 2022 21:38:28 +0000 (17:38 -0400)
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 similar functions which aren't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
src/helpers/helpers.core.js

index 2663c8b834b25bdb79ceb3f7889bcc16fef77ec3..00c143aa32575ca09766a543ee7d6f0bb134a8bb 100644 (file)
@@ -39,7 +39,7 @@ export function isArray(value) {
     return true;
   }
   const type = Object.prototype.toString.call(value);
-  if (type.substr(0, 7) === '[object' && type.substr(-6) === 'Array]') {
+  if (type.slice(0, 7) === '[object' && type.slice(-6) === 'Array]') {
     return true;
   }
   return false;
@@ -307,7 +307,7 @@ export function resolveObjectKey(obj, key) {
   let pos = 0;
   let idx = indexOfDotOrLength(key, pos);
   while (obj && idx > pos) {
-    obj = obj[key.substr(pos, idx - pos)];
+    obj = obj[key.slice(pos, idx)];
     pos = idx + 1;
     idx = indexOfDotOrLength(key, pos);
   }