File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -533,6 +533,7 @@ getByRole(
533
533
role : TextMatch ,
534
534
options ?: {
535
535
exact?: boolean = true ,
536
+ hidden?: boolean = false ,
536
537
normalizer?: NormalizerFn ,
537
538
}): HTMLElement
538
539
```
@@ -544,6 +545,27 @@ attribute. The
544
545
[ W3C HTML recommendation] ( https://www.w3.org/TR/html5/index.html#contents ) lists
545
546
all HTML elements with their default aria roles.
546
547
548
+ If you set ` hidden ` to ` true ` elements that are normally excluded from the
549
+ accessibility tree are considered for the query as well. The default behavior
550
+ follows https://www.w3.org/TR/wai-aria-1.2/#tree_exclusion with the exception of
551
+ ` role="none" ` and ` role="presentation" ` which are considered in the query in any
552
+ case. For example in
553
+
554
+ ``` html
555
+ <body >
556
+ <main aria-hidden =" true" >
557
+ <button >Open dialog</button >
558
+ </main >
559
+ <div role =" dialog" >
560
+ <button >Close dialog</button >
561
+ </div >
562
+ </body >
563
+ ```
564
+
565
+ ` getByRole('button') ` would only return the ` Close dialog ` -button. To make
566
+ assertions about the ` Open dialog ` -button you would need to use
567
+ ` getAllByRole('button', { hidden: true }) ` .
568
+
547
569
``` html
548
570
<div role =" dialog" >...</div >
549
571
```
You can’t perform that action at this time.
0 commit comments