mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 03:56:16 +00:00
LibWeb: Implement "plaintext-only" state for contenteditable
This commit is contained in:
parent
7e406ac668
commit
217567981a
Notes:
github-actions[bot]
2024-12-02 23:21:14 +00:00
Author: https://github.com/gmta
Commit: 217567981a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2697
Reviewed-by: https://github.com/awesomekling
Reviewed-by: https://github.com/tcl3
5 changed files with 104 additions and 14 deletions
|
@ -0,0 +1,45 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#attr-contenteditable">
|
||||
<link rel="help" href="https://html.spec.whatwg.org/#enumerated-attribute">
|
||||
<meta name="assert" content="@contenteditable values are ASCII case-insensitive">
|
||||
<script src="../../../../resources/testharness.js"></script>
|
||||
<script src="../../../../resources/testharnessreport.js"></script>
|
||||
|
||||
<script>
|
||||
function testValue(value, isValid) {
|
||||
const valueLower = value.toLowerCase();
|
||||
|
||||
test(() => {
|
||||
const el = document.createElement('div');
|
||||
if (valueLower !== "inherit") {
|
||||
el.setAttribute('contenteditable', value);
|
||||
}
|
||||
assert_equals(el.contentEditable, isValid ? valueLower : "inherit");
|
||||
}, `IDL attribute getter for attribute value "${value}"`);
|
||||
|
||||
test(() => {
|
||||
const el = document.createElement('div');
|
||||
if (isValid) {
|
||||
el.contentEditable = value;
|
||||
assert_equals(el.getAttribute('contenteditable'), valueLower === "inherit" ? null : valueLower);
|
||||
} else {
|
||||
assert_throws_dom("SyntaxError", () => {
|
||||
el.contentEditable = value;
|
||||
});
|
||||
}
|
||||
}, `IDL attribute setter for value "${value}"`);
|
||||
}
|
||||
|
||||
const valid = ["true", "false", "inherit", "plaintext-only"]; // "inherit" is treated specially
|
||||
const invalid = ["foobar", "falſe", "plaıntext-only", "plaİntext-only"];
|
||||
|
||||
for (const value of valid) {
|
||||
testValue(value, true);
|
||||
testValue(value.toUpperCase(), true);
|
||||
}
|
||||
|
||||
for (const value of invalid) {
|
||||
testValue(value, false);
|
||||
}
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue