Skip to content

Commit

Permalink
fix(index): do not throw an error if a comment precedes the colon
Browse files Browse the repository at this point in the history
```sh
$ node
> const css = require('css');
> css.parse('a{ color /*comment*/: red }');
Error: undefined:1:10: property missing ':'
```
  • Loading branch information
remarkablemark committed Jun 16, 2019
1 parent 7288eb6 commit 7f962ee
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ module.exports = function(style, options) {
while (
EMPTY_STRING != style.charAt(i) &&
(ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))
)
) {
++i;
}
i += 2;

if (EMPTY_STRING === style.charAt(i - 1)) {
Expand Down Expand Up @@ -191,7 +192,7 @@ module.exports = function(style, options) {
// prop
var prop = match(PROPERTY_REGEX);
if (!prop) return;
prop = trim(prop[0]);
comment();

// :
if (!match(COLON_REGEX)) return error("property missing ':'");
Expand All @@ -201,9 +202,9 @@ module.exports = function(style, options) {

var ret = pos({
type: TYPE_DECLARATION,
property: prop.replace(COMMENT_REGEX, EMPTY_STRING),
property: trim(prop[0].replace(COMMENT_REGEX, EMPTY_STRING)),
value: val
? trim(val[0]).replace(COMMENT_REGEX, EMPTY_STRING)
? trim(val[0].replace(COMMENT_REGEX, EMPTY_STRING))
: EMPTY_STRING
});

Expand Down

0 comments on commit 7f962ee

Please sign in to comment.