Files
formipay/node_modules/@wordpress/dom/src/test/tabbable.js
dwindown e8fbfb14c1 fix: prevent asset conflicts between React and Grid.js versions
Add coexistence checks to all enqueue methods to prevent loading
both React and Grid.js assets simultaneously.

Changes:
- ReactAdmin.php: Only enqueue React assets when ?react=1
- Init.php: Skip Grid.js when React active on admin pages
- Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0
- Customer.php, Product.php, License.php: Add coexistence checks

Now the toggle between Classic and React versions works correctly.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-18 17:02:14 +07:00

118 lines
3.5 KiB
JavaScript

/**
* Internal dependencies
*/
import createElement from './utils/create-element';
import { find } from '../tabbable';
describe( 'tabbable', () => {
beforeEach( () => {
document.body.innerHTML = '';
} );
describe( 'find()', () => {
it( 'returns focusables in order of tabindex', () => {
const node = createElement( 'div' );
const absent = createElement( 'input' );
absent.tabIndex = -1;
const first = createElement( 'input' );
const second = createElement( 'span' );
second.tabIndex = 0;
const third = createElement( 'input' );
third.tabIndex = 1;
node.appendChild( third );
node.appendChild( first );
node.appendChild( second );
node.appendChild( absent );
const tabbables = find( node );
expect( tabbables ).toEqual( [ first, second, third ] );
} );
it( 'consolidates radio group to the first, if unchecked', () => {
const node = createElement( 'div' );
const firstRadio = createElement( 'input' );
firstRadio.type = 'radio';
firstRadio.name = 'a';
firstRadio.value = 'firstRadio';
const secondRadio = createElement( 'input' );
secondRadio.type = 'radio';
secondRadio.name = 'a';
secondRadio.value = 'secondRadio';
const text = createElement( 'input' );
text.type = 'text';
text.name = 'b';
const thirdRadio = createElement( 'input' );
thirdRadio.type = 'radio';
thirdRadio.name = 'a';
thirdRadio.value = 'thirdRadio';
const fourthRadio = createElement( 'input' );
fourthRadio.type = 'radio';
fourthRadio.name = 'b';
fourthRadio.value = 'fourthRadio';
const fifthRadio = createElement( 'input' );
fifthRadio.type = 'radio';
fifthRadio.name = 'b';
fifthRadio.value = 'fifthRadio';
node.appendChild( firstRadio );
node.appendChild( secondRadio );
node.appendChild( text );
node.appendChild( thirdRadio );
node.appendChild( fourthRadio );
node.appendChild( fifthRadio );
const tabbables = find( node );
expect( tabbables ).toEqual( [ firstRadio, text, fourthRadio ] );
} );
it( 'consolidates radio group to the checked', () => {
const node = createElement( 'div' );
const firstRadio = createElement( 'input' );
firstRadio.type = 'radio';
firstRadio.name = 'a';
firstRadio.value = 'firstRadio';
const secondRadio = createElement( 'input' );
secondRadio.type = 'radio';
secondRadio.name = 'a';
secondRadio.value = 'secondRadio';
const text = createElement( 'input' );
text.type = 'text';
text.name = 'b';
const thirdRadio = createElement( 'input' );
thirdRadio.type = 'radio';
thirdRadio.name = 'a';
thirdRadio.value = 'thirdRadio';
thirdRadio.checked = true;
node.appendChild( firstRadio );
node.appendChild( secondRadio );
node.appendChild( text );
node.appendChild( thirdRadio );
const tabbables = find( node );
expect( tabbables ).toEqual( [ text, thirdRadio ] );
} );
it( 'not consolidate unnamed radio inputs', () => {
const node = createElement( 'div' );
const firstRadio = createElement( 'input' );
firstRadio.type = 'radio';
firstRadio.value = 'firstRadio';
const text = createElement( 'input' );
text.type = 'text';
text.name = 'b';
const secondRadio = createElement( 'input' );
secondRadio.type = 'radio';
secondRadio.value = 'secondRadio';
node.appendChild( firstRadio );
node.appendChild( text );
node.appendChild( secondRadio );
const tabbables = find( node );
expect( tabbables ).toEqual( [ firstRadio, text, secondRadio ] );
} );
} );
} );