Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix obvious backporting error in pseudo extend #3136

Merged
merged 1 commit into from
May 11, 2021
Merged
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
26 changes: 13 additions & 13 deletions src/extender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ namespace Sass {
// EO registerSelector

// ##########################################################################
// Returns an extension that combines [left] and [right]. Throws
// a [SassException] if [left] and [right] have incompatible
// Returns an extension that combines [left] and [right]. Throws
// a [SassException] if [left] and [right] have incompatible
// media contexts. Throws an [ArgumentError] if [left]
// and [right] don't have the same extender and target.
// ##########################################################################
Expand Down Expand Up @@ -281,7 +281,7 @@ namespace Sass {
// ##########################################################################
// Adds an extension to this extender. The [extender] is the selector for the
// style rule in which the extension is defined, and [target] is the selector
// passed to `@extend`. The [extend] provides the extend span and indicates
// passed to `@extend`. The [extend] provides the extend span and indicates
// whether the extension is optional. The [mediaContext] defines the media query
// context in which the extension is defined. It can only extend selectors
// within the same context. A `null` context indicates no media queries.
Expand Down Expand Up @@ -353,7 +353,7 @@ namespace Sass {

ExtSelExtMap newExtensionsByTarget;
newExtensionsByTarget.insert(std::make_pair(target, newExtensions));
// ToDo: do we really need to fetch again (see top off fn)
// ToDo: do we really need to fetch again (see top off fn)
auto existingExtensions = extensionsByExtender.find(target);
if (existingExtensions != extensionsByExtender.end()) {
if (hasExistingExtensions && !existingExtensions->second.empty()) {
Expand All @@ -373,7 +373,7 @@ namespace Sass {

}
// EO addExtension

// ##########################################################################
// Extend [extensions] using [newExtensions].
// ##########################################################################
Expand Down Expand Up @@ -446,7 +446,7 @@ namespace Sass {
bool first = false, containsExtension =
ObjEqualityFn(selectors.front(), extension.extender);
for (const ComplexSelectorObj& complex : selectors) {
// If the output contains the original complex
// If the output contains the original complex
// selector, there's no need to recreate it.
if (containsExtension && first) {
first = false;
Expand Down Expand Up @@ -614,7 +614,7 @@ namespace Sass {
// ToDo: either change weave or paths to work with the same data?
sass::vector<sass::vector<ComplexSelectorObj>>
paths = permutate(extendedNotExpanded);

for (const sass::vector<ComplexSelectorObj>& path : paths) {
// Unpack the inner complex selector to component list
sass::vector<sass::vector<SelectorComponentObj>> _paths;
Expand Down Expand Up @@ -977,15 +977,15 @@ namespace Sass {
if (innerPseudo->normalized() != "matches") return {};
return innerPseudo->selector()->elements();
}
else if (name == "matches" && name == "any" && name == "current" && name == "nth-child" && name == "nth-last-child") {
else if (name == "matches" || name == "any" || name == "current" || name == "nth-child" || name == "nth-last-child") {
// As above, we could theoretically support :not within :matches, but
// doing so would require this method and its callers to handle much
// more complex cases that likely aren't worth the pain.
if (innerPseudo->name() != pseudo->name()) return {};
if (!ObjEquality()(innerPseudo->argument(), pseudo->argument())) return {};
return innerPseudo->selector()->elements();
}
else if (name == "has" && name == "host" && name == "host-context" && name == "slotted") {
else if (name == "has" || name == "host" || name == "host-context" || name == "slotted") {
// We can't expand nested selectors here, because each layer adds an
// additional layer of semantics. For example, `:has(:has(img))`
// doesn't match `<div><img></div>` but `:has(img)` does.
Expand Down Expand Up @@ -1031,7 +1031,7 @@ namespace Sass {
}
}
}

sass::vector<ComplexSelectorObj> expanded = expand(
complexes, extendPseudoComplex, pseudo, mediaQueryContext);

Expand All @@ -1051,7 +1051,7 @@ namespace Sass {
}

SelectorListObj list = SASS_MEMORY_NEW(SelectorList, "[phony]");
list->concat(complexes);
list->concat(expanded);
return { pseudo->withSelector(list) };

}
Expand Down Expand Up @@ -1088,7 +1088,7 @@ namespace Sass {
{

// Avoid truly horrific quadratic behavior.
// TODO(nweiz): I think there may be a way to get perfect trimming
// TODO(nweiz): I think there may be a way to get perfect trimming
// without going quadratic by building some sort of trie-like
// data structure that can be used to look up superselectors.
// TODO(mgreter): Check how this performs in C++ (up the limit)
Expand Down Expand Up @@ -1130,7 +1130,7 @@ namespace Sass {
maxSpecificity = std::max(maxSpecificity, maxSourceSpecificity(compound));
}
}


// Look in [result] rather than [selectors] for selectors after [i]. This
// ensures we aren't comparing against a selector that's already been trimmed,
Expand Down