| 166 |
166 |
|
FieldKind::Email => "email",
|
| 167 |
167 |
|
FieldKind::Url => "url",
|
| 168 |
168 |
|
FieldKind::Tel => "tel",
|
|
169 |
+ |
// The same argument, and it buys more here than anywhere else in this
|
|
170 |
+ |
// list: a native picker as well as the keyboard and the validation.
|
|
171 |
+ |
// Both submit the format `makeover-layout` names, `DATE_FORMAT` and
|
|
172 |
+ |
// `DATETIME_FORMAT`, so honouring it costs this renderer nothing.
|
|
173 |
+ |
FieldKind::Date => "date",
|
|
174 |
+ |
FieldKind::DateTime => "datetime-local",
|
| 169 |
175 |
|
FieldKind::Radio => "radio",
|
| 170 |
176 |
|
// Select and Textarea are not inputs at all; they never reach here.
|
| 171 |
177 |
|
// Radio is one, but it is emitted once per option by `radio_html` and
|
| 893 |
899 |
|
(FieldKind::Email, "email"),
|
| 894 |
900 |
|
(FieldKind::Url, "url"),
|
| 895 |
901 |
|
(FieldKind::Tel, "tel"),
|
|
902 |
+ |
(FieldKind::Date, "date"),
|
|
903 |
+ |
(FieldKind::DateTime, "datetime-local"),
|
| 896 |
904 |
|
] {
|
| 897 |
905 |
|
let html = field_html(&field(kind), &Filling::default(), &Emit::default());
|
| 898 |
906 |
|
assert!(
|
| 902 |
910 |
|
}
|
| 903 |
911 |
|
}
|
| 904 |
912 |
|
|
|
913 |
+ |
#[test]
|
|
914 |
+ |
fn a_temporal_field_is_a_native_control_and_not_a_hinted_text_box() {
|
|
915 |
+ |
// The regression this closes: described as text with a hint reading
|
|
916 |
+ |
// "YYYY-MM-DD", which loses the picker, the platform's validation and
|
|
917 |
+ |
// the touch keyboard, and asks prose to do all three.
|
|
918 |
+ |
for kind in [FieldKind::Date, FieldKind::DateTime] {
|
|
919 |
+ |
let html = field_html(&field(kind), &Filling::default(), &Emit::default());
|
|
920 |
+ |
assert!(!html.contains(r#"type="text""#), "{kind:?} emitted {html}");
|
|
921 |
+ |
}
|
|
922 |
+ |
}
|
|
923 |
+ |
|
| 905 |
924 |
|
#[test]
|
| 906 |
925 |
|
fn no_prefix_leaves_the_id_as_the_name() {
|
| 907 |
926 |
|
let html = field_html(
|