Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiplication of mixed units to preserve the first unit
Match the internal unit handling for math operations to the Less.js 2.5.3 logic. The following part of lessjs-2.5.3/less/variables.less fixture was producing incorrect output: ``` div-px-1: (@px / @em); div-px-2: ((@px / @em) / @cm); sub-px-1: (@px - @em); sub-cm-1: (@cm - (@px - @em)); mul-px-1: (@px * @em); mul-em-1: (@em * @px); mul-em-2: ((@em * @px) * @cm); mul-cm-1: (@cm * (@em * @px)); add-px-1: (@px + @em); add-px-2: ((@px + @em) + @cm); mul-px-2: ((1 * @px) * @cm); mul-px-3: ((@px * 1) * @cm); ``` Without this patch: ``` Change-Id: Ia53cc26232da40e17c8e9829284ca4669c68f4af --- actual +++ /less.php/test/Fixtures/lessjs-2.5.3/css/variables.css @@ -56,13 +56,13 @@ div-px-1: 10px; div-px-2: 1px; sub-px-1: 12.6px; - sub-cm-1: 9.666625420000001cm; + sub-cm-1: 9.666625cm; - mul-px-1: 19.6em; + mul-px-1: 19.6px; mul-em-1: 19.6em; - mul-em-2: 196cm; + mul-em-2: 196em; mul-cm-1: 196cm; add-px-1: 15.4px; - add-px-2: 393.35323207px; + add-px-2: 393.35275591px; - mul-px-2: 140cm; + mul-px-2: 140px; - mul-px-3: 140cm; + mul-px-3: 140px; ``` With this patch: ``` --- actual +++ /less.php/test/Fixtures/lessjs-2.5.3/css/variables.css @@ -56,13 +56,13 @@ div-px-1: 10px; div-px-2: 1px; sub-px-1: 12.6px; - sub-cm-1: 9.666625420000001cm; + sub-cm-1: 9.666625cm; mul-px-1: 19.6px; mul-em-1: 19.6em; mul-em-2: 196em; mul-cm-1: 196cm; add-px-1: 15.4px; - add-px-2: 393.35323207px; + add-px-2: 393.35275591px; mul-px-2: 140px; mul-px-3: 140px; } ``` Bug: T362341 Change-Id: Ia9349fd8d7c3f08962fb5dd3af0d2f57cf78ea97
- Loading branch information