Skip to content

Commit

Permalink
Fix SCSS mixing parsing and add tests, fixes SC5#477
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannu Pelkonen committed Jun 4, 2015
1 parent 53a1042 commit ccf0487
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/modules/variable-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ function parseVariableDeclarations(string, syntax) {
},
process: function(nodes) {
var varName = nodes.content[0].content[0].content[0].content;
out.push({name: varName, value: nodes.content[3].toCSS(syntax)});
if (nodes.content[3]) {
out.push({name: varName, value: nodes.content[3].toCSS(syntax)});
}
}
},
less: {
Expand Down
23 changes: 23 additions & 0 deletions test/unit/modules/variable-parser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ describe('Variable Parser', function() {
result = ['myvar'];
expect(parser.findVariables(str)).eql(result);
});

it('shound handle mixins properly', function() {
var str = multiline(function() {
/*
@mixin sample-mixin($variable:'value'){
}
*/
});
expect(parser.findVariables(str)).eql([]);
})
});

describe('LESS syntax', function() {
Expand Down Expand Up @@ -359,6 +369,19 @@ describe('Variable Parser', function() {
expect(parser.parseVariableDeclarations(str)).eql(result);
});

it('should find variable declarations from mixins', function() {
var str = multiline(function() {
/*
@mixin sample-mixin($variable:'value') {
$color1: #ff0000;
}
*/
}),
result = [
{name: 'color1', value: '#ff0000'}
];
expect(parser.parseVariableDeclarations(str)).eql(result);
});
});

describe('LESS syntax', function() {
Expand Down

0 comments on commit ccf0487

Please sign in to comment.