1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:57:43 +00:00

LibWeb: Bring HTMLElement.offset{Left,Top,Parent} closer to spec

(Or rather, bring offsetLeft and offsetTop closer to spec, and implement
the previously-missing offsetParent)

This makes mouse inputs on https://nerget.com/fluidSim/ work properly.
This commit is contained in:
Andreas Kling 2023-12-10 13:47:16 +01:00
parent 43e9dc0500
commit cfe9577b48
5 changed files with 143 additions and 14 deletions

View file

@ -0,0 +1,21 @@
nodeName: CANVAS
offsetTop: 0
offsetLeft: 0
offsetParent: [object HTMLTableCellElement]
nodeName: TD
offsetTop: 2
offsetLeft: 2
offsetParent: [object HTMLTableElement]
nodeName: TABLE
offsetTop: 100
offsetLeft: 50
offsetParent: [object HTMLBodyElement]
nodeName: BODY
offsetTop: 0
offsetLeft: 0
offsetParent: null

View file

@ -0,0 +1,26 @@
<style>
* {
margin: 0;
padding: 0;
}
table {
position: relative;
top: 100px;
left: 50px;
}
</style><table><tr><td><canvas id="c"></canvas></td></tr></table>
<script src="../include.js"></script>
<script>
test(() => {
const c = document.getElementById("c");
println("");
for (let n = c; n; n = n.offsetParent) {
println("nodeName: " + n.nodeName);
println("offsetTop: " + n.offsetTop);
println("offsetLeft: " + n.offsetLeft);
println("offsetParent: " + n.offsetParent);
println("");
}
});
</script>