html2canvas: Clone node: Setting className for SVG element raises error
Please make sure you are testing with the latest release of html2canvas. Old versions are not supported and issues reported for them will be closed.
Please follow the general troubleshooting steps first:
- You are using the latest version
- You are testing using the non-minified version of html2canvas and checked any potential issues reported in the console
Bug reports:
Setting className for SVG element will raise error, here’s some stack trace, I’m using the non minified js version. I thinks the reason is probably I’m using fontawesome 5 SVG icon
MY_PROJECT_PATH/lib/html2canvas.js:5304 Uncaught (in promise) TypeError: Cannot assign to read only property 'className' of object '#<SVGSVGElement>'
at DocumentCloner.resolvePseudoContent (VM4414 html2canvas.js:5304)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5200)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at DocumentCloner.cloneNode (VM4414 html2canvas.js:5207)
at new DocumentCloner (VM4414 html2canvas.js:5006)
at VM4414 html2canvas.js:6900
at step (VM4414 html2canvas.js:83)
at Object.next (VM4414 html2canvas.js:64)
at VM4414 html2canvas.js:57
at new Promise (<anonymous>)
at __awaiter (VM4414 html2canvas.js:53)
at renderElement (VM4414 html2canvas.js:6857)
at html2canvas (VM4414 html2canvas.js:6854)
Specifications:
- html2canvas version tested with: 1.0.0-rc3
- Browser & version: Electron 4 / Chromium 69
- Operating system: macOS
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 11
- Comments: 31
Commits related to this issue
- Added check to use baseVal for svg elements — committed to ahardin13/html2canvas by deleted user 5 years ago
- Downgrade html2canvas to 1.0.0-alpha.12 because the latest version raise this issue https://github.com/niklasvh/html2canvas/issues/1868 — committed to TIBHannover/orkg-frontend by Reddine 5 years ago
- fix: #1868 Clone node, Setting className for SVG element raises error — committed to hal1984/html2canvas by JorgeDiazDiazDiaz 5 years ago
- fix: #1868 Clone node, Setting className for SVG element raises error (#2079) * fix: #1868 Clone node, Setting className for SVG element raises error * fix: svg element type information — committed to oliveira-gust/html2canvas by niklasvh 5 years ago
- fix: #1868 Clone node, Setting className for SVG element raises error (#2079) * fix: #1868 Clone node, Setting className for SVG element raises error * fix: svg element type information — committed to spsforks/html2canvas by niklasvh 5 years ago
@niklasvh, will you please release v1.0.0-rc.6 with this fix? What do you need to make this happen soon?
@niklasvh, the community using this library expects more frequent updates than you are providing. (>3 months of inactivity) If you are unable to maintain this library on your own, please add some prominent contributors such as @andyedinborough and @cobexer as collaborators: https://github.com/niklasvh/html2canvas/settings/access. Maybe they can provide the maintenance and releases that this library needs. Thank you.
Hello guys,
1.0.0-alpha.12works just fineI’m having the same problem. I tried 1.0.0-alpha.12 and v1.0.0-rc.3
I have created a pull request that fix this error.
#2034
Any news about the PR?
@maxaqquepucho It’s because the fix is not shipped
@niklasvh could you help create a new release?
Hey!
I had the same problem in a React app.
I had some FontAwesomeIcon on my page, removing them fixed the problem.
(even if the font icons were not in the selected element that I wanted to canvas)
use dom-to-image API For JS,Angular Which is better than this.