Skip to content

Add missing value units #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports.TYPES = {
// rough regular expressions
var integerRegEx = /^[-+]?[0-9]+$/;
var numberRegEx = /^[-+]?[0-9]*\.?[0-9]+$/;
var lengthRegEx = /^(0|[-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw|ch))$/;
var lengthRegEx = /^(0|[-+]?[0-9]*\.?[0-9]+(ch|cm|r?em|ex|in|lh|mm|pc|pt|px|Q|vh|vmin|vmax|vw))$/;
var percentRegEx = /^[-+]?[0-9]*\.?[0-9]+%$/;
var urlRegEx = /^url\(\s*([^)]*)\s*\)$/;
var stringRegEx = /^("[^"]*"|'[^']*')$/;
Expand All @@ -33,7 +33,7 @@ var colorRegEx2 = /^rgb\(([^)]*)\)$/;
var colorRegEx3 = /^rgba\(([^)]*)\)$/;
var calcRegEx = /^calc\(([^)]*)\)$/;
var colorRegEx4 = /^hsla?\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*(,\s*(-?\d+|-?\d*.\d+)\s*)?\)/;
var angleRegEx = /^([-+]?[0-9]*\.?[0-9]+)(deg|grad|rad)$/;
var angleRegEx = /^([-+]?[0-9]*\.?[0-9]+)(deg|grad|rad|turn)$/;

// This will return one of the above types based on the passed in string
exports.valueType = function valueType(val) {
Expand Down Expand Up @@ -418,6 +418,8 @@ exports.parseAngle = function parseAngle(val) {
flt *= 180 / Math.PI;
} else if (res[2] === 'grad') {
flt *= 360 / 400;
} else if (res[2] === 'turn') {
flt *= 360;
}

while (flt < 0) {
Expand Down