mirror of
https://github.com/apache/cordova-plugin-statusbar.git
synced 2026-04-27 00:00:06 +08:00
Update backgroundColorByHexString function
The implementation when `hexString.length == 4` was a bit off. The current version either doesn't actually use the `split` variable, so that variable could be removed, or used in place accessing the string characters as they are now. Opted for the former in this case, though it doesn't really matter. Since the length is always going to be a number, also changed to `===` instead, as well as updated the check for `#` at the beginning of the string. Since it's always looking for the `#` tat the beginning `charAt(0)` seems to be a better fit.
This commit is contained in:
+3
-3
@@ -71,13 +71,13 @@ var StatusBar = {
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (hexString) {
|
||||
if (hexString.indexOf("#") < 0) {
|
||||
if (hexString.charAt(0) === "#") {
|
||||
hexString = "#" + hexString;
|
||||
}
|
||||
|
||||
if (hexString.length == 4) {
|
||||
if (hexString.length === 4) {
|
||||
var split = hexString.split("");
|
||||
hexString = "#" + hexString[1] + hexString[1] + hexString[2] + hexString[2] + hexString[3] + hexString[3];
|
||||
hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
|
||||
}
|
||||
|
||||
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
|
||||
|
||||
Reference in New Issue
Block a user