Basic info:
- Node.js version: 14.6.0
- jsdom version: 16.5.3
Might be related to #1779
This bug does not occur when the document is the default document (window.document).
Minimal reproduction case
const { JSDOM } = require('jsdom');
const dom = new JSDOM();
const document = dom.window.document;
const styleDoc = document.implementation.createHTMLDocument('');
const styleElem = document.createElement('style');
styleElem.textContent = `.test { color: red; }`;
styleDoc.body.appendChild(styleElem);
console.log(styleElem.sheet); // null
How does similar code behave in browsers?
styleElem.sheet is a CSSStyleSheet. See example.