Skip to content

Commit ef912ac

Browse files
committed
Fix measurement regex's to allow for multiple digits before decimal point
- fixes #27 Thanks @lalalic
1 parent dcd687f commit ef912ac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/parsers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ exports.TYPES = {
2121
// rough regular expressions
2222
var integerRegEx = /^[\-+]?[0-9]+$/;
2323
var numberRegEx = /^[\-+]?[0-9]*\.[0-9]+$/;
24-
var lengthRegEx = /^(0|[\-+]?[0-9]?\.?[0-9]+(in|cm|em|mm|pt|pc|px))$/;
25-
var percentRegEx = /^[\-+]?[0-9]?\.?[0-9]+%$/;
24+
var lengthRegEx = /^(0|[\-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px))$/;
25+
var percentRegEx = /^[\-+]?[0-9]*\.?[0-9]+%$/;
2626
var urlRegEx = /^url\(\s*([^\)]*)\s*\)$/;
2727
var stringRegEx = /^("[^"]*"|'[^']*')$/;
2828
var colorRegEx1 = /^#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])?$/;
2929
var colorRegEx2 = /^rgb\(([^\)]*)\)$/;
3030
var colorRegEx3 = /^rgba\(([^\)]*)\)$/;
31-
var angleRegEx = /^([\-+]?[0-9]?\.?[0-9]+)(deg|grad|rad)$/;
31+
var angleRegEx = /^([\-+]?[0-9]*\.?[0-9]+)(deg|grad|rad)$/;
3232
/*jslint regexp: false*/
3333

3434
// This will return one of the above types based on the passed in string

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cssstyle",
33
"description": "CSSStyleDeclaration Object Model implementation",
44
"keywords": ["CSS", "CSSStyleDeclaration", "StyleSheet"],
5-
"version": "0.2.22",
5+
"version": "0.2.24",
66
"homepage": "https://github.com/chad3814/CSSStyleDeclaration",
77
"maintainers": [{
88
"name": "Chad Walker",

0 commit comments

Comments
 (0)