jsdom / cssstyle

A Node.js implementation of the CSS Object Model CSSStyleDeclaration interface
MIT License
109 stars 70 forks source link

Add transform property #49

Closed piec closed 6 years ago

piec commented 7 years ago

Hi,

I use jsdom to pre-render a dom with d3 but it's missing the transform styles This commit adds support for transform

Also mentioned in tmpvar/jsdom#1321 and NV/CSSOM#78

Cheers

hraban commented 7 years ago

Is this planned for merging ever? I'm currently using

mynode.attributes['style'].value += ' transform: translate(-50%, -50%);';

which is a bit of an eye sore :P

Hikariii commented 7 years ago

What is the problem with merging this?

Hikariii commented 7 years ago

A temporary work-around can be this:

Object.defineProperty(jsDom.window._core.CSSStyleDeclaration.prototype, 'transform', {
    get : function () {
        return this.getPropertyValue('transform');
    },
    set : function (v) {
        this._setProperty('transform', v);
    },
    enumerable: true,
    configurable: true
});