mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
Previously, the label called `HTMLElement::click()` which dispatched a synthetic event with all properties set to their default values. We now preserve the properties of the original mouse event.
50 lines
1.3 KiB
HTML
50 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<style>
|
|
body {
|
|
margin: 0;
|
|
}
|
|
label {
|
|
display: block;
|
|
width: 100px;
|
|
height: 20px;
|
|
}
|
|
input {
|
|
display: block;
|
|
margin: 0;
|
|
border: 0;
|
|
padding: 0;
|
|
width: 100px;
|
|
height: 20px;
|
|
}
|
|
</style>
|
|
<label for="input" id="label">hello</label>
|
|
<input id="input">
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
asyncTest((done) => {
|
|
let labelEventProps = null;
|
|
|
|
label.addEventListener("click", (e) => {
|
|
if (e.target === label) {
|
|
labelEventProps = {
|
|
clientX: e.clientX,
|
|
clientY: e.clientY,
|
|
};
|
|
}
|
|
});
|
|
|
|
input.addEventListener("click", (e) => {
|
|
println(`target: ${e.target.id}`);
|
|
println(`clientX preserved from label event: ${e.clientX === labelEventProps.clientX}`);
|
|
println(`clientY preserved from label event: ${e.clientY === labelEventProps.clientY}`);
|
|
|
|
const inputRect = input.getBoundingClientRect();
|
|
println(`offsetX relative to input: ${e.offsetX === labelEventProps.clientX - inputRect.left}`);
|
|
println(`offsetY relative to input: ${e.offsetY === labelEventProps.clientY - inputRect.top}`);
|
|
done();
|
|
});
|
|
|
|
internals.click(50, 10);
|
|
});
|
|
</script>
|