mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
LibWeb: Add remaining CSS AttributeMatchTypes
This adds: - ContainsString [att*=val] - StartsWithSegment [att|=val] - StartsWithString [att^=val] - EndsWithString [att$=val] Renamed AttributeMatchType::Contains to ::ContainsWord for clarity.
This commit is contained in:
parent
29d78bba4b
commit
7fefe34797
5 changed files with 38 additions and 10 deletions
|
@ -180,10 +180,26 @@ static bool matches(const CSS::Selector::SimpleSelector& component, const DOM::E
|
|||
if (element.attribute(component.attribute_name) != component.attribute_value)
|
||||
return false;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::AttributeMatchType::Contains:
|
||||
case CSS::Selector::SimpleSelector::AttributeMatchType::ContainsWord:
|
||||
if (!element.attribute(component.attribute_name).split(' ').contains_slow(component.attribute_value))
|
||||
return false;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::AttributeMatchType::ContainsString:
|
||||
if (!element.attribute(component.attribute_name).contains(component.attribute_value))
|
||||
return false;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::AttributeMatchType::StartsWithSegment:
|
||||
if (element.attribute(component.attribute_name).split('-').first() != component.attribute_value)
|
||||
return false;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::AttributeMatchType::StartsWithString:
|
||||
if (!element.attribute(component.attribute_name).starts_with(component.attribute_value))
|
||||
return false;
|
||||
break;
|
||||
case CSS::Selector::SimpleSelector::AttributeMatchType::EndsWithString:
|
||||
if (!element.attribute(component.attribute_name).ends_with(component.attribute_value))
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue