-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HTML: make dir=auto and dirname apply to more form controls
For whatwg/html#9689. Helps with #25569 as this area was barely tested. (Also correct some typos while here.)
- Loading branch information
Showing
6 changed files
with
79 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
html/dom/elements/global-attributes/dir-auto-form-associated.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Keep this mostly synchronized with | ||
// html/semantics/forms/attributes-common-to-form-controls/dirname-only-if-applies.html | ||
// except that won't have "reset" and "button" as those don't submit their value | ||
[ | ||
"hidden", | ||
"text", | ||
"search", | ||
"tel", | ||
"url", | ||
"email", | ||
"password", | ||
"submit", | ||
"reset", | ||
"button" | ||
].forEach(type => { | ||
test(t => { | ||
const input = document.createElement("input"); | ||
t.add_cleanup(() => input.remove()); | ||
input.type = type; | ||
assert_equals(input.type, type); | ||
input.dir = "auto"; | ||
input.value = "\u05D0"; // The Hebrew letter Alef (strongly RTL) | ||
document.body.append(input); | ||
assert_true(input.matches(":dir(rtl)")); | ||
}, `<input dir=auto type=${type}> directionality`); | ||
}); | ||
|
||
[ | ||
"date", | ||
"month", | ||
"week", | ||
"time", | ||
"datetime-local", | ||
"number", | ||
"range", | ||
"color", | ||
"checkbox", | ||
"radio", | ||
// "file" // value setter throws | ||
"image" | ||
].forEach(type => { | ||
test(t => { | ||
const input = document.createElement("input"); | ||
t.add_cleanup(() => input.remove()); | ||
input.type = type; | ||
assert_equals(input.type, type); | ||
input.dir = "auto"; | ||
input.value = "\u05D0"; // The Hebrew letter Alef (strongly RTL) | ||
document.body.append(input); | ||
assert_true(input.matches(":dir(ltr)")); | ||
}, `<input dir=auto type=${type}> directionality`); | ||
}); | ||
|
||
test(t => { | ||
const input = document.createElement("textarea"); | ||
t.add_cleanup(() => input.remove()); | ||
input.dir = "auto"; | ||
input.value = "\u05D0"; // The Hebrew letter Alef (strongly RTL) | ||
document.body.append(input); | ||
assert_true(input.matches(":dir(rtl)")); | ||
}, `<textarea dir=auto> directionality`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters