Skip to content

Commit d83f879

Browse files
committed
Skip extending of nested wrapped selector
1 parent 64856b2 commit d83f879

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/ast.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,6 +1889,9 @@ namespace Sass {
18891889
virtual void set_media_block(Media_Block* mb) {
18901890
media_block(mb);
18911891
}
1892+
virtual bool has_wrapped_selector() {
1893+
return false;
1894+
}
18921895
};
18931896
inline Selector::~Selector() { }
18941897

@@ -2185,6 +2188,10 @@ namespace Sass {
21852188
}
21862189
return hash_;
21872190
}
2191+
virtual bool has_wrapped_selector()
2192+
{
2193+
return true;
2194+
}
21882195
virtual unsigned long specificity()
21892196
{
21902197
return selector_ ? selector_->specificity() : 0;
@@ -2270,6 +2277,15 @@ namespace Sass {
22702277
return sum;
22712278
}
22722279

2280+
virtual bool has_wrapped_selector()
2281+
{
2282+
if (length() == 0) return false;
2283+
if (Simple_Selector* ss = elements().front()) {
2284+
if (ss->has_wrapped_selector()) return true;
2285+
}
2286+
return false;
2287+
}
2288+
22732289
bool is_empty_reference()
22742290
{
22752291
return length() == 1 &&
@@ -2398,6 +2414,11 @@ namespace Sass {
23982414
if (tail_) tail_->set_media_block(mb);
23992415
if (head_) head_->set_media_block(mb);
24002416
}
2417+
virtual bool has_wrapped_selector() {
2418+
if (head_ && head_->has_wrapped_selector()) return true;
2419+
if (tail_ && tail_->has_wrapped_selector()) return true;
2420+
return false;
2421+
}
24012422
bool operator<(const Complex_Selector& rhs) const;
24022423
bool operator==(const Complex_Selector& rhs) const;
24032424
inline bool operator!=(const Complex_Selector& rhs) const { return !(*this == rhs); }
@@ -2506,6 +2527,12 @@ namespace Sass {
25062527
cs->set_media_block(mb);
25072528
}
25082529
}
2530+
virtual bool has_wrapped_selector() {
2531+
for (Complex_Selector* cs : elements()) {
2532+
if (cs->has_wrapped_selector()) return true;
2533+
}
2534+
return false;
2535+
}
25092536
Selector_List* clone(Context&) const; // does not clone Compound_Selector*s
25102537
Selector_List* cloneFully(Context&) const; // clones Compound_Selector*s
25112538
virtual bool operator==(const Selector& rhs) const;

src/extend.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,6 +1942,7 @@ namespace Sass {
19421942
if (!pSelector->has_placeholder()) {
19431943
if (!extendedSelectors.contains(complexSelectorToNode(pSelector, ctx), true /*simpleSelectorOrderDependent*/)) {
19441944
*pNewSelectors << pSelector;
1945+
continue;
19451946
}
19461947
}
19471948

@@ -1987,7 +1988,12 @@ namespace Sass {
19871988
Wrapped_Selector* cpy_ws = SASS_MEMORY_NEW(ctx.mem, Wrapped_Selector, *ws);
19881989
Selector_List* cpy_ws_sl = SASS_MEMORY_NEW(ctx.mem, Selector_List, sl->pstate());
19891990
// remove parent selectors from inner selector
1990-
if (ext_cs->first()) *cpy_ws_sl << ext_cs->first();
1991+
if (ext_cs->first()) {
1992+
if (ext_cs->first()->has_wrapped_selector()) {
1993+
continue; // ignore this case for now
1994+
}
1995+
*cpy_ws_sl << ext_cs->first();
1996+
}
19911997
// assign list to clone
19921998
cpy_ws->selector(cpy_ws_sl);
19931999
// append the clone

0 commit comments

Comments
 (0)