@@ -628,7 +628,7 @@ function renderWindow(node, container, options, windowWidth, windowHeight) {
628628 var parser = new NodeParser ( node , renderer , support , imageLoader , options ) ;
629629 return parser . ready . then ( function ( ) {
630630 log ( "Finished rendering" ) ;
631- var canvas = ( options . type !== "view" && ( node === clonedWindow . document . body || node === clonedWindow . document . documentElement ) ) ? renderer . canvas : crop ( renderer . canvas , { width : width , height : height , top : bounds . top , left : bounds . left } ) ;
631+ var canvas = ( options . type !== "view" && ( node === clonedWindow . document . body || node === clonedWindow . document . documentElement || options . canvas != null ) ) ? renderer . canvas : crop ( renderer . canvas , { width : width , height : height , top : bounds . top , left : bounds . left } ) ;
632632 cleanupContainer ( container , options ) ;
633633 return canvas ;
634634 } ) ;
@@ -2679,9 +2679,11 @@ function XHR(url) {
26792679
26802680function CanvasRenderer ( width , height ) {
26812681 Renderer . apply ( this , arguments ) ;
2682- this . canvas = this . document . createElement ( "canvas" ) ;
2683- this . canvas . width = width ;
2684- this . canvas . height = height ;
2682+ this . canvas = this . options . canvas || this . document . createElement ( "canvas" ) ;
2683+ if ( ! this . options . canvas ) {
2684+ this . canvas . width = width ;
2685+ this . canvas . height = height ;
2686+ }
26852687 this . ctx = this . canvas . getContext ( "2d" ) ;
26862688 this . taintCtx = this . document . createElement ( "canvas" ) . getContext ( "2d" ) ;
26872689 this . ctx . textBaseline = "bottom" ;
0 commit comments