Skip to content

Commit bd02fc2

Browse files
author
Aaron Leung
committed
Merge pull request #370 from wonja/bem_selectors
allowing arbitrary hyphens at the beginning of BEM selectors #319
2 parents e9e2cfc + 141a964 commit bd02fc2

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

parser.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,10 @@ namespace Sass {
421421
return seq;
422422
}
423423
}
424-
if (lex< sequence< negate< functional >, alternatives< type_selector, universal, string_constant, dimension, percentage, number > > >()) {
424+
if (sawsomething && lex< sequence< negate< functional >, alternatives< hyphens_and_identifier, universal, string_constant, dimension, percentage, number > > >()) {
425+
// saw an ampersand, then allow type selectors with arbitrary number of hyphens at the beginning
426+
(*seq) << new (ctx.mem) Type_Selector(path, source_position, lexed);
427+
} else if (lex< sequence< negate< functional >, alternatives< type_selector, universal, string_constant, dimension, percentage, number > > >()) {
425428
// if you see a type selector
426429
(*seq) << new (ctx.mem) Type_Selector(path, source_position, lexed);
427430
sawsomething = true;
@@ -1484,6 +1487,7 @@ namespace Sass {
14841487
bool saw_interpolant = false;
14851488

14861489
while ((q = peek< identifier >(p)) ||
1490+
(q = peek< hyphens_and_identifier >(p)) ||
14871491
(q = peek< type_selector >(p)) ||
14881492
(q = peek< id_name >(p)) ||
14891493
(q = peek< class_name >(p)) ||

prelexer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ namespace Sass {
245245
const char* type_selector(const char* src) {
246246
return sequence< optional<namespace_prefix>, identifier>(src);
247247
}
248+
const char* hyphens_and_identifier(const char* src) {
249+
return sequence< zero_plus< exactly< '-' > >, identifier >(src);
250+
}
248251
const char* universal(const char* src) {
249252
return sequence< optional<namespace_prefix>, exactly<'*'> >(src);
250253
}

prelexer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ namespace Sass {
369369
// Match CSS type selectors
370370
const char* namespace_prefix(const char* src);
371371
const char* type_selector(const char* src);
372+
const char* hyphens_and_identifier(const char* src);
372373
const char* universal(const char* src);
373374
// Match CSS id names.
374375
const char* id_name(const char* src);

0 commit comments

Comments
 (0)