diff --git a/History.md b/History.md index f8c0ed685..a46a6f3f7 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +[4.1.2 / 2017-xx-xx](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.1...4.1) +================== + +* Fixed issue [#940](https://github.com/jakubpawlowicz/clean-css/issues/940) - handling more `font` keywords. + [4.1.1 / 2017-05-08](https://github.com/jakubpawlowicz/clean-css/compare/v4.1.0...v4.1.1) ================== diff --git a/lib/optimizer/level-2/break-up.js b/lib/optimizer/level-2/break-up.js index 45d5c3127..b6c961058 100644 --- a/lib/optimizer/level-2/break-up.js +++ b/lib/optimizer/level-2/break-up.js @@ -288,13 +288,13 @@ function font(property, compactable, validator) { throw new InvalidPropertyError('Missing font values at ' + formatPosition(property.all[property.position][1][2][0]) + '. Ignoring.'); } - if (values.length == 1 && (validator.isFontKeyword(values[0][1]) || validator.isPrefixed(values[0][1]))) { - values[0][1] = Marker.INTERNAL + values[0][1]; + if (values.length == 1 && values[0][1] == 'inherit') { style.value = variant.value = weight.value = stretch.value = size.value = height.value = family.value = values; return components; } - if (values.length == 1 && values[0][1] == 'inherit') { + 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; return components; } diff --git a/lib/optimizer/validator.js b/lib/optimizer/validator.js index 820f84036..cfccd0f9d 100644 --- a/lib/optimizer/validator.js +++ b/lib/optimizer/validator.js @@ -180,7 +180,8 @@ var Keywords = { 'menu', 'message-box', 'small-caption', - 'status-bar' + 'status-bar', + 'unset' ], 'font-size': [ 'large', diff --git a/test/optimizer/level-2/break-up-test.js b/test/optimizer/level-2/break-up-test.js index 842dc8fea..514f25b88 100644 --- a/test/optimizer/level-2/break-up-test.js +++ b/test/optimizer/level-2/break-up-test.js @@ -1475,6 +1475,48 @@ vows.describe(breakUp) assert.deepEqual(components[6].value, [['property-value', '-clean-css-icon']]); } }, + 'unset font': { + 'topic': function () { + return _breakUp([ + [ + 'property', + ['property-name', 'font'], + ['property-value', 'unset'] + ] + ]); + }, + 'has 7 components': function (components) { + assert.lengthOf(components, 7); + }, + 'has font-style': function (components) { + assert.equal(components[0].name, 'font-style'); + assert.deepEqual(components[0].value, [['property-value', '-clean-css-unset']]); + }, + 'has font-variant': function (components) { + assert.equal(components[1].name, 'font-variant'); + assert.deepEqual(components[1].value, [['property-value', '-clean-css-unset']]); + }, + 'has font-weight': function (components) { + assert.equal(components[2].name, 'font-weight'); + assert.deepEqual(components[2].value, [['property-value', '-clean-css-unset']]); + }, + 'has font-stretch': function (components) { + assert.equal(components[3].name, 'font-stretch'); + assert.deepEqual(components[3].value, [['property-value', '-clean-css-unset']]); + }, + 'has font-size': function (components) { + assert.equal(components[4].name, 'font-size'); + assert.deepEqual(components[4].value, [['property-value', '-clean-css-unset']]); + }, + 'has line-height': function (components) { + assert.equal(components[5].name, 'line-height'); + assert.deepEqual(components[5].value, [['property-value', '-clean-css-unset']]); + }, + 'has font-family': function (components) { + assert.equal(components[6].name, 'font-family'); + assert.deepEqual(components[6].value, [['property-value', '-clean-css-unset']]); + } + }, 'system font with vendor prefix': { 'topic': function () { return _breakUp([