Index: Source/core/dom/SelectorQuery.cpp |
diff --git a/Source/core/dom/SelectorQuery.cpp b/Source/core/dom/SelectorQuery.cpp |
index ee10ce8e35b7d8eb8c4a6d3adf16a3a95c28af74..572180d2523e2f0ed1b15c571d590ccf27ae2a36 100644 |
--- a/Source/core/dom/SelectorQuery.cpp |
+++ b/Source/core/dom/SelectorQuery.cpp |
@@ -122,8 +122,9 @@ |
SelectorChecker selectorChecker(SelectorChecker::QueryingRules); |
SelectorChecker::SelectorCheckingContext selectorCheckingContext(&element, SelectorChecker::VisitedMatchDisabled); |
selectorCheckingContext.selector = &selector; |
- selectorCheckingContext.scope = &rootNode; |
- selectorCheckingContext.scopeContainsLastMatchedElement = true; |
+ selectorCheckingContext.scope = !rootNode.isDocumentNode() ? &rootNode : nullptr; |
+ if (selectorCheckingContext.scope) |
+ selectorCheckingContext.scopeContainsLastMatchedElement = true; |
return selectorChecker.match(selectorCheckingContext); |
} |