bug: `<fieldset>` considered `:disabled` if it contains `<legend>`
Basic info:
- Node.js version: v12.16.1
- jsdom version: v17.0.0
Minimal reproduction case
https://replit.com/@PhilippFritsche/jsdom-pseudoclass#index.js
const { JSDOM } = require('jsdom')
const { window } = new JSDOM(`
<fieldset>
<legend>foo</legend>
</fieldset>
`)
// should be null but is <fieldset>
console.log(window.document.querySelector(':disabled'))
How does similar code behave in browsers?
https://codesandbox.io/s/jsdom-pseudoclass-s1iub?file=/src/App.js
A <fieldset> is :disabled in JSDOM if it contains a <legend>.
This is not the case in browsers.
Perfect bug report, thank you!
Can you also check if window.document.querySelector("fieldset").disabled is true or false? That'd help narrow down whether it's a bug in jsdom, or a bug in our selector library.
disabled property is false.
Added it to the replit.
This is affecting multiple of my unit tests as well. Really appreciate you filing this report @ph-fritsche
I believe this was a bug in the nwsapi library, which wasn't correctly taking into account fieldset elements that do not have a legend. I've opened a PR that I think will fix this issue: https://github.com/dperini/nwsapi/pull/125
Example from my nwsapi changes:
And before my changes: (fieldset is incorrectly selected)