diff options
Diffstat (limited to 'node_modules/clean-css/lib/optimizer/level-2/break-up.js')
-rw-r--r-- | node_modules/clean-css/lib/optimizer/level-2/break-up.js | 86 |
1 files changed, 84 insertions, 2 deletions
diff --git a/node_modules/clean-css/lib/optimizer/level-2/break-up.js b/node_modules/clean-css/lib/optimizer/level-2/break-up.js index b48ccf23d..5301cb898 100644 --- a/node_modules/clean-css/lib/optimizer/level-2/break-up.js +++ b/node_modules/clean-css/lib/optimizer/level-2/break-up.js @@ -105,7 +105,7 @@ function animation(property, compactable, validator) { } else if (validator.isTime(value[1]) && !delaySet) { delay.value = [value]; delaySet = true; - } else if ((validator.isGlobal(value[1]) || validator.isAnimationTimingFunction(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) { @@ -299,6 +299,10 @@ function font(property, compactable, validator) { 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 > 1 && _anyIsInherit(values)) { throw new InvalidPropertyError('Invalid font values at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); } @@ -377,6 +381,36 @@ function font(property, compactable, validator) { return components; } +function _anyIsFontSize(values, validator) { + var value; + var i, l; + + 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])) { + return true; + } + } + + return false; +} + +function _anyIsFontFamily(values, validator) { + var value; + var i, l; + + for (i = 0, l = values.length; i < l; i++) { + value = values[i]; + + if (validator.isIdentifier(value[1])) { + return true; + } + } + + return false; +} + function fourValues(property, compactable) { var componentNames = compactable[property.name].components; var components = []; @@ -489,6 +523,53 @@ function listStyle(property, compactable, validator) { return components; } +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 delay = _wrapDefault(property.name + '-delay', property, compactable); + var components = [prop, duration, timing, delay]; + var values = property.value; + var value; + var durationSet = false; + var delaySet = false; + var propSet = false; + var timingSet = false; + var i; + var l; + + if (property.value.length == 1 && property.value[0][1] == 'inherit') { + prop.value = duration.value = timing.value = delay.value = property.value; + return components; + } + + if (values.length > 1 && _anyIsInherit(values)) { + throw new InvalidPropertyError('Invalid animation values at ' + formatPosition(values[0][2][0]) + '. Ignoring.'); + } + + for (i = 0, l = values.length; i < l; i++) { + value = values[i]; + + if (validator.isTime(value[1]) && !durationSet) { + duration.value = [value]; + durationSet = true; + } else if (validator.isTime(value[1]) && !delaySet) { + delay.value = [value]; + delaySet = true; + } 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.'); + } + } + + return components; +} + function widthStyleColor(property, compactable, validator) { var descriptor = compactable[property.name]; var components = [ @@ -558,5 +639,6 @@ module.exports = { fourValues: fourValues, listStyle: listStyle, multiplex: multiplex, - outline: widthStyleColor + outline: widthStyleColor, + transition: transition }; |