Skip to content

document.implementation.createHTMLDocument breaks HTMLStyleElement.sheet #3179

@Qendolin

Description

@Qendolin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions