← All feedback

Fix export failure with gradient/mesh backgroundsDone

by Maxime2i
Fixed and live — thanks for the sharp report. Your instinct was very close. It wasn't a 0×0 element being painted, but the zero size was exactly the trigger: html2canvas turns each CSS gradient into a CanvasGradient and converts every colour stop into a ratio by dividing it by the gradient's line length. If any element inside the captured area measures 0 wide or 0 tall, that length is 0, every stop becomes NaN, and addColorStop() throws the error you saw — taking the whole export down with it. Two fixes shipped: 1. During a capture, addColorStop is now wrapped so non-finite offsets are clamped instead of throwing. A gradient that degenerate covers no visible pixels anyway, so the output is identical — the export just no longer dies. 2. Elements measuring 0×0 get their gradient stripped from the render clone before html2canvas ever sees them. I reproduced it by deliberately injecting a zero-sized gradient element, confirmed it threw your exact error, then verified the same design now exports cleanly through both the PNG and the ZIP path. Gradient and mesh backgrounds should be fine now. If you still hit it, tell me your browser and I'll dig further.
S Sedat Builder
Fixed and live — thanks for the sharp report. Your instinct was very close. It wasn't a 0×0 element being painted, but the zero size was exactly the trigger: html2canvas turns each CSS gradient into a CanvasGradient and converts every colour stop into a ratio by dividing it by the gradient's line length. If any element inside the captured area measures 0 wide or 0 tall, that length is 0, every stop becomes NaN, and addColorStop() throws the error you saw — taking the whole export down with it. Two fixes shipped: 1. During a capture, addColorStop is now wrapped so non-finite offsets are clamped instead of throwing. A gradient that degenerate covers no visible pixels anyway, so the output is identical — the export just no longer dies. 2. Elements measuring 0×0 get their gradient stripped from the render clone before html2canvas ever sees them. I reproduced it by deliberately injecting a zero-sized gradient element, confirmed it threw your exact error, then verified the same design now exports cleanly through both the PNG and the ZIP path. Gradient and mesh backgrounds should be fine now. If you still hit it, tell me your browser and I'll dig further.