Prechádzať zdrojové kódy

The attribute selector |= should also match when the value is exactly equal

Michael Ragazzon 3 rokov pred
rodič
commit
159b277fb5

+ 2 - 1
Source/Core/StyleSheetNode.cpp

@@ -277,7 +277,8 @@ bool StyleSheetNode::MatchAttributes(const Element* element) const
 		}
 		break;
 		case AttributeSelectorType::BeginsWithThenHyphen:
-			if (!BeginsWith(element_value, css_value) || element_value[css_value.size()] != '-')
+			// Begins with 'css_value' followed by a hyphen, or matches exactly.
+			if (!BeginsWith(element_value, css_value) || (element_value.size() != css_value.size() && element_value[css_value.size()] != '-'))
 				return false;
 			break;
 		case AttributeSelectorType::BeginsWith:

+ 1 - 1
Tests/Source/UnitTests/Selectors.cpp

@@ -123,7 +123,7 @@ static const Vector<QuerySelector> query_selectors =
 	{ "[class=\"\"]",                "G" },
 	{ "[class~=hello]",              "X Z H" },
 	{ "[class~=ello]",               "" },
-	{ "[class|=hello]",              "F0" },
+	{ "[class|=hello]",              "X F0" },
 	{ "[class^=hello]",              "X Z F0" },
 	{ "[class^=]",                   "X Y Z P F0 G H" },
 	{ "[class$=hello]",              "X H" },