Skip to content

Add related dynamic attributes example #6108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions docs/ui-coverage/configuration/attributefilters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,43 @@ For every attribute that an element has, the first `attributeFilters` rule for w
```
.user (2 instances)
```

### Filtering related dynamic attributes

When filtering dynamic `id` attributes, you should also filter attributes that reference those IDs to prevent elements from being identified by these related dynamic values. Common relationships include:

- Form associations (`for` attributes on labels)
- ARIA relationships (`aria-labelledby`, `aria-describedby`, `aria-controls`, `aria-owns`, `aria-details`)
- Name attributes that may mirror IDs in certain frameworks

```json
{
"uiCoverage": {
"attributeFilters": [
{
"attribute": "id|for|name|aria-.*",
"value": "dynamic-.*",
"include": false
}
]
}
}
```

#### HTML

```xml
<div>
<label for="dynamic-input-1">First Name</label>
<input id="dynamic-input-1" name="dynamic-input-1" aria-describedby="dynamic-help-1" />
<p id="dynamic-help-1">Enter your first name</p>
</div>
```

#### Elements shown in UI Coverage

```
label
input
p
```