jsdom / cssstyle

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

Support more css3 syntax #32

Closed chad3814 closed 5 years ago

chad3814 commented 9 years ago

to do things right would require a big overhaul to the parsers I think. might make sense to use jison or some other context-free grammar parser.

jsakas commented 5 years ago

Closing for inactivity.

skratchdot commented 5 years ago

It'd be nice to re-open this. I just ran into this and it was driving me crazy. I had some code that effectively does this:

if (props.imageurl) {
  styles.backgroundImage = `url(${props.imageurl}), url(default.png)`;
} else {
  styles.backgroundImage = `url(default.png)`;
}

Then I had 2 tests using react-testing-library. 1 was working, 1 wasn't.

expect(div.style.backgroundImage).toEqual('url(default.png)') worked, and my test with: expect(div.style.backgroundImage).toEqual('url(test.png), url(default.png)') failed b/c the string was empty.

I did a bunch of debugging, and knew I was setting the backgroundImage appropriately, but jsdom wasn't recognized the attribute.

skratchdot commented 5 years ago

^^ actually- I don't care if the Support more css3 syntax issue is re-opened. But I would like to see jsdom support multiple background images.

skratchdot commented 5 years ago

it might be as easy as calling v.split(',') somewhere, and looping through the array calling the same parseUrl() code: https://github.com/jsdom/cssstyle/blob/master/lib/properties/backgroundImage.js#L6

i've never looked at this codebase before, but might try to work on something if i get some time. thanks for your work on this!!!

skratchdot commented 5 years ago

I logged a new issue for my request: https://github.com/jsdom/cssstyle/issues/103

I'll try to submit a PR this week.