Skip to content

Commit

Permalink
Fixes #1043 - calc fallback removed within other function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubpawlowicz committed Jan 20, 2021
1 parent 9a68eed commit c873d7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Drops support for Node.js 6 & 8 to support last 3 Node.js releases: 10, 12, and 14.
* Fixed issue [#889](https://github.com/jakubpawlowicz/clean-css/issues/889) - whitelisted level 1 optimizations.
* Fixed issue [#1021](https://github.com/jakubpawlowicz/clean-css/issues/1021) - allow one- and two-letter property names.
* Fixed issue [#1043](https://github.com/jakubpawlowicz/clean-css/issues/1043) - `calc` fallback removed within other function.
* Fixed issue [#1055](https://github.com/jakubpawlowicz/clean-css/issues/1055) - supports 4- and 8-character hex with alpha color notation.
* Fixed issue [#1057](https://github.com/jakubpawlowicz/clean-css/issues/1057) - level 2 optimizations and quoted font family name.
* Fixed issue [#1073](https://github.com/jakubpawlowicz/clean-css/issues/1073) - adds support for non-standard `rpx` units.
Expand Down
9 changes: 8 additions & 1 deletion lib/optimizer/configuration/can-override.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ function areSameFunction(validator, value1, value2) {
var function1Name = value1.substring(0, value1.indexOf('('));
var function2Name = value2.substring(0, value2.indexOf('('));

return function1Name === function2Name;
var function1Value = value1.substring(function1Name.length + 1, value1.length - 1);
var function2Value = value2.substring(function2Name.length + 1, value2.length - 1);

if (validator.isFunction(function1Value) || validator.isFunction(function2Value)) {
return function1Name === function2Name && areSameFunction(validator, function1Value, function2Value);
} else {
return function1Name === function2Name;
}
}

function backgroundPosition(validator, value1, value2) {
Expand Down
4 changes: 4 additions & 0 deletions test/optimizer/level-2/optimize-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ vows.describe('level 2 optimizer')
'overrides hex color only': [
'.block{color:#696969;color:rgba(68,68,68,0.8);color:#444c}',
'.block{color:rgba(68,68,68,.8);color:#444c}'
],
'skips merging when function withing function is used for compatibility reasons': [
'.block{transform:translateX(-107%);transform:translateX(calc(-100% - 20px))}',
'.block{transform:translateX(-107%);transform:translateX(calc(-100% - 20px))}'
]
}, { level: 2 })
)
Expand Down

0 comments on commit c873d7d

Please sign in to comment.