From 7bdc9e6db5665a698bc5e6f1c32542c2fe965e32 Mon Sep 17 00:00:00 2001 From: vladkens Date: Fri, 23 Aug 2013 21:35:31 +0300 Subject: [PATCH] Remove comments from properties and values in parse time. --- index.js | 4 +-- test/cases/comment.in.css | 4 +++ test/cases/comment.in.json | 53 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 test/cases/comment.in.css create mode 100644 test/cases/comment.in.json diff --git a/index.js b/index.js index 8623fa4..5b832f7 100644 --- a/index.js +++ b/index.js @@ -192,8 +192,8 @@ module.exports = function(css, options){ var ret = pos({ type: 'declaration', - property: prop, - value: val[0].trim() + property: prop.replace(/\/\*.*\*\//g, ''), + value: val[0].trim().replace(/\/\*.*\*\//g, '') }); // ; diff --git a/test/cases/comment.in.css b/test/cases/comment.in.css new file mode 100644 index 0000000..f45a0d7 --- /dev/null +++ b/test/cases/comment.in.css @@ -0,0 +1,4 @@ +a { + color/**/: 12px; + padding/*4815162342*/: 1px /**/ 2px /*13*/ 3px; +} \ No newline at end of file diff --git a/test/cases/comment.in.json b/test/cases/comment.in.json new file mode 100644 index 0000000..5c9107f --- /dev/null +++ b/test/cases/comment.in.json @@ -0,0 +1,53 @@ +{ + "type": "stylesheet", + "stylesheet": { + "rules": [ + { + "type": "rule", + "selectors": ["a"], + "declarations": [ + { + "type": "declaration", + "property": "color", + "value": "12px", + "position": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 20 + } + } + }, + { + "type": "declaration", + "property": "padding", + "value": "1px 3px", + "position": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 51 + } + } + } + ], + "position": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 4, + "column": 2 + } + } + } + ] + } +} \ No newline at end of file