mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 02:59:45 +00:00
LibWeb: Implement the HTMLInputElement.width
attribute
This allows the width of an image button input to be set and queried.
This commit is contained in:
parent
8e3adbe082
commit
45a2823e08
Notes:
github-actions[bot]
2024-11-30 10:19:31 +00:00
Author: https://github.com/tcl3
Commit: 45a2823e08
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2645
5 changed files with 79 additions and 4 deletions
|
@ -2,10 +2,19 @@
|
|||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
function testProperty(elementName, propertyName, propertyGetter, propertySetter) {
|
||||
function testProperty(elementNameOrFactory, propertyName, propertyGetter, propertySetter) {
|
||||
const attributeName = propertyName.toLowerCase();
|
||||
function setValue(value) {
|
||||
let element = document.createElement(elementName);
|
||||
let element;
|
||||
let elementName;
|
||||
if (typeof elementNameOrFactory === "string") {
|
||||
element = document.createElement(elementNameOrFactory);
|
||||
elementName = elementNameOrFactory;
|
||||
} else {
|
||||
element = elementNameOrFactory();
|
||||
elementName = element.tagName.toLowerCase();
|
||||
}
|
||||
|
||||
element.setAttribute(attributeName, value.toString());
|
||||
println(`${elementName}.getAttribute("${attributeName}") after ${elementName}.setAttribute("${propertyName}", "${value}"): ${element.getAttribute(`${attributeName}`)}`);
|
||||
println(`${elementName}.${propertyName} after ${elementName}.setAttribute("${attributeName}", "${value}"): ${propertyGetter(element)}`);
|
||||
|
@ -16,7 +25,7 @@
|
|||
println(`${elementName}.getAttribute("${attributeName}") after ${elementName}.${propertyName} = ${value}: ${element.getAttribute(attributeName)}`);
|
||||
println(`${elementName}.${propertyName} after ${elementName}.${propertyName} = ${value}: ${propertyGetter(element)}`);
|
||||
} catch (e) {
|
||||
println(`${elementName}.${propertyName} = ${value} threw exception of type ${e.name}`);
|
||||
println(`${elementName}.${propertyName} = ${value} threw exception of type ${e.name}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,8 +36,15 @@
|
|||
setValue(4294967295);
|
||||
}
|
||||
|
||||
const imageButtonInputFactory = () => {
|
||||
const input = document.createElement("input");
|
||||
input.type = "image";
|
||||
return input;
|
||||
}
|
||||
|
||||
testProperty("img", "hspace", (img) => img.hspace, (img, value) => img.hspace = value);
|
||||
testProperty("input", "size", (input) => input.size, (input, value) => input.size = value);
|
||||
testProperty(imageButtonInputFactory, "width", (input) => input.width, (input, value) => input.width = value);
|
||||
testProperty("marquee", "scrollAmount", (marquee) => marquee.scrollAmount, (marquee, value) => marquee.scrollAmount = value);
|
||||
testProperty("marquee", "scrollDelay", (marquee) => marquee.scrollDelay, (marquee, value) => marquee.scrollDelay = value);
|
||||
testProperty("select", "size", (select) => select.size, (select, value) => select.size = value);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue