Skip to content

Implement CSS custom properties #1895

@nschomberg

Description

@nschomberg

Basic info:

  • Node v8.1.2
  • jsdom v11.0.0

Minimal reproduction case

const { JSDOM } = require("jsdom");

const dom = new JSDOM(`<!DOCTYPE html><p>Hello world</p>`);

dom.window.document.querySelector(":root").style.setProperty('--var', 'red');
dom.window.document.querySelector(":root").style.setProperty('color', 'red');

console.log(dom.window.document.querySelector(":root").style);
// CSSStyleDeclaration {
//     '0': 'color',
//     _values: { color: 'red' },
//     _importants: { '--var': undefined, color: undefined },
//     _length: 1,
//     _onChange: [Function],
//     Var: 'red' }

How does similar code behave in browsers?

Example: https://jsbin.com/xolomolexe/edit?js,console

In other browsers, CSS custom properties get applied like regular style properties.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions