mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-26 04:07:51 +00:00
LibWeb: Ensure document.getElementById("")
returns null
Previously, if a document had an element whose id was the empty string, then `document.getElementById("")` and `element.getElementById("")` would return that element.
This commit is contained in:
parent
18499c4eac
commit
f666d967d6
Notes:
github-actions[bot]
2024-07-23 06:59:28 +00:00
Author: https://github.com/tcl3
Commit: f666d967d6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/773
3 changed files with 10 additions and 1 deletions
|
@ -0,0 +1 @@
|
||||||
|
document.getElementById(""): null
|
|
@ -0,0 +1,8 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<div id=""></div>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
println(`document.getElementById(""): ${document.getElementById("")}`);
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -457,7 +457,7 @@ void Element::attribute_changed(FlyString const& name, Optional<String> const&,
|
||||||
auto value_or_empty = value.value_or(String {});
|
auto value_or_empty = value.value_or(String {});
|
||||||
|
|
||||||
if (name == HTML::AttributeNames::id) {
|
if (name == HTML::AttributeNames::id) {
|
||||||
if (!value.has_value())
|
if (value_or_empty.is_empty())
|
||||||
m_id = {};
|
m_id = {};
|
||||||
else
|
else
|
||||||
m_id = value_or_empty;
|
m_id = value_or_empty;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue