mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-30 21:24:44 +00:00
LibWeb: Ensure document.getElementsByName("")
returns no elements
Previously, if a document had any element with a name attribute that was set to the empty string, then `document.getElementsByName("")` and `element.getElementsByName("")` would return a collection including those elements. (cherry picked from commit e40352b6b59e99a9f3fd922142c2abafd9840e6c)
This commit is contained in:
parent
d3c2d2ba3f
commit
e399a716fa
|
@ -0,0 +1 @@
|
|||
document.getElementsByName("").length: 0
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<div name=""></div>
|
||||
<script>
|
||||
test(() => {
|
||||
println(`document.getElementsByName("").length: ${document.getElementsByName("").length}`);
|
||||
});
|
||||
</script>
|
|
@ -463,7 +463,7 @@ void Element::attribute_changed(FlyString const& name, Optional<String> const&,
|
|||
|
||||
document().element_id_changed({}, *this);
|
||||
} else if (name == HTML::AttributeNames::name) {
|
||||
if (!value.has_value())
|
||||
if (value_or_empty.is_empty())
|
||||
m_name = {};
|
||||
else
|
||||
m_name = value_or_empty;
|
||||
|
|
Loading…
Reference in a new issue