mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-17 07:50:04 +00:00
LibWeb: Only put connected elements into document's by-name-or-id cache
This fixes an issue where disconnected elements were incorrectly accessible as named properties on the document.
This commit is contained in:
parent
5f1a146afd
commit
12f5e9c5f8
Notes:
github-actions[bot]
2025-03-03 23:52:46 +00:00
Author: https://github.com/awesomekling
Commit: 12f5e9c5f8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3784
3 changed files with 95 additions and 12 deletions
64
Tests/LibWeb/Text/input/HTML/document-named-shenanigans.html
Normal file
64
Tests/LibWeb/Text/input/HTML/document-named-shenanigans.html
Normal file
|
@ -0,0 +1,64 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
function go(tagName) {
|
||||
println("Testing <" + tagName + "> element");
|
||||
|
||||
let a = [];
|
||||
|
||||
let e = document.createElement(tagName);
|
||||
a.push(document.shenanigans);
|
||||
|
||||
e.setAttribute("name", "shenanigans");
|
||||
a.push(document.shenanigans);
|
||||
|
||||
e.setAttribute("name", "mischief");
|
||||
a.push(document.shenanigans);
|
||||
a.push(document.mischief);
|
||||
|
||||
e.name = "shenanigans";
|
||||
a.push(document.shenanigans);
|
||||
a.push(document.mischief);
|
||||
|
||||
document.body.appendChild(e);
|
||||
a.push(document.shenanigans);
|
||||
|
||||
e.remove();
|
||||
a.push(document.shenanigans);
|
||||
|
||||
document.body.appendChild(e);
|
||||
a.push(document.shenanigans);
|
||||
|
||||
e.removeAttribute("name");
|
||||
a.push(document.hijinks);
|
||||
|
||||
e.setAttribute("id", "hijinks");
|
||||
a.push(document.hijinks);
|
||||
|
||||
document.body.appendChild(e);
|
||||
a.push(document.hijinks);
|
||||
|
||||
e.remove();
|
||||
a.push(document.hijinks);
|
||||
|
||||
document.body.appendChild(e);
|
||||
a.push(document.hijinks);
|
||||
|
||||
e.removeAttribute("id");
|
||||
a.push(document.hijinks);
|
||||
|
||||
e.remove();
|
||||
a.push(document.hijinks);
|
||||
|
||||
println(a);
|
||||
|
||||
println("");
|
||||
}
|
||||
|
||||
test(() => {
|
||||
go("div");
|
||||
go("form");
|
||||
go("img");
|
||||
go("embed");
|
||||
go("object");
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue