File tree Expand file tree Collapse file tree
biome_html_analyze/tests/specs/a11y/useAriaPropsForRole Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<!-- should not generate diagnostics -->
2+ <span role ={ roleValue } ></span >
3+ <span {role }></span >
24<span role =" checkbox" aria-checked =" true" ></span >
35<span role =" combobox" aria-controls =" true" aria-expanded =" true" ></span >
46<span role =" heading" aria-level =" 1" ></span >
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ expression: valid.astro
55# Input
66` ` ` astro
77<!-- should not generate diagnostics -->
8+ <span role = { roleValue } ></span >
9+ <span { role } ></span >
810<span role = " checkbox" aria-checked = " true" ></span >
911<span role = " combobox" aria-controls = " true" aria-expanded = " true" ></span >
1012<span role = " heading" aria-level = " 1" ></span >
Original file line number Diff line number Diff line change 11<!-- should not generate diagnostics -->
2+ <span role ={roleValue }></span >
3+ <span {role }></span >
24<span role =" checkbox" aria-checked =" true" ></span >
35<span role =" combobox" aria-controls =" true" aria-expanded =" true" ></span >
46<span role =" heading" aria-level =" 1" ></span >
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ expression: valid.svelte
55# Input
66` ` ` svelte
77<!-- should not generate diagnostics -->
8+ <span role = { roleValue } ></span >
9+ <span { role } ></span >
810<span role = " checkbox" aria-checked = " true" ></span >
911<span role = " combobox" aria-controls = " true" aria-expanded = " true" ></span >
1012<span role = " heading" aria-level = " 1" ></span >
Original file line number Diff line number Diff line change 11<!-- should not generate diagnostics: Vue v-bind shorthand (:aria-*) bindings satisfy required aria props -->
22<template >
3+ <span :role =" roleValue" ></span >
34 <span role =" checkbox" :aria-checked =" isChecked" ></span >
45 <span role =" radio" :aria-checked =" true" ></span >
56 <span role =" switch" :aria-checked =" dynamicValue" ></span >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ expression: valid.vue
66` ` ` vue
77<!-- should not generate diagnostics: Vue v-bind shorthand (:aria-*) bindings satisfy required aria props -->
88<template >
9+ <span :role="roleValue"></span>
910 <span role = " checkbox" :aria-checked="isChecked"></span>
1011 <span role = " radio" :aria-checked="true"></span>
1112 <span role = " switch" :aria-checked="dynamicValue"></span>
Original file line number Diff line number Diff line change @@ -100,16 +100,7 @@ impl HtmlAttributeName {
100100
101101impl Attribute for AnyHtmlAttribute {
102102 fn name ( & self ) -> Option < impl AsRef < str > > {
103- match self {
104- // Shorthand attributes like `{href}` use the expression text as the attribute name.
105- Self :: HtmlAttributeSingleTextExpression ( expr) => expr
106- . expression ( )
107- . ok ( ) ?
108- . html_literal_token ( )
109- . ok ( )
110- . map ( |token| token. token_text_trimmed ( ) ) ,
111- _ => self . name ( ) ,
112- }
103+ self . name ( )
113104 }
114105
115106 fn value ( & self ) -> Option < impl AsRef < str > > {
@@ -121,6 +112,11 @@ impl AnyHtmlAttribute {
121112 pub fn name ( & self ) -> Option < TokenText > {
122113 match self {
123114 Self :: HtmlAttribute ( attr) => attr. name ( ) . ok ( ) ?. token_text_trimmed ( ) ,
115+ Self :: HtmlAttributeSingleTextExpression ( attr) => attr
116+ . expression ( )
117+ . ok ( )
118+ . and_then ( |expr| expr. html_literal_token ( ) . ok ( ) )
119+ . map ( |html_literal| html_literal. token_text_trimmed ( ) ) ,
124120 Self :: AnyVueDirective ( vue) => match vue {
125121 // :attr="..." — shorthand Vue binding
126122 AnyVueDirective :: VueVBindShorthandDirective ( d) => d
You can’t perform that action at this time.
0 commit comments