format: prettify entire project
This commit is contained in:
383
node_modules/clean-css/lib/optimizer/level-2/break-up.js
generated
vendored
383
node_modules/clean-css/lib/optimizer/level-2/break-up.js
generated
vendored
@ -21,13 +21,21 @@ function _anyIsInherit(values) {
|
||||
|
||||
function _colorFilter(validator) {
|
||||
return function (value) {
|
||||
return value[1] == 'invert' || validator.isColor(value[1]) || validator.isPrefixed(value[1]);
|
||||
return (
|
||||
value[1] == 'invert' ||
|
||||
validator.isColor(value[1]) ||
|
||||
validator.isPrefixed(value[1])
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function _styleFilter(validator) {
|
||||
return function (value) {
|
||||
return value[1] != 'inherit' && validator.isStyleKeyword(value[1]) && !validator.isColorFunction(value[1]);
|
||||
return (
|
||||
value[1] != 'inherit' &&
|
||||
validator.isStyleKeyword(value[1]) &&
|
||||
!validator.isColorFunction(value[1])
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@ -38,42 +46,70 @@ function _wrapDefault(name, property, compactable) {
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, name],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue[0]],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue[1]]
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue[1]],
|
||||
]);
|
||||
} else if (descriptor.doubleValues && descriptor.defaultValue.length == 1) {
|
||||
return wrapSingle([
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, name],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue[0]]
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue[0]],
|
||||
]);
|
||||
} else {
|
||||
return wrapSingle([
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, name],
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue]
|
||||
[Token.PROPERTY_VALUE, descriptor.defaultValue],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
function _widthFilter(validator) {
|
||||
return function (value) {
|
||||
return value[1] != 'inherit' &&
|
||||
(validator.isWidth(value[1]) || validator.isUnit(value[1]) && !validator.isDynamicUnit(value[1])) &&
|
||||
return (
|
||||
value[1] != 'inherit' &&
|
||||
(validator.isWidth(value[1]) ||
|
||||
(validator.isUnit(value[1]) && !validator.isDynamicUnit(value[1]))) &&
|
||||
!validator.isStyleKeyword(value[1]) &&
|
||||
!validator.isColorFunction(value[1]);
|
||||
!validator.isColorFunction(value[1])
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function animation(property, compactable, validator) {
|
||||
var duration = _wrapDefault(property.name + '-duration', property, compactable);
|
||||
var timing = _wrapDefault(property.name + '-timing-function', property, compactable);
|
||||
var duration = _wrapDefault(
|
||||
property.name + '-duration',
|
||||
property,
|
||||
compactable
|
||||
);
|
||||
var timing = _wrapDefault(
|
||||
property.name + '-timing-function',
|
||||
property,
|
||||
compactable
|
||||
);
|
||||
var delay = _wrapDefault(property.name + '-delay', property, compactable);
|
||||
var iteration = _wrapDefault(property.name + '-iteration-count', property, compactable);
|
||||
var direction = _wrapDefault(property.name + '-direction', property, compactable);
|
||||
var iteration = _wrapDefault(
|
||||
property.name + '-iteration-count',
|
||||
property,
|
||||
compactable
|
||||
);
|
||||
var direction = _wrapDefault(
|
||||
property.name + '-direction',
|
||||
property,
|
||||
compactable
|
||||
);
|
||||
var fill = _wrapDefault(property.name + '-fill-mode', property, compactable);
|
||||
var play = _wrapDefault(property.name + '-play-state', property, compactable);
|
||||
var name = _wrapDefault(property.name + '-name', property, compactable);
|
||||
var components = [duration, timing, delay, iteration, direction, fill, play, name];
|
||||
var components = [
|
||||
duration,
|
||||
timing,
|
||||
delay,
|
||||
iteration,
|
||||
direction,
|
||||
fill,
|
||||
play,
|
||||
name,
|
||||
];
|
||||
var values = property.value;
|
||||
var value;
|
||||
var durationSet = false;
|
||||
@ -88,12 +124,24 @@ function animation(property, compactable, validator) {
|
||||
var l;
|
||||
|
||||
if (property.value.length == 1 && property.value[0][1] == 'inherit') {
|
||||
duration.value = timing.value = delay.value = iteration.value = direction.value = fill.value = play.value = name.value = property.value;
|
||||
duration.value =
|
||||
timing.value =
|
||||
delay.value =
|
||||
iteration.value =
|
||||
direction.value =
|
||||
fill.value =
|
||||
play.value =
|
||||
name.value =
|
||||
property.value;
|
||||
return components;
|
||||
}
|
||||
|
||||
if (values.length > 1 && _anyIsInherit(values)) {
|
||||
throw new InvalidPropertyError('Invalid animation values at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid animation values at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
for (i = 0, l = values.length; i < l; i++) {
|
||||
@ -105,13 +153,23 @@ function animation(property, compactable, validator) {
|
||||
} else if (validator.isTime(value[1]) && !delaySet) {
|
||||
delay.value = [value];
|
||||
delaySet = true;
|
||||
} else if ((validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) && !timingSet) {
|
||||
} else if (
|
||||
(validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) &&
|
||||
!timingSet
|
||||
) {
|
||||
timing.value = [value];
|
||||
timingSet = true;
|
||||
} else if ((validator.isAnimationIterationCountKeyword(value[1]) || validator.isPositiveNumber(value[1])) && !iterationSet) {
|
||||
} else if (
|
||||
(validator.isAnimationIterationCountKeyword(value[1]) ||
|
||||
validator.isPositiveNumber(value[1])) &&
|
||||
!iterationSet
|
||||
) {
|
||||
iteration.value = [value];
|
||||
iterationSet = true;
|
||||
} else if (validator.isAnimationDirectionKeyword(value[1]) && !directionSet) {
|
||||
} else if (
|
||||
validator.isAnimationDirectionKeyword(value[1]) &&
|
||||
!directionSet
|
||||
) {
|
||||
direction.value = [value];
|
||||
directionSet = true;
|
||||
} else if (validator.isAnimationFillModeKeyword(value[1]) && !fillSet) {
|
||||
@ -120,11 +178,19 @@ function animation(property, compactable, validator) {
|
||||
} else if (validator.isAnimationPlayStateKeyword(value[1]) && !playSet) {
|
||||
play.value = [value];
|
||||
playSet = true;
|
||||
} else if ((validator.isAnimationNameKeyword(value[1]) || validator.isIdentifier(value[1])) && !nameSet) {
|
||||
} else if (
|
||||
(validator.isAnimationNameKeyword(value[1]) ||
|
||||
validator.isIdentifier(value[1])) &&
|
||||
!nameSet
|
||||
) {
|
||||
name.value = [value];
|
||||
nameSet = true;
|
||||
} else {
|
||||
throw new InvalidPropertyError('Invalid animation value at ' + formatPosition(value[2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid animation value at ' +
|
||||
formatPosition(value[2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +206,16 @@ function background(property, compactable, validator) {
|
||||
var origin = _wrapDefault('background-origin', property, compactable);
|
||||
var clip = _wrapDefault('background-clip', property, compactable);
|
||||
var color = _wrapDefault('background-color', property, compactable);
|
||||
var components = [image, position, size, repeat, attachment, origin, clip, color];
|
||||
var components = [
|
||||
image,
|
||||
position,
|
||||
size,
|
||||
repeat,
|
||||
attachment,
|
||||
origin,
|
||||
clip,
|
||||
color,
|
||||
];
|
||||
var values = property.value;
|
||||
|
||||
var positionSet = false;
|
||||
@ -152,7 +227,14 @@ function background(property, compactable, validator) {
|
||||
|
||||
if (property.value.length == 1 && property.value[0][1] == 'inherit') {
|
||||
// NOTE: 'inherit' is not a valid value for background-attachment
|
||||
color.value = image.value = repeat.value = position.value = size.value = origin.value = clip.value = property.value;
|
||||
color.value =
|
||||
image.value =
|
||||
repeat.value =
|
||||
position.value =
|
||||
size.value =
|
||||
origin.value =
|
||||
clip.value =
|
||||
property.value;
|
||||
return components;
|
||||
}
|
||||
|
||||
@ -166,7 +248,10 @@ function background(property, compactable, validator) {
|
||||
if (validator.isBackgroundAttachmentKeyword(value[1])) {
|
||||
attachment.value = [value];
|
||||
anyValueSet = true;
|
||||
} else if (validator.isBackgroundClipKeyword(value[1]) || validator.isBackgroundOriginKeyword(value[1])) {
|
||||
} else if (
|
||||
validator.isBackgroundClipKeyword(value[1]) ||
|
||||
validator.isBackgroundOriginKeyword(value[1])
|
||||
) {
|
||||
if (clipSet) {
|
||||
origin.value = [value];
|
||||
originSet = true;
|
||||
@ -183,7 +268,12 @@ function background(property, compactable, validator) {
|
||||
repeatSet = true;
|
||||
}
|
||||
anyValueSet = true;
|
||||
} else if (validator.isBackgroundPositionKeyword(value[1]) || validator.isBackgroundSizeKeyword(value[1]) || validator.isUnit(value[1]) || validator.isDynamicUnit(value[1])) {
|
||||
} else if (
|
||||
validator.isBackgroundPositionKeyword(value[1]) ||
|
||||
validator.isBackgroundSizeKeyword(value[1]) ||
|
||||
validator.isUnit(value[1]) ||
|
||||
validator.isDynamicUnit(value[1])
|
||||
) {
|
||||
if (i > 0) {
|
||||
var previousValue = values[i - 1];
|
||||
|
||||
@ -193,21 +283,23 @@ function background(property, compactable, validator) {
|
||||
size.value = [previousValue, value];
|
||||
i -= 2;
|
||||
} else {
|
||||
if (!positionSet)
|
||||
position.value = [];
|
||||
if (!positionSet) position.value = [];
|
||||
|
||||
position.value.unshift(value);
|
||||
positionSet = true;
|
||||
}
|
||||
} else {
|
||||
if (!positionSet)
|
||||
position.value = [];
|
||||
if (!positionSet) position.value = [];
|
||||
|
||||
position.value.unshift(value);
|
||||
positionSet = true;
|
||||
}
|
||||
anyValueSet = true;
|
||||
} else if ((color.value[0][1] == compactable[color.name].defaultValue || color.value[0][1] == 'none') && (validator.isColor(value[1]) || validator.isPrefixed(value[1]))) {
|
||||
} else if (
|
||||
(color.value[0][1] == compactable[color.name].defaultValue ||
|
||||
color.value[0][1] == 'none') &&
|
||||
(validator.isColor(value[1]) || validator.isPrefixed(value[1]))
|
||||
) {
|
||||
color.value = [value];
|
||||
anyValueSet = true;
|
||||
} else if (validator.isUrl(value[1]) || validator.isFunction(value[1])) {
|
||||
@ -216,11 +308,14 @@ function background(property, compactable, validator) {
|
||||
}
|
||||
}
|
||||
|
||||
if (clipSet && !originSet)
|
||||
origin.value = clip.value.slice(0);
|
||||
if (clipSet && !originSet) origin.value = clip.value.slice(0);
|
||||
|
||||
if (!anyValueSet) {
|
||||
throw new InvalidPropertyError('Invalid background value at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid background value at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
return components;
|
||||
@ -238,24 +333,26 @@ function borderRadius(property, compactable) {
|
||||
}
|
||||
|
||||
if (splitAt === 0 || splitAt === values.length - 1) {
|
||||
throw new InvalidPropertyError('Invalid border-radius value at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid border-radius value at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
var target = _wrapDefault(property.name, property, compactable);
|
||||
target.value = splitAt > -1 ?
|
||||
values.slice(0, splitAt) :
|
||||
values.slice(0);
|
||||
target.value = splitAt > -1 ? values.slice(0, splitAt) : values.slice(0);
|
||||
target.components = fourValues(target, compactable);
|
||||
|
||||
var remainder = _wrapDefault(property.name, property, compactable);
|
||||
remainder.value = splitAt > -1 ?
|
||||
values.slice(splitAt + 1) :
|
||||
values.slice(0);
|
||||
remainder.value = splitAt > -1 ? values.slice(splitAt + 1) : values.slice(0);
|
||||
remainder.components = fourValues(remainder, compactable);
|
||||
|
||||
for (var j = 0; j < 4; j++) {
|
||||
target.components[j].multiplex = true;
|
||||
target.components[j].value = target.components[j].value.concat(remainder.components[j].value);
|
||||
target.components[j].value = target.components[j].value.concat(
|
||||
remainder.components[j].value
|
||||
);
|
||||
}
|
||||
|
||||
return target.components;
|
||||
@ -285,34 +382,77 @@ function font(property, compactable, validator) {
|
||||
var appendableFamilyName = false;
|
||||
|
||||
if (!values[index]) {
|
||||
throw new InvalidPropertyError('Missing font values at ' + formatPosition(property.all[property.position][1][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Missing font values at ' +
|
||||
formatPosition(property.all[property.position][1][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
if (values.length == 1 && values[0][1] == 'inherit') {
|
||||
style.value = variant.value = weight.value = stretch.value = size.value = height.value = family.value = values;
|
||||
style.value =
|
||||
variant.value =
|
||||
weight.value =
|
||||
stretch.value =
|
||||
size.value =
|
||||
height.value =
|
||||
family.value =
|
||||
values;
|
||||
return components;
|
||||
}
|
||||
|
||||
if (values.length == 1 && (validator.isFontKeyword(values[0][1]) || validator.isGlobal(values[0][1]) || validator.isPrefixed(values[0][1]))) {
|
||||
if (
|
||||
values.length == 1 &&
|
||||
(validator.isFontKeyword(values[0][1]) ||
|
||||
validator.isGlobal(values[0][1]) ||
|
||||
validator.isPrefixed(values[0][1]))
|
||||
) {
|
||||
values[0][1] = Marker.INTERNAL + values[0][1];
|
||||
style.value = variant.value = weight.value = stretch.value = size.value = height.value = family.value = values;
|
||||
style.value =
|
||||
variant.value =
|
||||
weight.value =
|
||||
stretch.value =
|
||||
size.value =
|
||||
height.value =
|
||||
family.value =
|
||||
values;
|
||||
return components;
|
||||
}
|
||||
|
||||
if (values.length < 2 || !_anyIsFontSize(values, validator) || !_anyIsFontFamily(values, validator)) {
|
||||
throw new InvalidPropertyError('Invalid font values at ' + formatPosition(property.all[property.position][1][2][0]) + '. Ignoring.');
|
||||
if (
|
||||
values.length < 2 ||
|
||||
!_anyIsFontSize(values, validator) ||
|
||||
!_anyIsFontFamily(values, validator)
|
||||
) {
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid font values at ' +
|
||||
formatPosition(property.all[property.position][1][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
if (values.length > 1 && _anyIsInherit(values)) {
|
||||
throw new InvalidPropertyError('Invalid font values at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid font values at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
// fuzzy match style, variant, weight, and stretch on first elements
|
||||
while (index < fuzzyMatched) {
|
||||
isStretchValid = validator.isFontStretchKeyword(values[index][1]) || validator.isGlobal(values[index][1]);
|
||||
isStyleValid = validator.isFontStyleKeyword(values[index][1]) || validator.isGlobal(values[index][1]);
|
||||
isVariantValid = validator.isFontVariantKeyword(values[index][1]) || validator.isGlobal(values[index][1]);
|
||||
isWeightValid = validator.isFontWeightKeyword(values[index][1]) || validator.isGlobal(values[index][1]);
|
||||
isStretchValid =
|
||||
validator.isFontStretchKeyword(values[index][1]) ||
|
||||
validator.isGlobal(values[index][1]);
|
||||
isStyleValid =
|
||||
validator.isFontStyleKeyword(values[index][1]) ||
|
||||
validator.isGlobal(values[index][1]);
|
||||
isVariantValid =
|
||||
validator.isFontVariantKeyword(values[index][1]) ||
|
||||
validator.isGlobal(values[index][1]);
|
||||
isWeightValid =
|
||||
validator.isFontWeightKeyword(values[index][1]) ||
|
||||
validator.isGlobal(values[index][1]);
|
||||
|
||||
if (isStyleValid && !isStyleSet) {
|
||||
style.value = [values[index]];
|
||||
@ -326,8 +466,17 @@ function font(property, compactable, validator) {
|
||||
} else if (isStretchValid && !isStretchSet) {
|
||||
stretch.value = [values[index]];
|
||||
isStretchSet = true;
|
||||
} else if (isStyleValid && isStyleSet || isVariantValid && isVariantSet || isWeightValid && isWeightSet || isStretchValid && isStretchSet) {
|
||||
throw new InvalidPropertyError('Invalid font style / variant / weight / stretch value at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
} else if (
|
||||
(isStyleValid && isStyleSet) ||
|
||||
(isVariantValid && isVariantSet) ||
|
||||
(isWeightValid && isWeightSet) ||
|
||||
(isStretchValid && isStretchSet)
|
||||
) {
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid font style / variant / weight / stretch value at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -336,20 +485,38 @@ function font(property, compactable, validator) {
|
||||
}
|
||||
|
||||
// now comes font-size ...
|
||||
if (validator.isFontSizeKeyword(values[index][1]) || validator.isUnit(values[index][1]) && !validator.isDynamicUnit(values[index][1])) {
|
||||
if (
|
||||
validator.isFontSizeKeyword(values[index][1]) ||
|
||||
(validator.isUnit(values[index][1]) &&
|
||||
!validator.isDynamicUnit(values[index][1]))
|
||||
) {
|
||||
size.value = [values[index]];
|
||||
isSizeSet = true;
|
||||
index++;
|
||||
} else {
|
||||
throw new InvalidPropertyError('Missing font size at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Missing font size at ' + formatPosition(values[0][2][0]) + '. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
if (!values[index]) {
|
||||
throw new InvalidPropertyError('Missing font family at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Missing font family at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
// ... and perhaps line-height
|
||||
if (isSizeSet && values[index] && values[index][1] == Marker.FORWARD_SLASH && values[index + 1] && (validator.isLineHeightKeyword(values[index + 1][1]) || validator.isUnit(values[index + 1][1]) || validator.isNumber(values[index + 1][1]))) {
|
||||
if (
|
||||
isSizeSet &&
|
||||
values[index] &&
|
||||
values[index][1] == Marker.FORWARD_SLASH &&
|
||||
values[index + 1] &&
|
||||
(validator.isLineHeightKeyword(values[index + 1][1]) ||
|
||||
validator.isUnit(values[index + 1][1]) ||
|
||||
validator.isNumber(values[index + 1][1]))
|
||||
) {
|
||||
height.value = [values[index + 1]];
|
||||
index++;
|
||||
index++;
|
||||
@ -363,7 +530,8 @@ function font(property, compactable, validator) {
|
||||
appendableFamilyName = false;
|
||||
} else {
|
||||
if (appendableFamilyName) {
|
||||
family.value[family.value.length - 1][1] += Marker.SPACE + values[index][1];
|
||||
family.value[family.value.length - 1][1] +=
|
||||
Marker.SPACE + values[index][1];
|
||||
} else {
|
||||
family.value.push(values[index]);
|
||||
}
|
||||
@ -375,7 +543,11 @@ function font(property, compactable, validator) {
|
||||
}
|
||||
|
||||
if (family.value.length === 0) {
|
||||
throw new InvalidPropertyError('Missing font family at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Missing font family at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
return components;
|
||||
@ -388,7 +560,11 @@ function _anyIsFontSize(values, validator) {
|
||||
for (i = 0, l = values.length; i < l; i++) {
|
||||
value = values[i];
|
||||
|
||||
if (validator.isFontSizeKeyword(value[1]) || validator.isUnit(value[1]) && !validator.isDynamicUnit(value[1]) || validator.isFunction(value[1])) {
|
||||
if (
|
||||
validator.isFontSizeKeyword(value[1]) ||
|
||||
(validator.isUnit(value[1]) && !validator.isDynamicUnit(value[1])) ||
|
||||
validator.isFunction(value[1])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -416,20 +592,16 @@ function fourValues(property, compactable) {
|
||||
var components = [];
|
||||
var value = property.value;
|
||||
|
||||
if (value.length < 1)
|
||||
return [];
|
||||
if (value.length < 1) return [];
|
||||
|
||||
if (value.length < 2)
|
||||
value[1] = value[0].slice(0);
|
||||
if (value.length < 3)
|
||||
value[2] = value[0].slice(0);
|
||||
if (value.length < 4)
|
||||
value[3] = value[1].slice(0);
|
||||
if (value.length < 2) value[1] = value[0].slice(0);
|
||||
if (value.length < 3) value[2] = value[0].slice(0);
|
||||
if (value.length < 4) value[3] = value[1].slice(0);
|
||||
|
||||
for (var i = componentNames.length - 1; i >= 0; i--) {
|
||||
var component = wrapSingle([
|
||||
Token.PROPERTY,
|
||||
[Token.PROPERTY_NAME, componentNames[i]]
|
||||
[Token.PROPERTY_NAME, componentNames[i]],
|
||||
]);
|
||||
component.value = [value[i]];
|
||||
components.unshift(component);
|
||||
@ -446,8 +618,7 @@ function multiplex(splitWith) {
|
||||
|
||||
// find split commas
|
||||
for (i = 0, l = values.length; i < l; i++) {
|
||||
if (values[i][1] == ',')
|
||||
splitsAt.push(i);
|
||||
if (values[i][1] == ',') splitsAt.push(i);
|
||||
}
|
||||
|
||||
if (splitsAt.length === 0)
|
||||
@ -474,7 +645,10 @@ function multiplex(splitWith) {
|
||||
|
||||
for (j = 1, m = splitComponents.length; j < m; j++) {
|
||||
components[i].value.push([Token.PROPERTY_VALUE, Marker.COMMA]);
|
||||
Array.prototype.push.apply(components[i].value, splitComponents[j][i].value);
|
||||
Array.prototype.push.apply(
|
||||
components[i].value,
|
||||
splitComponents[j][i].value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -516,7 +690,11 @@ function listStyle(property, compactable, validator) {
|
||||
}
|
||||
|
||||
// ... and what's left is a `type`
|
||||
if (values.length > 0 && (validator.isListStyleTypeKeyword(values[0][1]) || validator.isIdentifier(values[0][1]))) {
|
||||
if (
|
||||
values.length > 0 &&
|
||||
(validator.isListStyleTypeKeyword(values[0][1]) ||
|
||||
validator.isIdentifier(values[0][1]))
|
||||
) {
|
||||
type.value = [values[0]];
|
||||
}
|
||||
|
||||
@ -525,8 +703,16 @@ function listStyle(property, compactable, validator) {
|
||||
|
||||
function transition(property, compactable, validator) {
|
||||
var prop = _wrapDefault(property.name + '-property', property, compactable);
|
||||
var duration = _wrapDefault(property.name + '-duration', property, compactable);
|
||||
var timing = _wrapDefault(property.name + '-timing-function', property, compactable);
|
||||
var duration = _wrapDefault(
|
||||
property.name + '-duration',
|
||||
property,
|
||||
compactable
|
||||
);
|
||||
var timing = _wrapDefault(
|
||||
property.name + '-timing-function',
|
||||
property,
|
||||
compactable
|
||||
);
|
||||
var delay = _wrapDefault(property.name + '-delay', property, compactable);
|
||||
var components = [prop, duration, timing, delay];
|
||||
var values = property.value;
|
||||
@ -544,7 +730,11 @@ function transition(property, compactable, validator) {
|
||||
}
|
||||
|
||||
if (values.length > 1 && _anyIsInherit(values)) {
|
||||
throw new InvalidPropertyError('Invalid animation values at ' + formatPosition(values[0][2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid animation values at ' +
|
||||
formatPosition(values[0][2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
|
||||
for (i = 0, l = values.length; i < l; i++) {
|
||||
@ -556,14 +746,21 @@ function transition(property, compactable, validator) {
|
||||
} else if (validator.isTime(value[1]) && !delaySet) {
|
||||
delay.value = [value];
|
||||
delaySet = true;
|
||||
} else if ((validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) && !timingSet) {
|
||||
} else if (
|
||||
(validator.isGlobal(value[1]) || validator.isTimingFunction(value[1])) &&
|
||||
!timingSet
|
||||
) {
|
||||
timing.value = [value];
|
||||
timingSet = true;
|
||||
} else if (validator.isIdentifier(value[1]) && !propSet) {
|
||||
prop.value = [value];
|
||||
propSet = true;
|
||||
} else {
|
||||
throw new InvalidPropertyError('Invalid animation value at ' + formatPosition(value[2][0]) + '. Ignoring.');
|
||||
throw new InvalidPropertyError(
|
||||
'Invalid animation value at ' +
|
||||
formatPosition(value[2][0]) +
|
||||
'. Ignoring.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,23 +772,25 @@ function widthStyleColor(property, compactable, validator) {
|
||||
var components = [
|
||||
_wrapDefault(descriptor.components[0], property, compactable),
|
||||
_wrapDefault(descriptor.components[1], property, compactable),
|
||||
_wrapDefault(descriptor.components[2], property, compactable)
|
||||
_wrapDefault(descriptor.components[2], property, compactable),
|
||||
];
|
||||
var color, style, width;
|
||||
|
||||
for (var i = 0; i < 3; i++) {
|
||||
var component = components[i];
|
||||
|
||||
if (component.name.indexOf('color') > 0)
|
||||
color = component;
|
||||
else if (component.name.indexOf('style') > 0)
|
||||
style = component;
|
||||
else
|
||||
width = component;
|
||||
if (component.name.indexOf('color') > 0) color = component;
|
||||
else if (component.name.indexOf('style') > 0) style = component;
|
||||
else width = component;
|
||||
}
|
||||
|
||||
if ((property.value.length == 1 && property.value[0][1] == 'inherit') ||
|
||||
(property.value.length == 3 && property.value[0][1] == 'inherit' && property.value[1][1] == 'inherit' && property.value[2][1] == 'inherit')) {
|
||||
if (
|
||||
(property.value.length == 1 && property.value[0][1] == 'inherit') ||
|
||||
(property.value.length == 3 &&
|
||||
property.value[0][1] == 'inherit' &&
|
||||
property.value[1][1] == 'inherit' &&
|
||||
property.value[2][1] == 'inherit')
|
||||
) {
|
||||
color.value = style.value = width.value = [property.value[0]];
|
||||
return components;
|
||||
}
|
||||
@ -604,7 +803,13 @@ function widthStyleColor(property, compactable, validator) {
|
||||
|
||||
if (values.length > 0) {
|
||||
matches = values.filter(_widthFilter(validator));
|
||||
match = matches.length > 1 && (matches[0][1] == 'none' || matches[0][1] == 'auto') ? matches[1] : matches[0];
|
||||
match =
|
||||
(
|
||||
matches.length > 1 &&
|
||||
(matches[0][1] == 'none' || matches[0][1] == 'auto')
|
||||
) ?
|
||||
matches[1]
|
||||
: matches[0];
|
||||
if (match) {
|
||||
width.value = [match];
|
||||
values.splice(values.indexOf(match), 1);
|
||||
@ -640,5 +845,5 @@ module.exports = {
|
||||
listStyle: listStyle,
|
||||
multiplex: multiplex,
|
||||
outline: widthStyleColor,
|
||||
transition: transition
|
||||
transition: transition,
|
||||
};
|
||||
|
Reference in New Issue
Block a user