Skip to content

Commit 579d7f0

Browse files
committed
Fix inspect for evaled complex selector
Type is list but single items are not wrapped
1 parent 527f3a8 commit 579d7f0

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

src/ast.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ namespace Sass {
872872
private:
873873
ADD_PROPERTY(enum Sass_Separator, separator)
874874
ADD_PROPERTY(bool, is_arglist)
875+
ADD_PROPERTY(bool, from_selector)
875876
public:
876877
List(ParserState pstate,
877878
size_t size = 0, enum Sass_Separator sep = SASS_SPACE, bool argl = false)

src/debugger.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ inline void debug_ast(AST_Node* node, std::string ind, Env* env)
557557
(expression->separator() == SASS_COMMA ? "Comma " : expression->separator() == SASS_HASH ? "Map" : "Space ") <<
558558
" [delayed: " << expression->is_delayed() << "] " <<
559559
" [interpolant: " << expression->is_interpolant() << "] " <<
560+
" [listized: " << expression->from_selector() << "] " <<
560561
" [arglist: " << expression->is_arglist() << "] " <<
561562
" [hash: " << expression->hash() << "] " <<
562563
std::endl;

src/eval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ namespace Sass {
458458
*ll << (*l)[i]->perform(this);
459459
}
460460
ll->is_interpolant(l->is_interpolant());
461+
ll->from_selector(l->from_selector());
461462
ll->is_expanded(true);
462463
return ll;
463464
}
@@ -832,7 +833,6 @@ namespace Sass {
832833
stm << "Stack depth exceeded max of " << Constants::MaxCallStack;
833834
error(stm.str(), c->pstate(), backtrace());
834835
}
835-
836836
std::string name(Util::normalize_underscores(c->name()));
837837
std::string full_name(name + "[f]");
838838
Arguments* args = SASS_MEMORY_NEW(ctx.mem, Arguments, *c->arguments());

src/inspect.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,12 @@ namespace Sass {
385385
bool was_space_array = in_space_array;
386386
bool was_comma_array = in_comma_array;
387387
// probably ruby sass eqivalent of element_needs_parens
388-
if (output_style() == TO_SASS && list->length() == 1 &&
389-
(!dynamic_cast<List*>((*list)[0]) &&
390-
!dynamic_cast<Selector_List*>((*list)[0]))) {
388+
if (output_style() == TO_SASS &&
389+
list->length() == 1 &&
390+
!list->from_selector() &&
391+
!dynamic_cast<List*>((*list)[0]) &&
392+
!dynamic_cast<List*>((*list)[0]) &&
393+
!dynamic_cast<Selector_List*>((*list)[0])) {
391394
append_string("(");
392395
}
393396
else if (!in_declaration && (list->separator() == SASS_HASH ||
@@ -424,9 +427,12 @@ namespace Sass {
424427
in_comma_array = was_comma_array;
425428
in_space_array = was_space_array;
426429
// probably ruby sass eqivalent of element_needs_parens
427-
if (output_style() == TO_SASS && list->length() == 1 &&
428-
(!dynamic_cast<List*>((*list)[0]) &&
429-
!dynamic_cast<Selector_List*>((*list)[0]))) {
430+
if (output_style() == TO_SASS &&
431+
list->length() == 1 &&
432+
!list->from_selector() &&
433+
!dynamic_cast<List*>((*list)[0]) &&
434+
!dynamic_cast<List*>((*list)[0]) &&
435+
!dynamic_cast<Selector_List*>((*list)[0])) {
430436
append_string(",)");
431437
}
432438
else if (!in_declaration && (list->separator() == SASS_HASH ||

src/listize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace Sass {
1717
Expression* Listize::operator()(Selector_List* sel)
1818
{
1919
List* l = SASS_MEMORY_NEW(mem, List, sel->pstate(), sel->length(), SASS_COMMA);
20+
l->from_selector(true);
2021
for (size_t i = 0, L = sel->length(); i < L; ++i) {
2122
if (!(*sel)[i]) continue;
2223
*l << (*sel)[i]->perform(this);
@@ -38,7 +39,7 @@ namespace Sass {
3839
Expression* Listize::operator()(Complex_Selector* sel)
3940
{
4041
List* l = SASS_MEMORY_NEW(mem, List, sel->pstate(), 2);
41-
42+
l->from_selector(true);
4243
Compound_Selector* head = sel->head();
4344
if (head && !head->is_empty_reference())
4445
{

0 commit comments

Comments
 (0)