@@ -483,14 +483,44 @@ The {{Element/getSpatialNavigationContainer()}} method must follow these steps:
483483
484484<div algorithm="focusableAreas steps">
485485The {{Element/focusableAreas()}} method must follow these steps:
486- 1. Let <var> v </var> be <code> false</code>
487- if the argument's {{FocusableAreasOptions/mode}} attribute if present and equal to <code> " all" </code> ,
486+ 1. Let <var> visibleOnly </var> be <code> false</code>
487+ if the argument's {{FocusableAreasOptions/mode}} attribute is present and equal to <code> ' all' </code> ,
488488 or <code> true</code> otherwise.
489- 4. Let <var> areas</var> be the result of <a>finding focusable areas</a> within the element with the visibleOnly argument set to <var> v</var>
489+ 2. Let <var> areas</var> be the result of <a>finding focusable areas</a> within the element with the <var> visibleOnly</var> argument.
490+ 3. Loop: If there is a <a>spatial navigation container</a> <var> container</var> among <var> areas</var> ,
491+ then add the result of <a>finding focusable areas</a> to <var> areas</var> within the <var> container</var> .
4904925. Let <var> anchors</var> be a <a for=list>clone</a> of <var> areas</var> ,
491493 with every <a>focusable area</a> which is not itself a <a>Node</a> replaced with its <a>DOM anchor</a> .
4924946. Return <var> anchors</var>
495+ </div>
496+
497+ <div class=example id=focusAreas-visible>
498+ The following code shows how to get all the visible focusable elements in the current page using {{Element/focusableAreas()}} .
499+ If the method finds a <a>spatial navigation container</a> , it recursively finds focusable areas inside it.
500+ However, <code> 'visible' </code> is given to the {{FocusableAreasOptions/mode}} attribute of this method,
501+ the focusable element which isn’t inside the <a>scrollport</a> is excluded from the result.
493502
503+ <pre><code highlight=markup>
504+ <body>
505+ <button class="box" style="top:100px; left:20px;"></button>
506+ <div class="container" style="left:110px; width:300px; height:200px; overflow-x: scroll;">
507+ <button class="box" style="top:78px; left:25px;"></button>
508+ <button class="box" style="top: 80px; left:150px;"></button>
509+ <button class="box" style="top: 80px; left:350px;"></button>
510+ </div>
511+ </body>
512+ </code></pre>
513+ <pre><code highlight=javascript>
514+ const focusableAreas = document.body.focusableAreas({'mode' : 'visible' });
515+ focusableAreas && focusableAreas.forEach(focusable => {
516+ focusable.style.outline = '5px solid red' ;
517+ });
518+ </code></pre>
519+ The figure below is the result of this code.
520+ <figure>
521+ <img alt="An image about focusableAreas()" src="images/focusableareas-visible-example.png" style="width: 450px;"/>
522+ <figcaption> Find all visible focusable areas inside the document.</figcaption>
523+ </figure>
494524</div>
495525
496526<div algorithm="spatialNavigationSearch steps">
@@ -863,11 +893,11 @@ and it cannot be scrolled at the same time.
863893 For the sake of keeping the description simple,
864894 this example assumes a UA where spatial navigation is triggered using arrow keys.
865895
866- <figure>
867- <img alt="An image about navnotarget" src="images/navnotarget-example-1.png" style="width: 200px;"/>
868- <figcaption> Moving focus when there isn't any candidate in the
869- <a>scroll container</a> .</figcaption>
870- </figure>
896+ <figure>
897+ <img alt="An image about navnotarget" src="images/navnotarget-example-1.png" style="width: 200px;"/>
898+ <figcaption> Moving focus when there isn't any candidate in the
899+ <a>scroll container</a> .</figcaption>
900+ </figure>
871901
872902 <table class="complex data">
873903 <thead>
0 commit comments