Code style / formatting.

pull/8275/head
typhonrt 4 years ago
parent 15fa8ad0cc
commit 8f5fd3d6fe

@ -16,17 +16,17 @@ export const structure = {
value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null] value: ['Identifier', 'Number', 'Comparison', 'Dimension', 'QueryCSSFunction', 'Ratio', null]
}; };
function lookupNonWSTypeAndValue(offset, type, referenceStr) { function lookup_non_WS_type_and_value(offset, type, referenceStr) {
let currentType; let current_type;
do { do {
currentType = this.lookupType(offset++); current_type = this.lookupType(offset++);
if (currentType !== WhiteSpace) { if (current_type !== WhiteSpace) {
break; break;
} }
} while (currentType !== 0); // NULL -> 0 } while (current_type !== 0); // NULL -> 0
return currentType === type ? this.lookupValue(offset - 1, referenceStr) : false; return current_type === type ? this.lookupValue(offset - 1, referenceStr) : false;
} }
export function parse() { export function parse() {
@ -39,7 +39,7 @@ export function parse() {
while (!this.eof && this.tokenType !== RightParenthesis) { while (!this.eof && this.tokenType !== RightParenthesis) {
switch (this.tokenType) { switch (this.tokenType) {
case Number: case Number:
if (lookupNonWSTypeAndValue.call(this, 1, Delim, '/')) { if (lookup_non_WS_type_and_value.call(this, 1, Delim, '/')) {
child = this.Ratio(); child = this.Ratio();
} else { } else {
child = this.Number(); child = this.Number();

@ -19,8 +19,8 @@ export function parse() {
const start = this.tokenStart; const start = this.tokenStart;
let value = null; let value = null;
const functionName = this.consumeFunctionName(); const function_name = this.consumeFunctionName();
if (functionName !== 'style') { if (function_name !== 'style') {
this.error('Unknown container style query identifier; "style" is expected'); this.error('Unknown container style query identifier; "style" is expected');
} }

@ -30,37 +30,35 @@ export const structure = {
* Looks ahead to determine if query feature is a range query. This involves locating at least one delimiter and no * Looks ahead to determine if query feature is a range query. This involves locating at least one delimiter and no
* colon tokens. * colon tokens.
* *
* @param context -
*
* @returns {boolean} Is potential range query. * @returns {boolean} Is potential range query.
*/ */
function lookaheadIsRange(context) { function lookahead_is_range() {
let type; let type;
let offset = 0; let offset = 0;
let count = 0; let count = 0;
let delimFound = false; let delim_found = false;
let noColon = true; let no_colon = true;
// A range query has maximum 5 tokens when formatted as 'mf-range' / // A range query has maximum 5 tokens when formatted as 'mf-range' /
// '<mf-value> <mf-lt> <mf-name> <mf-lt> <mf-value>'. So only look ahead maximum of 6 non-whitespace tokens. // '<mf-value> <mf-lt> <mf-name> <mf-lt> <mf-value>'. So only look ahead maximum of 6 non-whitespace tokens.
do { do {
type = context.lookupNonWSType(offset++); type = this.lookupNonWSType(offset++);
if (type !== WhiteSpace) { if (type !== WhiteSpace) {
count++; count++;
} }
if (type === Delim) { if (type === Delim) {
delimFound = true; delim_found = true;
} }
if (type === Colon) { if (type === Colon) {
noColon = false; no_colon = false;
} }
if (type === LeftCurlyBracket || type === RightParenthesis) { if (type === LeftCurlyBracket || type === RightParenthesis) {
break; break;
} }
} while (type !== EOF && count <= 6); } while (type !== EOF && count <= 6);
return delimFound && noColon; return delim_found && no_colon;
} }
export function parse() { export function parse() {
@ -71,12 +69,12 @@ export function parse() {
// Parse potential container name. // Parse potential container name.
if (this.tokenType === Ident) { if (this.tokenType === Ident) {
const containerName = this.substring(this.tokenStart, this.tokenEnd); const container_name = this.substring(this.tokenStart, this.tokenEnd);
// Container name doesn't match a query keyword, so assign it as container name. // Container name doesn't match a query keyword, so assign it as container name.
if (!CONTAINER_QUERY_KEYWORDS.has(containerName.toLowerCase())) { if (!CONTAINER_QUERY_KEYWORDS.has(container_name.toLowerCase())) {
name = containerName; name = container_name;
this.eatIdent(containerName); this.eatIdent(container_name);
} }
} }
@ -100,7 +98,7 @@ export function parse() {
case LeftParenthesis: case LeftParenthesis:
// Lookahead to determine if range feature. // Lookahead to determine if range feature.
child = lookaheadIsRange(this) ? this.ContainerFeatureRange() : this.ContainerFeature(); child = lookahead_is_range.call(this) ? this.ContainerFeatureRange() : this.ContainerFeature();
break; break;
default: default:

Loading…
Cancel
Save