@@ -477,7 +477,7 @@ namespace Sass {
477477 /*
478478 - IMPROVEMENT: We could probably work directly in the output trimmed deque.
479479 */
480- static Node trim (Node& seqses, Context& ctx) {
480+ static Node trim (Node& seqses, Context& ctx, bool isReplace ) {
481481 // See the comments in the above ruby code before embarking on understanding this function.
482482
483483 // Avoid poor performance in extreme cases.
@@ -520,7 +520,7 @@ namespace Sass {
520520 // had an extra source that the ruby version did not have. Without a failing test case, this is going to be extra hard to find. My
521521 // best guess at this point is that we're cloning an object somewhere and maintaining the sources when we shouldn't be. This is purely
522522 // a guess though.
523- unsigned long maxSpecificity = 0 ;
523+ unsigned long maxSpecificity = isReplace ? pSeq1-> specificity () : 0 ;
524524 SourcesSet sources = pSeq1->sources ();
525525
526526 DEBUG_PRINTLN (TRIM, " TRIMASDF SEQ1: " << seq1)
@@ -1461,7 +1461,7 @@ namespace Sass {
14611461 Complex_Selector* pComplexSelector,
14621462 Context& ctx,
14631463 ExtensionSubsetMap& subset_map,
1464- set<Compound_Selector> seen);
1464+ set<Compound_Selector> seen, bool isReplace );
14651465
14661466
14671467
@@ -1489,7 +1489,7 @@ namespace Sass {
14891489 Compound_Selector* pSelector,
14901490 Context& ctx,
14911491 ExtensionSubsetMap& subset_map,
1492- set<Compound_Selector> seen) {
1492+ set<Compound_Selector> seen, bool isReplace ) {
14931493
14941494 DEBUG_EXEC (EXTEND_COMPOUND, printCompoundSelector (pSelector, " EXTEND COMPOUND: " ))
14951495
@@ -1629,7 +1629,7 @@ namespace Sass {
16291629
16301630
16311631 DEBUG_PRINTLN (EXTEND_COMPOUND, " RECURSING DO EXTEND: " << complexSelectorToNode (pNewSelector, ctx))
1632- Node recurseExtendedSelectors = extendComplexSelector (pNewSelector, ctx, subset_map, recurseSeen);
1632+ Node recurseExtendedSelectors = extendComplexSelector (pNewSelector, ctx, subset_map, recurseSeen, isReplace );
16331633
16341634 DEBUG_PRINTLN (EXTEND_COMPOUND, " RECURSING DO EXTEND RETURN: " << recurseExtendedSelectors)
16351635
@@ -1740,7 +1740,7 @@ namespace Sass {
17401740 Complex_Selector* pComplexSelector,
17411741 Context& ctx,
17421742 ExtensionSubsetMap& subset_map,
1743- set<Compound_Selector> seen) {
1743+ set<Compound_Selector> seen, bool isReplace ) {
17441744
17451745 Node complexSelector = complexSelectorToNode (pComplexSelector, ctx);
17461746 DEBUG_PRINTLN (EXTEND_COMPLEX, " EXTEND COMPLEX: " << complexSelector)
@@ -1766,7 +1766,7 @@ namespace Sass {
17661766
17671767 Compound_Selector* pCompoundSelector = sseqOrOp.selector ()->head ();
17681768
1769- Node extended = extendCompoundSelector (pCompoundSelector, ctx, subset_map, seen);
1769+ Node extended = extendCompoundSelector (pCompoundSelector, ctx, subset_map, seen, isReplace );
17701770 if (sseqOrOp.got_line_feed ) extended.got_line_feed = true ;
17711771 DEBUG_PRINTLN (EXTEND_COMPLEX, " EXTENDED: " << extended)
17721772
@@ -1824,7 +1824,7 @@ namespace Sass {
18241824
18251825
18261826 // Ruby Equivalent: trim
1827- Node trimmed = trim (weaves, ctx);
1827+ Node trimmed = trim (weaves, ctx, isReplace );
18281828
18291829 DEBUG_PRINTLN (EXTEND_COMPLEX, " TRIMMED: " << trimmed)
18301830
@@ -1871,7 +1871,7 @@ namespace Sass {
18711871
18721872 set<Compound_Selector> seen;
18731873
1874- Node extendedSelectors = extendComplexSelector (pSelector, ctx, subset_map, seen);
1874+ Node extendedSelectors = extendComplexSelector (pSelector, ctx, subset_map, seen, isReplace );
18751875 if (!pSelector->has_placeholder ()) {
18761876 if (!extendedSelectors.contains (complexSelectorToNode (pSelector, ctx), true /* simpleSelectorOrderDependent*/ )) {
18771877 *pNewSelectors << pSelector;
0 commit comments