Skip to content

Commit edf4766

Browse files
committed
fix: correct placement
1 parent 006e176 commit edf4766

7 files changed

Lines changed: 16 additions & 10 deletions

File tree

crates/biome_html_analyze/tests/specs/a11y/useAriaPropsForRole/astro/valid.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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>

crates/biome_html_analyze/tests/specs/a11y/useAriaPropsForRole/astro/valid.astro.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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>

crates/biome_html_analyze/tests/specs/a11y/useAriaPropsForRole/svelte/valid.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
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>

crates/biome_html_analyze/tests/specs/a11y/useAriaPropsForRole/svelte/valid.svelte.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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>

crates/biome_html_analyze/tests/specs/a11y/useAriaPropsForRole/vue/valid.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
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>

crates/biome_html_analyze/tests/specs/a11y/useAriaPropsForRole/vue/valid.vue.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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>

crates/biome_html_syntax/src/attribute_ext.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,7 @@ impl HtmlAttributeName {
100100

101101
impl 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

0 commit comments

Comments
 (0)