Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backgroundColor: 'var(--blue)' doesn't render on Chrome #433

Open
Fish1 opened this issue Sep 14, 2023 · 2 comments
Open

backgroundColor: 'var(--blue)' doesn't render on Chrome #433

Fish1 opened this issue Sep 14, 2023 · 2 comments
Labels

Comments

@Fish1
Copy link

Fish1 commented Sep 14, 2023

CSS variables should be rendered to the background color.

Current Behavior

Chrome doesn't render backgroundColor when it is set to a variable.
Firefox renders it properly.

Possible Solution

Not sure at the moment.

Steps To Reproduce

  it('should render backgroundColor with variable', (done) => {
    bootstrap(
      'bgcolor-variable/node.html',
      'bgcolor-variable/style.css',
      'bgcolor-variable/image',
    )
      .then((node) => {
        return toPng(node, {
          backgroundColor: 'var(--blue)',
        })
      })
      .then((res) => {
        console.log(res)
        check(res)
      })
      .then(done)
      .catch(done)
  })
:root {
  --blue: #1e90ff;
}

#dom-node {
  height: 100px;
  width: 100px;
}

#content {
  height: 50px;
  width: 50px;
}
Error Message & Stack Trace

<!-- Provide a log message if relevant -->

Additional Context

Your Environment

Chrome

@Fish1 Fish1 added the bug label Sep 14, 2023
@vivcat
Copy link
Contributor

vivcat bot commented Sep 14, 2023

👋 @Fish1

Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.

We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

@Justineo
Copy link

AFAIK CSS custom properties are not iterable from CSSStyleDeclaration (returned from getComputedStyle) so in current implementation they won't be reflected in the snapshot image.

I made a PR (#436) which added a includeStyleProperties option which allow users to manually specify the included properties. Though I added it for performance reasons, I believe it's also helpful in the custom properties' case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants