mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 08:39:22 +00:00
LibWeb: Update attribute name validation in Element.toggleAttribute
This now follows the latest specification steps.
This commit is contained in:
parent
4593c28769
commit
acf2d773d5
Notes:
github-actions[bot]
2025-06-19 10:02:19 +00:00
Author: https://github.com/tcl3
Commit: acf2d773d5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5140
Reviewed-by: https://github.com/AtkinsSJ ✅
4 changed files with 9 additions and 9 deletions
|
@ -461,8 +461,8 @@ bool Element::has_attribute_ns(Optional<FlyString> const& namespace_, FlyString
|
||||||
// https://dom.spec.whatwg.org/#dom-element-toggleattribute
|
// https://dom.spec.whatwg.org/#dom-element-toggleattribute
|
||||||
WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force)
|
WebIDL::ExceptionOr<bool> Element::toggle_attribute(FlyString const& name, Optional<bool> force)
|
||||||
{
|
{
|
||||||
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
|
// 1. If qualifiedName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
|
||||||
if (!Document::is_valid_name(name.to_string()))
|
if (!is_valid_attribute_local_name(name))
|
||||||
return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty or contain invalid characters"_string);
|
return WebIDL::InvalidCharacterError::create(realm(), "Attribute name must not be empty or contain invalid characters"_string);
|
||||||
|
|
||||||
// 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
|
// 2. If this is in the HTML namespace and its node document is an HTML document, then set qualifiedName to qualifiedName in ASCII lowercase.
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
PASS (''): InvalidCharacterError
|
PASS (''): InvalidCharacterError
|
||||||
PASS ('0'): InvalidCharacterError
|
PASS ('='): InvalidCharacterError
|
||||||
|
|
|
@ -2,13 +2,13 @@ Harness status: OK
|
||||||
|
|
||||||
Found 67 tests
|
Found 67 tests
|
||||||
|
|
||||||
65 Pass
|
66 Pass
|
||||||
2 Fail
|
1 Fail
|
||||||
Pass When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (toggleAttribute)
|
Pass When qualifiedName does not match the Name production, an INVALID_CHARACTER_ERR exception is to be thrown. (toggleAttribute)
|
||||||
Pass toggleAttribute should lowercase its name argument (upper case attribute)
|
Pass toggleAttribute should lowercase its name argument (upper case attribute)
|
||||||
Pass toggleAttribute should lowercase its name argument (mixed case attribute)
|
Pass toggleAttribute should lowercase its name argument (mixed case attribute)
|
||||||
Pass toggleAttribute should not throw even when qualifiedName starts with 'xmlns'
|
Pass toggleAttribute should not throw even when qualifiedName starts with 'xmlns'
|
||||||
Fail Basic functionality should be intact. (toggleAttribute)
|
Pass Basic functionality should be intact. (toggleAttribute)
|
||||||
Pass toggleAttribute should not change the order of previously set attributes.
|
Pass toggleAttribute should not change the order of previously set attributes.
|
||||||
Pass toggleAttribute should set the first attribute with the given name
|
Pass toggleAttribute should set the first attribute with the given name
|
||||||
Pass toggleAttribute should set the attribute with the given qualified name
|
Pass toggleAttribute should set the attribute with the given qualified name
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
element.toggleAttribute("0");
|
element.toggleAttribute("=");
|
||||||
println("FAIL ('0')");
|
println("FAIL ('=')");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
println("PASS ('0'): " + err.name);
|
println("PASS ('='): " + err.name);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue