element.matches can throw an unexpected error for certain selectors.
Here is an example to reproduce the issue in the browser (assuming nwsapi.js is included in a <script> tag):
const div = document.createElement('div');
div.innerHTML = '<div class="b"><div class="c"></div></div>';
//document.documentElement.appendChild(div); // Doesn't matter if this is executed or not
const c = div.querySelector('.c');
const selector = '.a:nth-last-of-type(1) .b .c';
console.log(c.matches(selector)); // Okay with native DOM
console.log(NW.Dom.match(selector, c)); // Throws
Uncaught TypeError: Cannot read property 'parentElement' of null
at Array.Resolver (eval at compile (nwsapi.js:768), <anonymous>:3:129)
at match_assert (nwsapi.js:1351)
at Object._matches [as match] (nwsapi.js:1415)
element.matches
can throw an unexpected error for certain selectors.Here is an example to reproduce the issue in the browser (assuming nwsapi.js is included in a
<script>
tag):