Skip to content

Commit

Permalink
Merge pull request #2181 from SomMeri/case-insensite-units-2096
Browse files Browse the repository at this point in the history
Case insensitive units parsing and comparison
  • Loading branch information
lukeapage committed Sep 5, 2014
2 parents 08e2fc4 + 4a49c63 commit 2942b9d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/less/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ less.Parser = function Parser(env) {
return;
}

value = $re(/^([+-]?\d*\.?\d+)(%|[a-z]+)?/);
value = $re(/^([+-]?\d*\.?\d+)(%|[a-zA-Z]+)?/);
if (value) {
return new(tree.Dimension)(value[1], value[2]);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/less/tree/dimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ tree.Unit.prototype = {
},

is: function (unitString) {
return this.toString() === unitString;
return this.toString().toUpperCase() === unitString.toUpperCase();
},

isLength: function () {
Expand Down
2 changes: 2 additions & 0 deletions test/css/functions.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
percent: true;
em: true;
cat: true;
case-insensitive-1: true;
case-insensitive-2: true;
}
#alpha {
alpha: rgba(153, 94, 51, 0.6);
Expand Down
2 changes: 2 additions & 0 deletions test/less/functions.less
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@
percent: ispercentage(32%);
em: isem(32em);
cat: isunit(32cat, cat);
case-insensitive-1: isunit(32CAT, cat);
case-insensitive-2: isunit(32px, PX);
}
}

Expand Down

0 comments on commit 2942b9d

Please sign in to comment.