From: Timur Kristóf Date: Fri, 28 Feb 2014 15:27:57 +0000 (+0100) Subject: Some final touches and more tests X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=23a17b2e2a156044b99165fe1e2446e1a2076ac0;p=clean-css.git Some final touches and more tests --- diff --git a/lib/properties/processable.js b/lib/properties/processable.js index 91e00e0a..8c9a7ac2 100644 --- a/lib/properties/processable.js +++ b/lib/properties/processable.js @@ -85,7 +85,6 @@ module.exports = (function () { // Functions with the same name can override each other; same values can override each other return canOverride.sameFunctionOrValue(val1, val2); } - // TODO: add more }; canOverride = Object.freeze(canOverride); diff --git a/lib/properties/shorthand-compactor.js b/lib/properties/shorthand-compactor.js index e1167264..177d7899 100644 --- a/lib/properties/shorthand-compactor.js +++ b/lib/properties/shorthand-compactor.js @@ -132,7 +132,6 @@ module.exports = (function () { var compactedLength = Token.getDetokenizedLength(compacted); var authenticLength = Token.getDetokenizedLength(realComponents); - // TODO: unit test for hacked value if (realComponents.length === processable[prop].components.length || compactedLength < authenticLength || components.some(isHackValue)) { compacted[0].isShorthand = true; compacted[0].components = processable[prop].breakUp(compacted[0]); @@ -183,15 +182,16 @@ module.exports = (function () { // Found an instance of a full shorthand // NOTE: we should NOT mix together tokens that come before and after the shorthands - if (token.isImportant === isImportant) { + if (token.isImportant === isImportant || (token.isImportant && !isImportant)) { // Try to compact what we've found so far while (compactSoFar(token.prop)) { } // Reset initSoFar(token.prop, token, true); } - // TODO: test case for shorthanding boundaries - // TODO: what happens if the importantness of the shorthand isn't the same as isImportant parameter? + // TODO: when the old optimizer is removed, take care of this corner case: + // div{background-color:#111;background-image:url(aaa);background:linear-gradient(aaa);background-repeat:no-repeat;background-position:1px 2px;background-attachment:scroll} + // -> should not be shorthanded / minified at all because the result wouldn't be equivalent to the original in any browser } else if (processable[token.prop].componentOf) { // Found a component of a shorthand diff --git a/lib/properties/validator.js b/lib/properties/validator.js index b9f4487a..5ffce7f3 100644 --- a/lib/properties/validator.js +++ b/lib/properties/validator.js @@ -22,11 +22,10 @@ module.exports = (function () { return s.length > 0 && s.indexOf('hsla(') === 0 && s.indexOf(')') === s.length - 1; }, isValidNamedColor: function (s) { - // TODO: we don't really check if it's a valid color value, but allow any letters in it + // We don't really check if it's a valid color value, but allow any letters in it return s !== 'auto' && (s === 'transparent' || s === 'inherit' || /^[a-zA-Z]+$/.test(s)); }, isValidColor: function (s) { - // http://www.w3schools.com/cssref/css_colors_legal.asp return validator.isValidNamedColor(s) || validator.isValidHexColor(s) || validator.isValidRgbaColor(s) || validator.isValidHslaColor(s); }, isValidUrl: function (s) { diff --git a/test/unit-test.js b/test/unit-test.js index 4f773190..d5800550 100644 --- a/test/unit-test.js +++ b/test/unit-test.js @@ -1630,6 +1630,10 @@ title']{display:block}", 'should NOT merge outline with inherited outline-width': [ 'a{outline:0;outline-width:inherit}', 'a{outline:0;outline-width:inherit}' + ], + 'should merge list-style with list-style-type': [ + 'li{list-style-type:disc;list-style:inside}', + 'li{list-style:inside}' ] }), 'shorthand properties': cssContext({ @@ -1660,6 +1664,14 @@ title']{display:block}", 'shorthand border-radius': [ '.t{border-top-left-radius:7px;border-bottom-right-radius:6px;border-bottom-left-radius:5px;border-top-right-radius:3px}', '.t{border-radius:7px 3px 6px 5px}' + ], + 'shorthand list-style #1': [ + '.t{list-style-type:circle;list-style-position:outside;list-style-image:url(aaa)}', + '.t{list-style:circle url(aaa)}' + ], + 'shorthand list-style #2': [ + '.t{list-style-image:url(aaa);list-style-type:circle;list-style-position:inside}', + '.t{list-style:circle inside url(aaa)}' ] }), 'care about understandability of shorthand components': cssContext({