Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix most urgent issues in 2023 #3184

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/ast_selectors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ namespace Sass {
for (SimpleSelectorObj simple : elements()) {
if (PseudoSelector * pseudo = Cast<PseudoSelector>(simple)) {
if (SelectorList* sel = Cast<SelectorList>(pseudo->selector())) {
if (parent) {
if (parent && !parent->has_real_parent_ref()) {
pseudo->selector(sel->resolve_parent_refs(
pstack, traces, implicit_parent));
}
Expand Down Expand Up @@ -976,20 +976,22 @@ namespace Sass {
}

/* better return sass::vector? only - is empty container anyway? */
SelectorList* ComplexSelector::resolve_parent_refs(SelectorStack pstack, Backtraces& traces, bool implicit_parent)
SelectorList* ComplexSelector::resolve_parent_refs(
SelectorStack pstack, Backtraces& traces, bool implicit_parent)
{

sass::vector<sass::vector<ComplexSelectorObj>> vars;

auto parent = pstack.back();
auto hasRealParent = has_real_parent_ref();

if (has_real_parent_ref() && !parent) {
if (hasRealParent && !parent) {
throw Exception::TopLevelParent(traces, pstate());
}

if (!chroots() && parent) {

if (!has_real_parent_ref() && !implicit_parent) {
if (!hasRealParent && !implicit_parent) {
SelectorList* retval = SASS_MEMORY_NEW(SelectorList, pstate(), 1);
retval->append(this);
return retval;
Expand Down Expand Up @@ -1020,10 +1022,10 @@ namespace Sass {
for (auto items : res) {
if (items.size() > 0) {
ComplexSelectorObj first = SASS_MEMORY_COPY(items[0]);
first->hasPreLineFeed(first->hasPreLineFeed() || (!has_real_parent_ref() && hasPreLineFeed()));
first->hasPreLineFeed(first->hasPreLineFeed() || (!hasRealParent && hasPreLineFeed()));
// ToDo: remove once we know how to handle line feeds
// ToDo: currently a mashup between ruby and dart sass
// if (has_real_parent_ref()) first->has_line_feed(false);
// if (hasRealParent) first->has_line_feed(false);
// first->has_line_break(first->has_line_break() || has_line_break());
first->chroots(true); // has been resolved by now
for (size_t i = 1; i < items.size(); i += 1) {
Expand Down
1 change: 1 addition & 0 deletions src/debugger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ inline void debug_ast(AST_Node* node, sass::string ind, Env* env)
std::cerr << " <<" << selector->ns_name() << ">>";
std::cerr << (selector->isClass() ? " [isClass]": " -");
std::cerr << (selector->isSyntacticClass() ? " [isSyntacticClass]": " -");
std::cerr << (selector->has_real_parent_ref(nullptr) ? " [real parent]" : " -");
std::cerr << std::endl;
debug_ast(selector->argument(), ind + " <= ", env);
debug_ast(selector->selector(), ind + " || ", env);
Expand Down
12 changes: 8 additions & 4 deletions src/fn_miscs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,14 @@ namespace Sass {
ExpressionObj cond = ARG("$condition", Expression)->perform(&expand.eval);
bool is_true = !cond->is_false();
ExpressionObj res = ARG(is_true ? "$if-true" : "$if-false", Expression);
ValueObj qwe = Cast<Value>(res->perform(&expand.eval));
// res = res->perform(&expand.eval.val_eval);
qwe->set_delayed(false); // clone?
return qwe.detach();
ExpressionObj rv = res->perform(&expand.eval);
ValueObj value = Cast<Value>(rv);
if (value != nullptr) {
value->set_delayed(false);
return value.detach();
}
rv->set_delayed(false);
return nullptr;
}

//////////////////////////
Expand Down
3 changes: 2 additions & 1 deletion src/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ namespace Sass {
{ sep[0] = i % 2 ? ':' : ','; }
ExpressionObj list_item = list->at(i);
if (output_style() != TO_SASS) {
if (list_item == nullptr) continue;
if (list_item->is_invisible()) {
// this fixes an issue with "" in a list
if (!Cast<String_Constant>(list_item)) {
Expand Down Expand Up @@ -1088,7 +1089,7 @@ namespace Sass {

void Inspect::operator()(CompoundSelector* sel)
{
if (sel->hasRealParent()) {
if (sel->hasRealParent() /* || sel->has_real_parent_ref() */) {
append_string("&");
}
for (auto& item : sel->elements()) {
Expand Down
Loading