|
118 | 118 | <button data-next slot="d">button 4</button> |
119 | 119 | </div> |
120 | 120 | </template> |
121 | | -<template data-description="Focus navigation starting point should be used when it's a descendant of the focused element."> |
122 | | - <div tabindex="0" data-focus> |
123 | | - <button data-prev id="button1">button 1</button> |
124 | | - <span data-click>in between</span> |
125 | | - <button data-next id="button2">button 2</button> |
126 | | - </div> |
127 | | -</template> |
128 | | -<template data-description="Backwards focus navigation should not be stuck when starting point is inside focused element but before any other focusable areas."> |
129 | | - <button data-prev id="button1">button 1</button> |
130 | | - <div tabindex="0" id="focusable" data-focus> |
131 | | - <span data-click>in between</span> |
132 | | - <button data-next id="button2">button 2</button> |
133 | | - </div> |
134 | | -</template> |
135 | | -<template data-description="Should start from focused element if it was focused after the selection was set."> |
136 | | - <button id="button1">button 1</button> |
137 | | - <span data-click>in between</span> |
138 | | - <button id="button2">button 2</button> |
139 | | - <button id="button3" data-prev>button 3</button> |
140 | | - <div tabindex="0" id="focusable" data-focus2>focusable</div> |
141 | | - <button id="button4" data-next>button 4</button> |
142 | | -</template> |
143 | 121 |
|
144 | 122 | <script> |
145 | 123 | "use strict"; |
|
148 | 126 | const kTab = "\uE004"; |
149 | 127 |
|
150 | 128 | // Runs callback on each element matching selector, descending into open shadow roots. |
151 | | -async function forEachMatching(selector, callback, root) { |
| 129 | +function forEachMatching(selector, callback, root) { |
152 | 130 | if (!root) { root = container; } |
153 | 131 | for (let element of root.querySelectorAll(selector)) { |
154 | | - await callback(element); |
| 132 | + callback(element); |
155 | 133 | } |
156 | 134 | for (let element of root.querySelectorAll("[data-shadow]")) { |
157 | | - if (element.shadowRoot) { |
158 | | - await forEachMatching(selector, callback, element.shadowRoot); |
159 | | - } |
| 135 | + forEachMatching(selector, callback, element.shadowRoot); |
160 | 136 | } |
161 | 137 | } |
162 | 138 |
|
|
173 | 149 | forEachMatching("[data-focus]", element => { |
174 | 150 | element.focus(); |
175 | 151 | }); |
176 | | - await forEachMatching("[data-click]", test_driver.click); |
177 | 152 | forEachMatching("[data-blur]", element => { |
178 | 153 | element.blur(); |
179 | 154 | }); |
|
201 | 176 | forEachMatching("[data-reenable]", element => { |
202 | 177 | element.disabled = false; |
203 | 178 | }); |
204 | | - forEachMatching("[data-focus2]", element => { |
205 | | - element.focus(); |
206 | | - }); |
207 | 179 |
|
208 | 180 | let actions = new test_driver.Actions(); |
209 | 181 | if (backwards) { |
|
0 commit comments