-
Notifications
You must be signed in to change notification settings - Fork 89
Description
svgexport creates a pseudo-page on about:blank and then dumps the previously modified and grabbed SVG contents in there, in order to get a proper HTML with a screenshottable div. However, this means that (1) the new page is at an isolated location, and (2) the page is not loaded with the file:// protocol like local SVG files are usually.
This leads to two problems with SVGs that use the <image> tag to import other SVGs or images.
- If the images use a relative import, that's broken. The images will just not show up.
- If the images use a
file://protocol, even if the path is absolute, it also doesn't work. The images are replaced by a "file missing" icon and my guess is that the browser forbids theabout:blankpage to load stuff with thefile://protocol.
A fix would be to create an empty HTML file in the current location with a random name (and error out if it exists), then navigate to that. This would both allow the file:// URLs as well as relative imports. The file should of course be deleted before the program ends. I have had success with a workaround that changes render.js line 162 to use a local "sacrificial" HTML file.
To be clear: this is an issue with the way svgexport uses puppeteer, not an issue with puppeteer itself. All of this is expected Chromium behavior.