-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2644 from SomMeri/percentage-should-error-on-nan-…
…2553 `percentage` function should throw error if result would be `NaN`
- Loading branch information
Showing
5 changed files
with
34 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var Dimension = require("../tree/dimension"); | ||
|
||
var MathHelper = function() { | ||
}; | ||
MathHelper._math = function (fn, unit, n) { | ||
if (!(n instanceof Dimension)) { | ||
throw { type: "Argument", message: "argument must be a number" }; | ||
} | ||
if (unit == null) { | ||
unit = n.unit; | ||
} else { | ||
n = n.unify(); | ||
} | ||
return new Dimension(fn(parseFloat(n.value)), unit); | ||
}; | ||
module.exports = MathHelper; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
div { | ||
percentage: percentage(16/17); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ArgumentError: error evaluating function `percentage`: argument must be a number in {path}percentage-non-number-argument.less on line 2, column 15: | ||
1 div { | ||
2 percentage: percentage(16/17); | ||
3 } |