Skip to content

Commit 9e99a86

Browse files
authored
Merge pull request #3 from simon360/fix-file-level-comments
Don't fail on file-level comments
2 parents 4df32d4 + b84a536 commit 9e99a86

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = function(source) {
33
this.cacheable();
44
var result = {};
55
css.parse(source).stylesheet.rules
6-
.filter(rule => rule.selectors.some(sel => sel === ':root'))
6+
.filter(rule => rule.selectors && rule.selectors.some(sel => sel === ':root'))
77
.forEach(rule => rule.declarations
88
.filter(decl => decl.type === 'declaration' && decl.property.indexOf('--') === 0)
99
.forEach(decl => result[decl.property] = decl.value));

test/simple.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ check('should import from :root among multiple selectors',
3333
check('should not break when there is a comment',
3434
':root { --theme: red; /* important info */ --accent: blue }',
3535
{ '--accent': 'blue', '--theme': 'red' })
36+
check('should not break when there is a file-level comment',
37+
'/* file info */ :root { --theme: red; /* important info */ --accent: blue }',
38+
{ '--accent': 'blue', '--theme': 'red' })

0 commit comments

Comments
 (0)