diff --git a/History.md b/History.md index bbffc98c..485a2d61 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,8 @@ +[5.2.4 / 2022-01-28](https://github.com/clean-css/clean-css/compare/v5.2.3...v5.2.4) +================== + +* Fixed issue [#1196](https://github.com/clean-css/clean-css/issues/1196) - correctly parse variables & comments mix. + [5.2.3 / 2022-01-26](https://github.com/clean-css/clean-css/compare/v5.2.2...v5.2.3) ================== diff --git a/lib/tokenizer/tokenize.js b/lib/tokenizer/tokenize.js index 62ebec10..e9e7c663 100644 --- a/lib/tokenizer/tokenize.js +++ b/lib/tokenizer/tokenize.js @@ -380,6 +380,7 @@ function intoTokens(source, externalContext, internalContext, isNested) { seekingValue = false; buffer = []; isBufferEmpty = true; + isVariable = false; } else if (character == Marker.SEMICOLON && level == Level.RULE && propertyToken && isBufferEmpty && isVariable && !propertyToken[2]) { // semicolon after empty variable value at rule level, e.g. a{--color: ;<-- propertyToken.push([Token.PROPERTY_VALUE, ' ', [originalMetadata(metadata, ' ', externalContext)]]); diff --git a/package-lock.json b/package-lock.json index 75fc7674..a96afc18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "clean-css", - "version": "5.2.3", + "version": "5.2.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 19c8626f..56135626 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clean-css", - "version": "5.2.3", + "version": "5.2.4", "author": "Jakub Pawlowicz ", "description": "A well-tested CSS minifier", "license": "MIT", diff --git a/test/integration-test.js b/test/integration-test.js index 14123be2..6f262fb7 100644 --- a/test/integration-test.js +++ b/test/integration-test.js @@ -2702,6 +2702,14 @@ vows.describe('integration tests') 'comments #3': [ '.test {--tw-blur: var(--tw-empty,/*!*/ /*!*/);color:hsl(0, 1%, 99%)}', '.test{--tw-blur:var(--tw-empty,/*!*/ /*!*/);color:#fcfcfc}' + ], + 'comments #4': [ + ':root{/* Site container */--a:20px;/* Z indices for modals and dialogs */--foo:5050}.bar{z-index:5050;z-index:var(--foo)}', + ':root{--a:20px;--foo:5050}.bar{z-index:5050;z-index:var(--foo)}' + ], + 'comments #5': [ + ':host{/* this will stay */--this_will_stay: 1;/* this will disappear */--this_will_disappear: 1;/* this will also disappear */--this_will_also_disappear: 1;--this_will_stay_aswell: 1;--this_will_stay_too: 1;width: 1px;height: 1px}', + ':host{--this_will_stay:1;--this_will_disappear:1;--this_will_also_disappear:1;--this_will_stay_aswell:1;--this_will_stay_too:1;width:1px;height:1px}' ] }, { level: 2 }) ) diff --git a/test/tokenizer/tokenize-test.js b/test/tokenizer/tokenize-test.js index 5208805b..180cba58 100644 --- a/test/tokenizer/tokenize-test.js +++ b/test/tokenizer/tokenize-test.js @@ -3260,6 +3260,90 @@ vows.describe(tokenize) ] ] ], + 'variable declarations with comments inside them 2': [ + 'a{--test1:1;/*!*/--test2:2;/*!*/--test3:3;}', + [ + [ + 'rule', + [ + [ + 'rule-scope', + 'a', + [ + [1, 0, undefined] + ] + ] + ], + [ + [ + 'property', + [ + 'property-name', + '--test1', + [ + [1, 2, undefined] + ] + ], + [ + 'property-value', + '1', + [ + [1, 10, undefined] + ] + ] + ], + [ + 'comment', + '/*!*/', + [ + [ 1, 12, undefined ] + ] + ], + [ + 'property', + [ + 'property-name', + '--test2', + [ + [ 1, 17, undefined ] + ] + ], + [ + 'property-value', + '2', + [ + [ 1, 25, undefined ] + ] + ] + ], + [ + 'comment', + '/*!*/', + [ + [ 1, 27, undefined ] + ] + ], + [ + 'property', + [ + 'property-name', + '--test3', + [ + [ 1, 32, undefined ] + ] + ], + [ + 'property-value', + '3', + [ + [ 1, 40, undefined ] + ] + ] + ] + ] + ] + ] + ], '_:-ms-lang flat block': [ '_:-ms-lang(x),@-ms-viewport{color:red}', [