LibWeb: Default to an empty string when a string attr substitution fails

When a string-type attr() substitution produces no value and no fallback
had been specified, the spec mandates we default to the empty string.
This commit is contained in:
Timothy Flynn 2024-04-16 12:42:23 -04:00 committed by Andreas Kling
commit bf1c82724f
Notes: sideshowbarker 2024-07-16 23:34:49 +09:00
6 changed files with 34 additions and 10 deletions

View file

@ -7450,6 +7450,12 @@ bool Parser::substitute_attr_function(DOM::Element& element, FlyString const& pr
if (has_fallback_values)
return expand_unresolved_values(element, property_name, attr_contents, dest);
if (attribute_type.equals_ignoring_ascii_case("string"_fly_string)) {
// If the <attr-type> argument is string, defaults to the empty string if omitted
dest.empend(Token::create_string({}));
return true;
}
// 3. Otherwise, the property containing the attr() function is invalid at computed-value time.
return false;
}