From ae14e6b8da71ac9aa5639405e530840959eb44b5 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Mon, 14 Mar 2022 23:22:23 +0100 Subject: [PATCH 1/2] Replace deprecated String.prototype.substr() 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 --- docs/tinycolor.html | 2 +- tinycolor.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tinycolor.html b/docs/tinycolor.html index 148068c..f156791 100644 --- a/docs/tinycolor.html +++ b/docs/tinycolor.html @@ -298,7 +298,7 @@ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + format = String(color.r).slice(-1) === "%" ? "prgb" : "rgb"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); diff --git a/tinycolor.js b/tinycolor.js index 7534fc7..0405643 100644 --- a/tinycolor.js +++ b/tinycolor.js @@ -318,7 +318,7 @@ function inputToRGB(color) { if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + format = String(color.r).slice(-1) === "%" ? "prgb" : "rgb"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); From 452f512b7937fffc869152b4e6e8698b825db60c Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Fri, 29 Sep 2023 13:44:45 +0200 Subject: [PATCH 2/2] Replace deprecated String.prototype.substr() 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 --- mod.js | 2 +- tinycolor.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mod.js b/mod.js index be6b382..bbd4e62 100644 --- a/mod.js +++ b/mod.js @@ -377,7 +377,7 @@ function inputToRGB(color) { ) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + format = String(color.r).slice(-1) === "%" ? "prgb" : "rgb"; } else if ( isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && diff --git a/tinycolor.js b/tinycolor.js index e52a3d5..74b79d4 100644 --- a/tinycolor.js +++ b/tinycolor.js @@ -325,7 +325,7 @@ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) { rgb = rgbToRgb(color.r, color.g, color.b); ok = true; - format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb"; + format = String(color.r).slice(-1) === "%" ? "prgb" : "rgb"; } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) { s = convertToPercentage(color.s); v = convertToPercentage(color.v);