capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.14k stars 189 forks source link

Regression in `:is()` pseudo class function #1333

Closed asamuzaK closed 4 months ago

asamuzaK commented 4 months ago

Things that used to be handled correctly with :is() are regressed in happy-com v14.

document.body.innerHTML = `<div id="parent">
  <p id="child">child</p>
</div>`;
const node = document.getElementById('child');

console.log(node.matches(':is(:last-child, :only-child)'));
// expects `true`, but gets `false`

console.log(node.matches(':is(:invalid-nth-child, :only-child)'));
// expects `true`, but gets `false`

Actual logs: Last good (Mar 9, 2024): https://github.com/asamuzaK/domSelector/actions/runs/8213032502/job/22463958026#step:5:17 First bad (Mar 16, 2024): https://github.com/asamuzaK/domSelector/actions/runs/8307223087/job/22736188722#step:5:17 NOTE: Empty result means that unexpected value, i.e. false in this case, is returned.

capricorn86 commented 4 months ago

Thank you for reporting @asamuzaK! :slightly_smiling_face:

Happy DOM actually didn't have support for the :is() pseudo selector. The reason for why it was passing before is probably because Happy DOM matched unsupported pseudo selectors as a positive match, which was fixed in v13.8.5.

I have added support for the :is() pseudo selector now.

You can read more about the release here: https://github.com/capricorn86/happy-dom/releases/tag/v14.2.0