mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 07:07:49 +00:00
LibWeb: Update attribute name validation in Element.setAttribute()
This now follows the latest specification steps.
This commit is contained in:
parent
acf2d773d5
commit
ba641d4784
Notes:
github-actions[bot]
2025-06-19 10:02:13 +00:00
Author: https://github.com/tcl3
Commit: ba641d4784
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5140
Reviewed-by: https://github.com/AtkinsSJ ✅
7 changed files with 67 additions and 7 deletions
|
@ -211,8 +211,8 @@ GC::Ptr<Attr> Element::get_attribute_node_ns(Optional<FlyString> const& namespac
|
|||
// https://dom.spec.whatwg.org/#dom-element-setattribute
|
||||
WebIDL::ExceptionOr<void> Element::set_attribute(FlyString const& name, String const& value)
|
||||
{
|
||||
// 1. If qualifiedName does not match the Name production in XML, then throw an "InvalidCharacterError" DOMException.
|
||||
if (!Document::is_valid_name(name.to_string()))
|
||||
// 1. If qualifiedName is not a valid attribute local name, then throw an "InvalidCharacterError" DOMException.
|
||||
if (!is_valid_attribute_local_name(name))
|
||||
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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue