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

Filter out css variables in Firefox #194

Open
1 of 2 tasks
NogaMan opened this issue Oct 11, 2024 · 0 comments · May be fixed by #200
Open
1 of 2 tasks

Filter out css variables in Firefox #194

NogaMan opened this issue Oct 11, 2024 · 0 comments · May be fixed by #200

Comments

@NogaMan
Copy link

NogaMan commented Oct 11, 2024

Use case:

Copied from the issue in the main repo (which seems forgotten).

I have a page with lots of css variables (around 1333) set in :root, and each of them gets copied into each element inside the canvas, because apparently in Firefox, getComputedStyle returns not only all styles, but all of the applied css variables as well.

Is it possible to add an option something like filterStyles that we could use to filter out which computed styles we want to be included in the saved image and which not? We could use filtering by -- prefix to filter out CSS variables.

Expected behavior

await domtoimage.toJpeg(element,{
  filterStyles(node, propertyName) {
    return !propertyName.startssWith('--');
  }
)

Actual behavior (stack traces, console logs etc)

Currently all 1300 css variables are set on each node, making the image file so big that it fails to be saved in Firefox

Library version

2.6.0

Browsers

  • Chrome 49+
  • Firefox 45+
@ludovic ludovic linked a pull request Nov 8, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant