Skip to content

Commit

Permalink
Fixes issue where selector_append output order does not match ruby-sa…
Browse files Browse the repository at this point in the history
…ss output order
  • Loading branch information
onedayitwillmake committed Apr 7, 2015
1 parent 521a68b commit 7ccaece
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1639,7 +1639,7 @@ if( CONTEXTUALIZE->parent ) { \
// Set the first element as Parent, start iterating from 1 after begin()
std::vector<Selector_List*>::iterator itr = parsedSelectors.begin();
Selector_List* parent = *itr;
itr++;
++itr;
for(;itr != parsedSelectors.end(); ++itr) {

Selector_List* child = *itr;
Expand All @@ -1650,33 +1650,29 @@ if( CONTEXTUALIZE->parent ) { \
// Add that clone to newElements
// Replace CHILD.elements with newElements
vector<Complex_Selector*> newElements;
for (Complex_Selector* seq : child->elements()) {
for(Complex_Selector* pSeq : parent->elements() ) {
for(Complex_Selector* pSeq : parent->elements() ) {
for (Complex_Selector* seq : child->elements()) {
Complex_Selector* seq_clone = seq->cloneFully(ctx);

// std::cout << "--------\nparent:" << parent->perform(&to_string) << std::endl;
// std::cout << "pSeq:" << pSeq->perform(&to_string) << std::endl;
// std::cout << "\nchild:" << child->perform(&to_string) << std::endl;
// std::cout << "cSeq:" << seq_clone->perform(&to_string) << std::endl;

//
Selector_Reference* ref = new (ctx.mem) Selector_Reference(pSeq->pstate(), pSeq);
seq_clone->tail()->head()->unshift(ref);
newElements.push_back(seq_clone);
}
}

// Sort the final Complex_Selectors list alphabetically to match sass output
std::sort(newElements.begin(), newElements.end(), [](Complex_Selector* a, Complex_Selector* b){
return *a < *b;
});
child->elements(newElements);

// string s = child->perform(&to_string);
// child->mCachedSelector(s);
// std::cout << "\n\tEndChild:" << child->mCachedSelector() << std::endl;
parent = child;
}

return new (ctx.mem) String_Constant(pstate, parent->perform(&to_string));
}

Expand Down

0 comments on commit 7ccaece

Please sign in to comment.