Skip to content

Commit e9e2cfc

Browse files
author
Aaron Leung
committed
Merge pull request #369 from wonja/bem_selectors
Fixes Sass 3.3 BEM-style selector syntax support #319
2 parents cd3ee1c + aa851cf commit e9e2cfc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

parser.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,23 @@ namespace Sass {
411411
Compound_Selector* Parser::parse_simple_selector_sequence()
412412
{
413413
Compound_Selector* seq = new (ctx.mem) Compound_Selector(path, source_position);
414-
// check for backref or type selector, which are only allowed at the front
414+
bool sawsomething = false;
415415
if (lex< exactly<'&'> >()) {
416+
// if you see a &
416417
(*seq) << new (ctx.mem) Selector_Reference(path, source_position);
418+
sawsomething = true;
419+
// if you see a space after a &, then you're done
420+
if(lex< spaces >()) {
421+
return seq;
422+
}
417423
}
418-
else if (lex< sequence< negate< functional >, alternatives< type_selector, universal, string_constant, dimension, percentage, number > > >()) {
424+
if (lex< sequence< negate< functional >, alternatives< type_selector, universal, string_constant, dimension, percentage, number > > >()) {
425+
// if you see a type selector
419426
(*seq) << new (ctx.mem) Type_Selector(path, source_position, lexed);
427+
sawsomething = true;
420428
}
421-
else {
429+
if (!sawsomething) {
430+
// don't blindly do this if you saw a & or selector
422431
(*seq) << parse_simple_selector();
423432
}
424433

0 commit comments

Comments
 (0)