Skip to content

Commit 1051565

Browse files
jonathanKingstonbodil
authored andcommitted
Adding support for the ARIA role attribute
1 parent d0b4955 commit 1051565

File tree

3 files changed

+142
-1
lines changed

3 files changed

+142
-1
lines changed

examples/stdweb/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use typed_html::output::stdweb::Stdweb;
1010

1111
fn main() {
1212
let mut doc = html!(
13-
<div>
13+
<div role="main">
1414
<h1>"Hello Kitty"</h1>
1515
<p>
1616
"She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em>

macros/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub fn global_attrs(span: Span) -> StringyMap<Ident, TokenStream> {
2828
insert("hidden", "crate::types::Bool");
2929
insert("is", "String");
3030
insert("lang", "crate::types::LanguageTag");
31+
insert("role", "crate::types::Role");
3132
insert("style", "String");
3233
insert("tabindex", "isize");
3334
insert("title", "String");

typed-html/src/types/mod.rs

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,146 @@ pub enum ReferrerPolicy {
300300
UnsafeUrl,
301301
}
302302

303+
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
304+
pub enum Role {
305+
#[strum(to_string = "any")]
306+
Any,
307+
#[strum(to_string = "alert")]
308+
Alert,
309+
#[strum(to_string = "alertdialog")]
310+
AlertDialog,
311+
#[strum(to_string = "application")]
312+
Application,
313+
#[strum(to_string = "article")]
314+
Article,
315+
#[strum(to_string = "banner")]
316+
Banner,
317+
#[strum(to_string = "checkbox")]
318+
Checkbox,
319+
#[strum(to_string = "cell")]
320+
Cell,
321+
#[strum(to_string = "columnheader")]
322+
ColumnHeader,
323+
#[strum(to_string = "combobox")]
324+
ComboBox,
325+
#[strum(to_string = "complementary")]
326+
Complementary,
327+
#[strum(to_string = "contentinfo")]
328+
ContentInfo,
329+
#[strum(to_string = "definition")]
330+
Definition,
331+
#[strum(to_string = "dialog")]
332+
Dialog,
333+
#[strum(to_string = "directory")]
334+
Directory,
335+
#[strum(to_string = "document")]
336+
Document,
337+
#[strum(to_string = "feed")]
338+
Feed,
339+
#[strum(to_string = "figure")]
340+
Figure,
341+
#[strum(to_string = "form")]
342+
Form,
343+
#[strum(to_string = "grid")]
344+
Grid,
345+
#[strum(to_string = "gridcell")]
346+
GridCell,
347+
#[strum(to_string = "group")]
348+
Group,
349+
#[strum(to_string = "heading")]
350+
Heading,
351+
#[strum(to_string = "img")]
352+
Image,
353+
#[strum(to_string = "link")]
354+
Link,
355+
#[strum(to_string = "list")]
356+
List,
357+
#[strum(to_string = "listbox")]
358+
ListBox,
359+
#[strum(to_string = "listitem")]
360+
ListItem,
361+
#[strum(to_string = "log")]
362+
Log,
363+
#[strum(to_string = "main")]
364+
Main,
365+
#[strum(to_string = "marquee")]
366+
Marquee,
367+
#[strum(to_string = "math")]
368+
Math,
369+
#[strum(to_string = "menu")]
370+
Menu,
371+
#[strum(to_string = "menubar")]
372+
MenuBar,
373+
#[strum(to_string = "menuitem")]
374+
MenuItem,
375+
#[strum(to_string = "menuitemcheckbox")]
376+
MenuItemCheckbox,
377+
#[strum(to_string = "menuitemradio")]
378+
MenuItemRadio,
379+
#[strum(to_string = "navigation")]
380+
Navigation,
381+
#[strum(to_string = "none")]
382+
None,
383+
#[strum(to_string = "note")]
384+
Note,
385+
#[strum(to_string = "option")]
386+
Option,
387+
#[strum(to_string = "presentation")]
388+
Presentation,
389+
#[strum(to_string = "progressbar")]
390+
ProgressBar,
391+
#[strum(to_string = "radio")]
392+
Radio,
393+
#[strum(to_string = "radiogroup")]
394+
RadioGroup,
395+
#[strum(to_string = "region")]
396+
Region,
397+
#[strum(to_string = "row")]
398+
Row,
399+
#[strum(to_string = "rowgroup")]
400+
RowGroup,
401+
#[strum(to_string = "rowheader")]
402+
RowHeader,
403+
#[strum(to_string = "scrollbar")]
404+
ScrollBar,
405+
#[strum(to_string = "search")]
406+
Search,
407+
#[strum(to_string = "searchbox")]
408+
SearchBox,
409+
#[strum(to_string = "separator")]
410+
Separator,
411+
#[strum(to_string = "slider")]
412+
Slider,
413+
#[strum(to_string = "spinbutton")]
414+
SpinButton,
415+
#[strum(to_string = "status")]
416+
Status,
417+
#[strum(to_string = "switch")]
418+
Switch,
419+
#[strum(to_string = "tab")]
420+
Tab,
421+
#[strum(to_string = "table")]
422+
Table,
423+
#[strum(to_string = "tablist")]
424+
TabList,
425+
#[strum(to_string = "tabpanel")]
426+
TabPanel,
427+
#[strum(to_string = "term")]
428+
Term,
429+
#[strum(to_string = "textbox")]
430+
TextBox,
431+
#[strum(to_string = "timer")]
432+
Timer,
433+
#[strum(to_string = "toolbar")]
434+
ToolBar,
435+
#[strum(to_string = "tooltip")]
436+
ToolTip,
437+
#[strum(to_string = "tree")]
438+
Tree,
439+
#[strum(to_string = "treegrid")]
440+
TreeGrid,
441+
}
442+
303443
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
304444
pub enum Sandbox {
305445
#[strum(to_string = "allow-forms")]

0 commit comments

Comments
 (0)