Skip to content

Commit

Permalink
Merge pull request sass#739 from xzyfer/fix/bem-style-identifiers
Browse files Browse the repository at this point in the history
Parse selector identifiers prefixed with an ampersand correctly
  • Loading branch information
xzyfer committed Dec 19, 2014
2 parents a6fe2d0 + 80877ae commit 7693c35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ namespace Sass {
return seq;
}
}
if (sawsomething && lex< sequence< negate< functional >, alternatives< hyphens_and_identifier, universal, string_constant, dimension, percentage, number > > >()) {
if (sawsomething && lex< sequence< negate< functional >, alternatives< identifier_fragment, universal, string_constant, dimension, percentage, number > > >()) {
// saw an ampersand, then allow type selectors with arbitrary number of hyphens at the beginning
(*seq) << new (ctx.mem) Type_Selector(path, source_position, lexed);
} else if (lex< sequence< negate< functional >, alternatives< type_selector, universal, string_constant, dimension, percentage, number > > >()) {
Expand Down Expand Up @@ -1776,6 +1776,8 @@ namespace Sass {
(q = peek< sequence< optional<sign>,
digits > >(p)) ||
(q = peek< number >(p)) ||
(q = peek< sequence< exactly<'&'>,
identifier_fragment > >(p)) ||
(q = peek< exactly<'&'> >(p)) ||
(q = peek< exactly<'%'> >(p)) ||
(q = peek< alternatives<exact_match,
Expand Down Expand Up @@ -1832,6 +1834,8 @@ namespace Sass {
(q = peek< sequence< optional<sign>,
digits > >(p)) ||
(q = peek< number >(p)) ||
(q = peek< sequence< exactly<'&'>,
identifier_fragment > >(p)) ||
(q = peek< exactly<'&'> >(p)) ||
(q = peek< exactly<'%'> >(p)) ||
(q = peek< alternatives<exact_match,
Expand Down
7 changes: 7 additions & 0 deletions prelexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ namespace Sass {
backslash_something > > >(src);
}

const char* identifier_fragment(const char* src) {
return one_plus< alternatives< alnum,
exactly<'-'>,
exactly<'_'>,
backslash_something > >(src);
}

// Match CSS selectors.
const char* sel_ident(const char* src) {
return sequence< optional< alternatives< exactly<'-'>, exactly<'|'> > >,
Expand Down
1 change: 1 addition & 0 deletions prelexer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ namespace Sass {
const char* custom_property_name(const char* src);
// Match a CSS identifier.
const char* identifier(const char* src);
const char* identifier_fragment(const char* src);
// Match selector names.
const char* sel_ident(const char* src);
// Match interpolant schemas
Expand Down

0 comments on commit 7693c35

Please sign in to comment.