Skip to content

Commit

Permalink
refactor: tweak regex variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Apr 19, 2020
1 parent 9189daa commit a55ffc2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/nodes/Func.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,9 @@ const allFunctions = [
const vendorPrefixes = ['-webkit-', '-moz-', '-ms-', '-o-'];
const reFunctions = new RegExp(`^(${vendorPrefixes.join('|')})?(${allFunctions.join('|')})`, 'i');
const rePunctuation = new RegExp(`^(\\${Punctuation.chars.join('|\\')})`);

const colorFunctionsRegex = /^(hsla?|hwb|lab|lch|rgba?)$/i;
const varFunctionRegex = /^var$/i;
const varPrefixRegex = /^--[^\s]+$/;
const reColorFunctions = /^(hsla?|hwb|lab|lch|rgba?)$/i;
const reVar = /^var$/i;
const reVarPrefix = /^--[^\s]+$/;

class Func extends Container {
constructor(options = {}) {
Expand Down Expand Up @@ -192,9 +191,8 @@ class Func extends Container {

const { lastNode } = parser;
const { nodes } = node;
lastNode.isColor = colorFunctionsRegex.test(lastNode.name);
lastNode.isVar =
varFunctionRegex.test(lastNode.name) && nodes.length && varPrefixRegex.test(nodes[0].value);
lastNode.isColor = reColorFunctions.test(lastNode.name);
lastNode.isVar = reVar.test(lastNode.name) && nodes.length && reVarPrefix.test(nodes[0].value);
}
}

Expand Down

0 comments on commit a55ffc2

Please sign in to comment.