-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
5 changed files
with
68 additions
and
6 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
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,60 @@ | ||
// Keep this synchronized with | ||
// html/semantics/forms/attributes-common-to-form-controls/dirname-only-if-applies.html | ||
[ | ||
"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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<title>Languages</title> | ||
<link rel="author" title="Ms2ger" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-lang-and-xml:lang-attributes"> | ||
<link tel="help" href="http://www.w3.org/TR/CSS2/selector.html#lang"> | ||
<link rel="help" href="http://www.w3.org/TR/CSS2/selector.html#lang"> | ||
<meta name="flags" content="css21"> | ||
<style> | ||
#test > * { background: limegreen; } | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<link rel="match" href="lang-xmllang-01-ref.html"> | ||
<link rel="author" title="Ms2ger" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-lang-and-xml:lang-attributes"> | ||
<link tel="help" href="http://www.w3.org/TR/CSS2/selector.html#lang"> | ||
<link rel="help" href="http://www.w3.org/TR/CSS2/selector.html#lang"> | ||
<meta name="flags" content="css21"> | ||
<style> | ||
#test #a :lang(en) { background: limegreen; } | ||
|
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<link rel="match" href="lang-xyzzy-ref.html"> | ||
<link rel="author" title="Ms2ger" href="mailto:[email protected]"> | ||
<link rel="help" href="https://html.spec.whatwg.org/multipage/#the-lang-and-xml:lang-attributes"> | ||
<link tel="help" href="http://www.w3.org/TR/CSS2/selector.html#lang"> | ||
<link rel="help" href="http://www.w3.org/TR/CSS2/selector.html#lang"> | ||
<meta name="flags" content="css21"> | ||
<style>:lang(xyzzy) { color: green; }</style> | ||
<body> | ||
|
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