diff --git a/History.md b/History.md index 9b8089e5..8336afd2 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,9 @@ +[5.3.1 / 2022-07-13](https://github.com/clean-css/clean-css/compare/v5.3.0...v5.3.1) +================== + +* Fixed issue [#1218](https://github.com/clean-css/clean-css/issues/1218) - double hyphen in at-rule breaks parsing. +* Fixed issue [#1220](https://github.com/clean-css/clean-css/issues/1220) - adds optimization for nth-* rules. + [5.3.0 / 2022-03-31](https://github.com/clean-css/clean-css/compare/v5.2.3...v5.3.0) ================== diff --git a/lib/optimizer/level-1/tidy-rules.js b/lib/optimizer/level-1/tidy-rules.js index c0399886..bb467e29 100644 --- a/lib/optimizer/level-1/tidy-rules.js +++ b/lib/optimizer/level-1/tidy-rules.js @@ -193,7 +193,13 @@ function replacePseudoClasses(value) { .replace('nth-of-type(even)', 'nth-of-type(2n)') .replace('nth-child(even)', 'nth-child(2n)') .replace('nth-of-type(2n+1)', 'nth-of-type(odd)') - .replace('nth-child(2n+1)', 'nth-child(odd)'); + .replace('nth-child(2n+1)', 'nth-child(odd)') + .replace('nth-last-child(1)', 'last-child') + .replace('nth-last-of-type(1)', 'last-of-type') + .replace('nth-last-of-type(even)', 'nth-last-of-type(2n)') + .replace('nth-last-child(even)', 'nth-last-child(2n)') + .replace('nth-last-of-type(2n+1)', 'nth-last-of-type(odd)') + .replace('nth-last-child(2n+1)', 'nth-last-child(odd)'); } function tidyRules(rules, removeUnsupported, adjacentSpace, format, warnings) { diff --git a/lib/tokenizer/tokenize.js b/lib/tokenizer/tokenize.js index 07575b8f..0331012c 100644 --- a/lib/tokenizer/tokenize.js +++ b/lib/tokenizer/tokenize.js @@ -373,6 +373,7 @@ function intoTokens(source, externalContext, internalContext, isNested) { position.index++; buffer = []; isBufferEmpty = true; + isVariable = false; ruleToken[2] = intoTokens(source, externalContext, internalContext, true); ruleToken = null; diff --git a/package-lock.json b/package-lock.json index f3a2242b..ab298be1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "clean-css", - "version": "5.3.0", + "version": "5.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7ac4ead2..686ce862 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clean-css", - "version": "5.3.0", + "version": "5.3.1", "author": "Jakub Pawlowicz ", "description": "A well-tested CSS minifier", "license": "MIT", diff --git a/test/optimizer/level-1/optimize-test.js b/test/optimizer/level-1/optimize-test.js index 4667498d..0723c0dc 100644 --- a/test/optimizer/level-1/optimize-test.js +++ b/test/optimizer/level-1/optimize-test.js @@ -74,6 +74,30 @@ vows.describe('level 1 optimizations') '.block:nth-child(2n+1){color:red}', '.block:nth-child(odd){color:red}' ], + 'pseudo classes - nth-last-child(1) to last-child': [ + '.block:nth-last-child(1){color:red}', + '.block:last-child{color:red}' + ], + 'pseudo classes - nth-last-of-type(1) to last-of-type': [ + '.block:nth-last-of-type(1){color:red}', + '.block:last-of-type{color:red}' + ], + 'pseudo classes - nth-last-of-type(even) to nth-last-of-type(2n)': [ + '.block:nth-last-of-type(even){color:red}', + '.block:nth-last-of-type(2n){color:red}' + ], + 'pseudo classes - nth-last-child(even) to nth-last-child(2n)': [ + '.block:nth-last-child(even){color:red}', + '.block:nth-last-child(2n){color:red}' + ], + 'pseudo classes - nth-last-of-type(2n+1) to nth-last-of-type(odd)': [ + '.block:nth-last-of-type(2n+1){color:red}', + '.block:nth-last-of-type(odd){color:red}' + ], + 'pseudo classes - nth-last-child(2n+1) to nth-last-child(odd)': [ + '.block:nth-last-child(2n+1){color:red}', + '.block:nth-last-child(odd){color:red}' + ], 'tabs': [ 'div\t\t{color:red}', 'div{color:red}'