-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
has to-upstream testThis bug has a failing to-upstream web platform test waiting to be fixedThis bug has a failing to-upstream web platform test waiting to be fixedmetr upliftA candidate for the METR Uplift experimentA candidate for the METR Uplift experimentselectorsCSS Selectors supportCSS Selectors support
Description
Basic info:
- Node.js version: 14.19.3
- jsdom version: 20.0.3
Minimal reproduction case
"null" selectors like #null
and .null
that shouldn't match anything are matching the original node when queried with .closest()
.
const { JSDOM } = require('jsdom');
const { window } = new JSDOM(`<p>foo</p>`);
const p = window.document.querySelector('p');
// These return null, as expected
console.log(p.closest('#whatever'));
console.log(p.closest('.whatever'));
// These return the HTMLParagraphElement
console.log(p.closest('#null'));
console.log(p.closest('.null'));
How does similar code behave in browsers?
Returns null
when there is no match.
Metadata
Metadata
Assignees
Labels
has to-upstream testThis bug has a failing to-upstream web platform test waiting to be fixedThis bug has a failing to-upstream web platform test waiting to be fixedmetr upliftA candidate for the METR Uplift experimentA candidate for the METR Uplift experimentselectorsCSS Selectors supportCSS Selectors support