[Pkg-javascript-commits] [node-cssstyle] 38/39: parser fixes

Wolfgang Borgert debacle at moszumanska.debian.org
Sat Sep 20 20:22:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository node-cssstyle.

commit 3cd7f2670d5d2a68e14b0ce4f8d14361b9958749
Author: Chad Walker <chad at chad-cat-lore-eddie.com>
Date:   Mon May 19 20:12:14 2014 -0500

    parser fixes
    
    - fix valueType function to parse integers and numbers that are set
      as a string
    - fix camelToDashed to actually do the proper replacement *sigh*
    - bumped version
---
 lib/parsers.js | 22 ++++++++++++----------
 package.json   |  2 +-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/parsers.js b/lib/parsers.js
index 69c1a69..ee0d7e3 100644
--- a/lib/parsers.js
+++ b/lib/parsers.js
@@ -38,18 +38,18 @@ exports.valueType = function valueType(val) {
     }
     if (typeof val === 'number') {
         val = val.toString();
-        if (integerRegEx.test(val)) {
-            return exports.TYPES.INTEGER;
-        }
-        if (numberRegEx.test(val)) {
-            return exports.TYPES.NUMBER;
-        }
-        // shouldn't get here
-        return undefined;
     }
+
     if (typeof val !== 'string') {
         return undefined;
     }
+
+    if (integerRegEx.test(val)) {
+        return exports.TYPES.INTEGER;
+    }
+    if (numberRegEx.test(val)) {
+        return exports.TYPES.NUMBER;
+    }
     if (lengthRegEx.test(val)) {
         return exports.TYPES.LENGTH;
     }
@@ -163,12 +163,14 @@ exports.parseInteger = function parseInteger(val) {
 exports.parseNumber = function parseNumber(val) {
     var type = exports.valueType(val);
     if (type === exports.TYPES.NULL_OR_EMPTY_STR) {
+        console.log('null or empty str');
         return val;
     }
     if (type !== exports.TYPES.NUMBER) {
+        console.log('not a number', type);
         return undefined;
     }
-    return String(parseFloat(val, 10));
+    return String(parseFloat(val));
 };
 
 exports.parseLength = function parseLength(val) {
@@ -608,7 +610,7 @@ var first_segment = /^\([^\-]\)-/;
 var vendor_prefixes = ['o', 'moz', 'ms', 'webkit'];
 exports.camelToDashed = function (camel_case) {
     var match;
-    var dashed = camel_case.replace(camel_to_dashed, '-$1').toLowerCase();
+    var dashed = camel_case.replace(camel_to_dashed, '-$&').toLowerCase();
     match = dashed.match(first_segment);
     if (match && vendor_prefixes.indexOf(match[1]) !== -1) {
         dashed = '-' + dashed;
diff --git a/package.json b/package.json
index a7deb2a..06e0b82 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
     "name": "cssstyle",
     "description": "CSSStyleDeclaration Object Model implementation",
     "keywords": ["CSS", "CSSStyleDeclaration", "StyleSheet"],
-    "version": "0.2.12",
+    "version": "0.2.13",
     "homepage": "https://github.com/chad3814/CSSStyleDeclaration",
     "maintainers": [{
         "name": "Chad Walker",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-cssstyle.git



More information about the Pkg-javascript-commits mailing list