| Index: Source/core/css/SelectorChecker.cpp | 
| diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp | 
| index 694c652130adfeac5356ee443095b01574122e4a..cb86f50b0565297dbf1d83264029f302cfdc04fe 100644 | 
| --- a/Source/core/css/SelectorChecker.cpp | 
| +++ b/Source/core/css/SelectorChecker.cpp | 
| @@ -99,8 +99,12 @@ static bool matchesTagName(const Element& element, const QualifiedName& tagQName | 
| if (tagQName == anyQName()) | 
| return true; | 
| const AtomicString& localName = tagQName.localName(); | 
| -    if (localName != starAtom && localName != element.localName()) | 
| -        return false; | 
| +    if (localName != starAtom && localName != element.localName()) { | 
| +        if (element.isHTMLElement() || !element.document().isHTMLDocument()) | 
| +            return false; | 
| +        if (!equalIgnoringCase(localName, element.localName())) | 
| +            return false; | 
| +    } | 
| const AtomicString& namespaceURI = tagQName.namespaceURI(); | 
| return namespaceURI == starAtom || namespaceURI == element.namespaceURI(); | 
| } | 
|  |