src/less/parse.js
function checkCondition(i) {
  const start = i;
  let l;

  if (i >= tokensLength) return 0;

  if ((l = checkIdent(i)) && tokens[i].value === 'when') i += l;
  else return 0;

  while (i < tokensLength) {
    if (l = checkBlock(i)) {
      tokens[i].condition_child = 0;
      break;
    } else if (l = checkFunction(i)) tokens[i].condition_child = 1;
    else if (l = checkBrackets(i)) tokens[i].condition_child = 2;
    else if (l = checkParentheses(i)) tokens[i].condition_child = 3;
    else if (l = checkVariable(i)) tokens[i].condition_child = 4;
    else if (l = checkIdent(i)) tokens[i].condition_child = 5;
    else if (l = checkNumber(i)) tokens[i].condition_child = 6;
    else if (l = checkDelim(i)) tokens[i].condition_child = 7;
    else if (l = checkOperator(i)) tokens[i].condition_child = 8;
    else if (l = checkCombinator(i)) tokens[i].condition_child = 9;
    else if (l = checkSC(i)) tokens[i].condition_child = 10;
    else if (l = checkString(i)) tokens[i].condition_child = 11;
    else return 0;

    i += l;
  }

  return i - start;
}
function checkCondition(i) {
  const start = i;
  let l;

  if (i >= tokensLength) return 0;

  if ((l = checkIdent(i)) && tokens[i].value === 'when') i += l;
  else return 0;

  while (i < tokensLength) {
    if (l = checkBlock(i)) {
      tokens[i].condition_child = 0;
      break;
    } else if (l = checkFunction(i)) tokens[i].condition_child = 1;
    else if (l = checkBrackets(i)) tokens[i].condition_child = 2;
    else if (l = checkParentheses(i)) tokens[i].condition_child = 3;
    else if (l = checkVariable(i)) tokens[i].condition_child = 4;
    else if (l = checkIdent(i)) tokens[i].condition_child = 5;
    else if (l = checkNumber(i)) tokens[i].condition_child = 6;
    else if (l = checkDelim(i)) tokens[i].condition_child = 7;
    else if (l = checkOperator(i)) tokens[i].condition_child = 8;
    else if (l = checkCombinator(i)) tokens[i].condition_child = 9;
    else if (l = checkSC(i)) tokens[i].condition_child = 10;
    else if (l = checkString(i)) tokens[i].condition_child = 11;
    else return 0;

    i += l;
  }

  return i - start;
}
function checkCondition ( i ) { const start = i ; let l ; if ( i >= tokensLength ) return 0 ; if ( ( l = checkIdent ( i ) ) && tokens [ i ] . value === 'when' ) i += l ; else return 0 ; while ( i < tokensLength ) { if ( l = checkBlock ( i ) ) { tokens [ i ] . condition_child = 0 ; break ; } else if ( l = checkFunction ( i ) ) tokens [ i ] . condition_child = 1 ; else if ( l = checkBrackets ( i ) ) tokens [ i ] . condition_child = 2 ; else if ( l = checkParentheses ( i ) ) tokens [ i ] . condition_child = 3 ; else if ( l = checkVariable ( i ) ) tokens [ i ] . condition_child = 4 ; else if ( l = checkIdent ( i ) ) tokens [ i ] . condition_child = 5 ; else if ( l = checkNumber ( i ) ) tokens [ i ] . condition_child = 6 ; else if ( l = checkDelim ( i ) ) tokens [ i ] . condition_child = 7 ; else if ( l = checkOperator ( i ) ) tokens [ i ] . condition_child = 8 ; else if ( l = checkCombinator ( i ) ) tokens [ i ] . condition_child = 9 ; else if ( l = checkSC ( i ) ) tokens [ i ] . condition_child = 10 ; else if ( l = checkString ( i ) ) tokens [ i ] . condition_child = 11 ; else return 0 ; i += l ; } return i - start ; }
Check if token is part of a condition.
@param {Number} i Token's index number
@return {Number} Length of the condition
Check if token is part of a condition .