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

Allow linkNodes to accept props #211

Closed
william-deckard opened this issue Jan 22, 2020 · 5 comments
Closed

Allow linkNodes to accept props #211

william-deckard opened this issue Jan 22, 2020 · 5 comments

Comments

@william-deckard
Copy link

FEATURE REQUEST:

Users should be able to configure which styles they want linked rather than an "all or nothing" approach that "copyStyles (boolean)" provides.

I ran into an issue recently where our cloud application displays 200+ images in a scrollable view. When I wanted to print a customize component that I had nested as a child the 206 images were being loaded each time print was toggled. Obviously this is a performance issue. I was able to get around this my going into the source code and removing "img" from being pulled in as a linked node but would be nice to disable images from being pulled in as well as other custom linking configuration that users can provide.

const linkNodes = document.querySelectorAll("link[rel='stylesheet'], img");
---> to
const linkNodes = document.querySelectorAll("link[rel='stylesheet']");
was my change but perhaps:

const defaultQuerySelector = "link[rel='stylesheet'], img";
const linkNodes = document.querySelectorAll(this.props.querySelectors || defaultQuerySelector);
@MatthewHerbst
Copy link
Owner

Hello. We actually recently just made the change to include img to ensure images that are printed are loaded before the print window opens. Maybe we can optimize it by only selecting images there are children of the ref being printed?

@william-deckard
Copy link
Author

@MatthewHerbst That would be perfect!

@MatthewHerbst
Copy link
Owner

MatthewHerbst commented Jan 23, 2020

@william-deckard any idea what the best way to do that might be (i.e., what the selector(s) would be?

@william-deckard
Copy link
Author

@MatthewHerbst Let me give it a think, I will pull the repo and work with it. Should I find a good solution I will open a PR.

@MatthewHerbst
Copy link
Owner

@william-deckard This should be fixed in 2.7.0, where only img nodes that are children of the React component being printed are loaded. Please let me know if you see any issues!

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

No branches or pull requests

2 participants