You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears an nth-child selector inside another nth-child selector returns null.
To Reproduce
Steps to reproduce the behavior:
Visit this codepen and see that the HTML can be queried with the selector '#test-one tbody tr:nth-child(1) td:nth-child(3)' and logs:
<td>
2.6 mi
</td>
Create this jest unit test with the same HTML and selector and see that it logs dom node: null when run:
const HTML_SNIPPET = `
<tableid="test-one"><thead><tr><th>
Agency
</th><th><button>
Languages
</button></th><th><button>
Distance
</button></th></tr></thead><tbody><tr><td>
Alpha
</td><td>
English
</td><td>
2.6 mi
</td></tr><tr><td>
Beta
</td><td>
English, Spanish
</td><td>
1.4 mi
</td></tr><tr><td>
Gamma
</td><td>
English, French, Spanish
</td><td>
1.4 mi
</td></tr><tr><td>
Delta
</td><td>
English, Spanish
</td><td>
3.2 mi
</td></tr><tr><td>
Epsilon
</td><td>
English
</td><td>
1.6 mi
</td></tr><tr><td>
Zeta
</td><td>
English, Spanish
</td><td>
1.2 mi
</td></tr><tr><td>
Eta
</td><td>
English
</td><td>
11.1 mi
</td></tr></tbody></table>
`;
describe( 'Table', () => {
beforeEach( () => {
document.body.innerHTML = HTML_SNIPPET;
} );
it( 'should have the .sort-up class sort table on load', () => {
const selector = '#test-one tbody tr:nth-child(1) td:nth-child(3)';
const dom = document.querySelector( selector );
console.log( 'dom node:', dom );
} );
} );
Change query to '#test-one tbody tr:nth-child(1) td' and see that dom node: HTMLTableCellElement {} is logged, appearing to indicate issue is with the inner nth-child query in the selector.
Expected behavior
Jest and codepen example should behave the same way in regard to selectors.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 Bug Report
It appears an
nth-child
selector inside anothernth-child
selector returnsnull
.To Reproduce
Steps to reproduce the behavior:
'#test-one tbody tr:nth-child(1) td:nth-child(3)'
and logs:dom node: null
when run:'#test-one tbody tr:nth-child(1) td'
and see thatdom node: HTMLTableCellElement {}
is logged, appearing to indicate issue is with the innernth-child
query in the selector.Expected behavior
Jest and codepen example should behave the same way in regard to selectors.
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: