Skip to content

getComputedStyle doesn't return a default opacity value "1", but empty string #3339

@thusimon

Description

@thusimon

Basic info:

  • **Node.js version: v16.13.2
  • **jsdom version: 19.0.0

Minimal reproduction case

const { JSDOM } = require("jsdom");
const options = {
  contentType: 'text/html'
};
const dom = new JSDOM('<html><head></head><body></body></html>', options);
const input = dom.window.document.createElement('input');
input.type = 'text';
dom.window.document.body.append(input);
const styles = dom.window.getComputedStyle(input);
console.log(`opacity=${styles.getPropertyValue('opacity')}
display=${styles.getPropertyValue('display')}`);

actual output

opacity=
display=inline-block

expected output

opacity=1
display=inline-block

How does similar code behave in browsers?

in browser (latest Chrome and Firefox), if an element doesn't specify the opacity, getPropertyValue('opacity') would return '1'
While in current jsdom, it return empty string

Metadata

Metadata

Assignees

No one assigned

    Labels

    csshas to-upstream testThis bug has a failing to-upstream web platform test waiting to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions