Adding support for the ARIA role attribute

This commit is contained in:
Jonathan Kingston 2019-05-19 14:19:21 +01:00 committed by Bodil Stokke
parent d0b4955ba0
commit 105156542e
3 changed files with 142 additions and 1 deletions

View File

@ -10,7 +10,7 @@ use typed_html::output::stdweb::Stdweb;
fn main() { fn main() {
let mut doc = html!( let mut doc = html!(
<div> <div role="main">
<h1>"Hello Kitty"</h1> <h1>"Hello Kitty"</h1>
<p> <p>
"She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em> "She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em>

View File

@ -28,6 +28,7 @@ pub fn global_attrs(span: Span) -> StringyMap<Ident, TokenStream> {
insert("hidden", "crate::types::Bool"); insert("hidden", "crate::types::Bool");
insert("is", "String"); insert("is", "String");
insert("lang", "crate::types::LanguageTag"); insert("lang", "crate::types::LanguageTag");
insert("role", "crate::types::Role");
insert("style", "String"); insert("style", "String");
insert("tabindex", "isize"); insert("tabindex", "isize");
insert("title", "String"); insert("title", "String");

View File

@ -300,6 +300,146 @@ pub enum ReferrerPolicy {
UnsafeUrl, UnsafeUrl,
} }
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
pub enum Role {
#[strum(to_string = "any")]
Any,
#[strum(to_string = "alert")]
Alert,
#[strum(to_string = "alertdialog")]
AlertDialog,
#[strum(to_string = "application")]
Application,
#[strum(to_string = "article")]
Article,
#[strum(to_string = "banner")]
Banner,
#[strum(to_string = "checkbox")]
Checkbox,
#[strum(to_string = "cell")]
Cell,
#[strum(to_string = "columnheader")]
ColumnHeader,
#[strum(to_string = "combobox")]
ComboBox,
#[strum(to_string = "complementary")]
Complementary,
#[strum(to_string = "contentinfo")]
ContentInfo,
#[strum(to_string = "definition")]
Definition,
#[strum(to_string = "dialog")]
Dialog,
#[strum(to_string = "directory")]
Directory,
#[strum(to_string = "document")]
Document,
#[strum(to_string = "feed")]
Feed,
#[strum(to_string = "figure")]
Figure,
#[strum(to_string = "form")]
Form,
#[strum(to_string = "grid")]
Grid,
#[strum(to_string = "gridcell")]
GridCell,
#[strum(to_string = "group")]
Group,
#[strum(to_string = "heading")]
Heading,
#[strum(to_string = "img")]
Image,
#[strum(to_string = "link")]
Link,
#[strum(to_string = "list")]
List,
#[strum(to_string = "listbox")]
ListBox,
#[strum(to_string = "listitem")]
ListItem,
#[strum(to_string = "log")]
Log,
#[strum(to_string = "main")]
Main,
#[strum(to_string = "marquee")]
Marquee,
#[strum(to_string = "math")]
Math,
#[strum(to_string = "menu")]
Menu,
#[strum(to_string = "menubar")]
MenuBar,
#[strum(to_string = "menuitem")]
MenuItem,
#[strum(to_string = "menuitemcheckbox")]
MenuItemCheckbox,
#[strum(to_string = "menuitemradio")]
MenuItemRadio,
#[strum(to_string = "navigation")]
Navigation,
#[strum(to_string = "none")]
None,
#[strum(to_string = "note")]
Note,
#[strum(to_string = "option")]
Option,
#[strum(to_string = "presentation")]
Presentation,
#[strum(to_string = "progressbar")]
ProgressBar,
#[strum(to_string = "radio")]
Radio,
#[strum(to_string = "radiogroup")]
RadioGroup,
#[strum(to_string = "region")]
Region,
#[strum(to_string = "row")]
Row,
#[strum(to_string = "rowgroup")]
RowGroup,
#[strum(to_string = "rowheader")]
RowHeader,
#[strum(to_string = "scrollbar")]
ScrollBar,
#[strum(to_string = "search")]
Search,
#[strum(to_string = "searchbox")]
SearchBox,
#[strum(to_string = "separator")]
Separator,
#[strum(to_string = "slider")]
Slider,
#[strum(to_string = "spinbutton")]
SpinButton,
#[strum(to_string = "status")]
Status,
#[strum(to_string = "switch")]
Switch,
#[strum(to_string = "tab")]
Tab,
#[strum(to_string = "table")]
Table,
#[strum(to_string = "tablist")]
TabList,
#[strum(to_string = "tabpanel")]
TabPanel,
#[strum(to_string = "term")]
Term,
#[strum(to_string = "textbox")]
TextBox,
#[strum(to_string = "timer")]
Timer,
#[strum(to_string = "toolbar")]
ToolBar,
#[strum(to_string = "tooltip")]
ToolTip,
#[strum(to_string = "tree")]
Tree,
#[strum(to_string = "treegrid")]
TreeGrid,
}
#[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)] #[derive(EnumString, Display, PartialEq, Eq, PartialOrd, Ord, AsRefStr, AsStaticStr)]
pub enum Sandbox { pub enum Sandbox {
#[strum(to_string = "allow-forms")] #[strum(to_string = "allow-forms")]