nwsapi
nwsapi copied to clipboard
The `:nth-child(even)` selector no longer works
This test used to work fine in nwsapi 2.2.0:
<table>
<tbody>
<tr id="tr1">
<td>1</td>
</tr>
<tr id="tr2">
<td>2</td>
</tr>
<tr id="tr3">
<td>3</td>
</tr>
<tr id="tr4">
<td>4</td>
</tr>
<tr id="tr5">
<td>5</td>
</tr>
<tr id="tr6">
<td>6</td>
</tr>
<tr id="tr7">
<td>7</td>
</tr>
</tbody>
</table>
mywrapper.querySelectorAll('table tr:nth-child(even)');
This query should return 3 elements: tr2, tr4 & tr6. And it did in version 2.2.0 But in the latest version (2.2.7) it returns no matches.
The same goes for :nth-child(odd)
@skerit can you please send a minimal but complete failing test case and specify your browser / environment ?
The HTML fragment you sent seems to be working for me in a standard browser environment.
<!doctype html>
<html>
<head>
<title>NWSAPI Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="src/nwsapi.js" onload="NW.Dom.install()"></script>
</head>
<body>
<table>
<tbody>
<tr id="tr1">
<td>1</td>
</tr>
<tr id="tr2">
<td>2</td>
</tr>
<tr id="tr3">
<td>3</td>
</tr>
<tr id="tr4">
<td>4</td>
</tr>
<tr id="tr5">
<td>5</td>
</tr>
<tr id="tr6">
<td>6</td>
</tr>
<tr id="tr7">
<td>7</td>
</tr>
</tbody>
</table>
<script>console.log(document.querySelectorAll('table tr:nth-child(even)'));</script>
</body>
</html>