|
12 | 12 |
|
13 | 13 | import {act, waitFor, within} from '@testing-library/react'; |
14 | 14 | import {MenuTesterOpts, UserOpts} from './types'; |
15 | | -import {nodeContains} from '@react-aria/utils'; |
16 | 15 | import {triggerLongPress} from './events'; |
17 | 16 |
|
18 | 17 | interface MenuOpenOpts { |
@@ -216,7 +215,7 @@ export class MenuTester { |
216 | 215 | return; |
217 | 216 | } |
218 | 217 |
|
219 | | - if (document.activeElement !== menu && !nodeContains(menu, document.activeElement)) { |
| 218 | + if (document.activeElement !== menu && !menu.contains(document.activeElement)) { |
220 | 219 | act(() => menu.focus()); |
221 | 220 | } |
222 | 221 |
|
@@ -263,7 +262,7 @@ export class MenuTester { |
263 | 262 | // close. In React 16, focus actually makes it all the way to the root menu's submenu trigger so we need check the root menu |
264 | 263 | if (this._isSubmenu) { |
265 | 264 | await waitFor(() => { |
266 | | - if (document.activeElement === this.trigger || nodeContains(this._rootMenu, document.activeElement)) { |
| 265 | + if (document.activeElement === this.trigger || this._rootMenu?.contains(document.activeElement)) { |
267 | 266 | throw new Error('Expected focus after selecting an submenu option to move away from the original submenu trigger.'); |
268 | 267 | } else { |
269 | 268 | return true; |
@@ -343,7 +342,7 @@ export class MenuTester { |
343 | 342 | private async keyboardNavigateToOption(opts: {option: HTMLElement}) { |
344 | 343 | let {option} = opts; |
345 | 344 | let options = this.options(); |
346 | | - let targetIndex = options.findIndex(opt => (opt === option) || nodeContains(opt, option)); |
| 345 | + let targetIndex = options.findIndex(opt => (opt === option) || opt.contains(option)); |
347 | 346 |
|
348 | 347 | if (targetIndex === -1) { |
349 | 348 | throw new Error('Option provided is not in the menu'); |
@@ -379,7 +378,7 @@ export class MenuTester { |
379 | 378 | } |
380 | 379 | }); |
381 | 380 |
|
382 | | - if (nodeContains(document, menu)) { |
| 381 | + if (document.contains(menu)) { |
383 | 382 | throw new Error('Expected the menu to not be in the document after closing it.'); |
384 | 383 | } |
385 | 384 | } |
|
0 commit comments