Skip to content

Commit

Permalink
Fixes stylus#834 Percentage calculation not used when value is expres…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
tonistiigi committed Oct 23, 2012
1 parent b4c438d commit dd3c3f7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/nodes/unit.js
Expand Up @@ -92,11 +92,12 @@ Unit.prototype.operate = function(op, right){


// operate // operate
if (this.shouldCoerce(op)) { if (this.shouldCoerce(op)) {
right = right.first;
// percentages // percentages
if (('-' == op || '+' == op) && '%' == right.type) { if (('-' == op || '+' == op) && '%' == right.type) {
right.val = this.val * (right.val / 100); right.val = this.val * (right.val / 100);
} else { } else {
right = this.coerce(right.first); right = this.coerce(right);
} }


switch (op) { switch (op) {
Expand Down
6 changes: 6 additions & 0 deletions test/cases/regression.834.css
@@ -0,0 +1,6 @@
.grid {
width: 45%;
}
.grid {
width: 45%;
}
8 changes: 8 additions & 0 deletions test/cases/regression.834.styl
@@ -0,0 +1,8 @@
grid(x)
width: 50% - x

.grid
grid(10%)

.grid
grid 10%

0 comments on commit dd3c3f7

Please sign in to comment.