Skip to content

Commit

Permalink
Hotfix for #389
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyganch committed Jun 9, 2015
1 parent df7cf02 commit d4b4375
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/options/unitless-zero.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,21 @@ module.exports = {
value.remove(1);
}
} else if (value.is('percentage')) {
var number = value.first('number').content;
// XXX(tonyganch): There is a bug in Gonzales when in Less,
// percentage's content is not wrapped as an array but actually
// type of node's content is object. This bug has already been
// fixed in newer versions of Gonzales so the issue should be
// gone after update of dependencies and csscomb@4.0 release.
// This hack is here as a hotfix for csscomb@3.1 and must be
// removed once csscom@4.0 is released. See #389.
var number;
if (!Array.isArray(value.content) &&
value.content.is('number')) {
number = value.content;
} else {
number = value.first('number').content;
}

if (number[0] === '0') {
value.type = 'number';
value.content = number;
Expand Down
4 changes: 4 additions & 0 deletions test/options/unitless-zero-less/issue-389.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.test
{
width: 100%;
}
6 changes: 6 additions & 0 deletions test/options/unitless-zero-less/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
describe('options/unitless-zero (less)', function() {
it('Issue 389', function() {
this.comb.configure({ 'unitless-zero': true });
this.shouldBeEqual('issue-389.less');
});
});

0 comments on commit d4b4375

Please sign in to comment.