Fix: validate function should return a boolean

This commit is contained in:
eight 2018-11-18 23:31:24 +08:00
parent fc53234dba
commit 6beed6b9c9

View File

@ -44,9 +44,7 @@ const colorConverter = (() => {
// Copied from _hexcolor() in parserlib.js // Copied from _hexcolor() in parserlib.js
function validateHex(color) { function validateHex(color) {
return (!/^#[a-f\d]+$/i.test(color) || [4, 5, 7, 9].every(n => color.length !== n)) return /^#[a-f\d]+$/i.test(color) && [4, 5, 7, 9].some(n => color.length === n));
? false
: color;
} }
// % converted before function call // % converted before function call