Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using getComputedStyle with jsdom

I fail to get the computed style value of color with jsdom:

require("jsdom").env({
    html: '<html><head><style> html { color: red; } </style></head><body></body></html>',
    done: function(errors, window) {

        console.log('color: "'+window.getComputedStyle(window.document.body).color+'"');
    }
});

The previous test returns "" instead of "rgb(255, 0, 0)" or "red" ...
(note that this work properly in a browser)

Do I miss something ?

like image 841
Franck Freiburger Avatar asked Aug 01 '26 04:08

Franck Freiburger


1 Answers

It seems like jsdom does not implement inheritance for getComputedStyle.

If you get the computed style of the html tag it should work however.

like image 95
Sebmaster Avatar answered Aug 03 '26 19:08

Sebmaster