mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-11 18:50:50 +00:00
LibWeb: Implement setRangeText for input and textarea elements
This method replaces range of text in its respective element with a new string
This commit is contained in:
parent
206262cd55
commit
2f5b070716
Notes:
github-actions[bot]
2024-08-31 09:50:48 +00:00
Author: https://github.com/tcl3
Commit: 2f5b070716
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1223
Reviewed-by: https://github.com/awesomekling
10 changed files with 217 additions and 4 deletions
|
@ -0,0 +1,42 @@
|
|||
<!DOCTYPE html>
|
||||
<div id="container">
|
||||
<textarea id="textarea"></textarea>
|
||||
<input id="passwordInput" type="password" value="test">
|
||||
<input id="searchInput" type=search value="test">
|
||||
<input id="telInput" type="tel" value="test">
|
||||
<input id="textInput" type="text" value="test">
|
||||
<input id="urlInput" type="url" value="test">
|
||||
<input id="invalidInput" type="checkbox" value="test">
|
||||
</div>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const invalidInput = document.getElementById('invalidInput');
|
||||
try {
|
||||
invalidInput.setRangeText('foo');
|
||||
println("FAIL");
|
||||
} catch (e) {
|
||||
println(`Calling setRangeText() on an element where setRangeText doesn't apply throws: ${e.name}`);
|
||||
}
|
||||
|
||||
const validInputs = [
|
||||
document.getElementById('textarea'),
|
||||
document.getElementById('passwordInput'),
|
||||
document.getElementById('searchInput'),
|
||||
document.getElementById('telInput'),
|
||||
document.getElementById('textInput'),
|
||||
document.getElementById('urlInput')
|
||||
];
|
||||
|
||||
for (let input of validInputs) {
|
||||
input.setRangeText("foo");
|
||||
println(`setRangeText("foo") on: ${input.type} - Value: ${input.value}`);
|
||||
|
||||
input.value = "test";
|
||||
input.setRangeText("foo", 1, 3);
|
||||
println(`setRangeText("foo", 1, 3) on: ${input.id} - Value: ${input.value}`);
|
||||
}
|
||||
|
||||
document.getElementById("container").remove();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue