@@ -64,7 +64,7 @@ Worker.prototype.from = function from(src, type) {
6464 }
6565 }
6666
67- return this . then ( function ( ) {
67+ return this . then ( function from_main ( ) {
6868 type = type || getType ( src ) ;
6969 switch ( type ) {
7070 case 'string' : return this . set ( { src : createElement ( 'div' , { innerHTML : src } ) } ) ;
@@ -95,11 +95,11 @@ Worker.prototype.to = function to(target) {
9595Worker . prototype . toContainer = function toContainer ( ) {
9696 // Set up function prerequisites.
9797 var prereqs = [
98- function ( ) { return this . prop . src || this . error ( 'Cannot duplicate - no source HTML.' ) ; } ,
99- function ( ) { return this . prop . pageSize || this . setPageSize ( ) ; }
98+ function checkSrc ( ) { return this . prop . src || this . error ( 'Cannot duplicate - no source HTML.' ) ; } ,
99+ function checkPageSize ( ) { return this . prop . pageSize || this . setPageSize ( ) ; }
100100 ] ;
101101
102- return this . thenList ( prereqs ) . then ( function ( ) {
102+ return this . thenList ( prereqs ) . then ( function toContainer_main ( ) {
103103 // Define the CSS styles for the container and its overlay parent.
104104 var overlayCSS = {
105105 position : 'fixed' , overflow : 'hidden' , zIndex : 1000 ,
@@ -126,7 +126,7 @@ Worker.prototype.toContainer = function toContainer() {
126126 // Enable page-breaks.
127127 var pageBreaks = source . querySelectorAll ( '.html2pdf__page-break' ) ;
128128 var pxPageHeight = this . prop . pageSize . inner . px . height ;
129- Array . prototype . forEach . call ( pageBreaks , function ( el ) {
129+ Array . prototype . forEach . call ( pageBreaks , function pageBreak_loop ( el ) {
130130 el . style . display = 'block' ;
131131 var clientRect = el . getBoundingClientRect ( ) ;
132132 el . style . height = pxPageHeight - ( clientRect . top % pxPageHeight ) + 'px' ;
@@ -137,19 +137,20 @@ Worker.prototype.toContainer = function toContainer() {
137137Worker . prototype . toCanvas = function toCanvas ( ) {
138138 // Set up function prerequisites.
139139 var prereqs = [
140- function ( ) { return document . body . contains ( this . prop . container ) || this . toContainer ( ) ; }
140+ function checkContainer ( ) { return document . body . contains ( this . prop . container )
141+ || this . toContainer ( ) ; }
141142 ] ;
142143
143144 // Fulfill prereqs then create the canvas.
144- return this . thenList ( prereqs ) . then ( function ( ) {
145+ return this . thenList ( prereqs ) . then ( function toCanvas_main ( ) {
145146 // Handle old-fashioned 'onrendered' argument.
146147 var options = Object . assign ( { } , this . opt . html2canvas ) ;
147148 delete options . onrendered ;
148149
149150 return html2canvas ( this . prop . container , options ) ;
150- } ) . then ( function ( canvas ) {
151+ } ) . then ( function toCanvas_post ( canvas ) {
151152 // Handle old-fashioned 'onrendered' argument.
152- var onRendered = this . opt . html2canvas . onrendered || function ( ) { } ;
153+ var onRendered = this . opt . html2canvas . onrendered || function ( ) { } ;
153154 onRendered ( canvas ) ;
154155
155156 this . prop . canvas = canvas ;
@@ -160,11 +161,11 @@ Worker.prototype.toCanvas = function toCanvas() {
160161Worker . prototype . toImg = function toImg ( ) {
161162 // Set up function prerequisites.
162163 var prereqs = [
163- function ( ) { return this . prop . canvas || this . toCanvas ( ) ; }
164+ function checkCanvas ( ) { return this . prop . canvas || this . toCanvas ( ) ; }
164165 ] ;
165166
166167 // Fulfill prereqs then create the image.
167- return this . thenList ( prereqs ) . then ( function ( ) {
168+ return this . thenList ( prereqs ) . then ( function toImg_main ( ) {
168169 var imgData = this . prop . canvas . toDataURL ( 'image/' + this . opt . image . type , this . opt . image . quality ) ;
169170 this . prop . img = document . createElement ( 'img' ) ;
170171 this . prop . img . src = imgData ;
@@ -174,11 +175,11 @@ Worker.prototype.toImg = function toImg() {
174175Worker . prototype . toPdf = function toPdf ( ) {
175176 // Set up function prerequisites.
176177 var prereqs = [
177- function ( ) { return this . prop . canvas || this . toCanvas ( ) ; }
178+ function checkCanvas ( ) { return this . prop . canvas || this . toCanvas ( ) ; }
178179 ] ;
179180
180181 // Fulfill prereqs then create the image.
181- return this . thenList ( prereqs ) . then ( function ( ) {
182+ return this . thenList ( prereqs ) . then ( function toPdf_main ( ) {
182183 // Create local copies of frequently used properties.
183184 var canvas = this . prop . canvas ;
184185 var opt = this . opt ;
@@ -240,11 +241,11 @@ Worker.prototype.output = function output(type, options, src) {
240241Worker . prototype . outputPdf = function outputPdf ( type , options ) {
241242 // Set up function prerequisites.
242243 var prereqs = [
243- function ( ) { return this . prop . pdf || this . toPdf ( ) ; }
244+ function checkPdf ( ) { return this . prop . pdf || this . toPdf ( ) ; }
244245 ] ;
245246
246247 // Fulfill prereqs then perform the appropriate output.
247- return this . thenList ( prereqs ) . then ( function ( ) {
248+ return this . thenList ( prereqs ) . then ( function outputPdf_main ( ) {
248249 /* Currently implemented output types:
249250 * https://rawgit.com/MrRio/jsPDF/master/docs/jspdf.js.html#line992
250251 * save(options), arraybuffer, blob, bloburi/bloburl,
@@ -257,11 +258,11 @@ Worker.prototype.outputPdf = function outputPdf(type, options) {
257258Worker . prototype . outputImg = function outputImg ( type , options ) {
258259 // Set up function prerequisites.
259260 var prereqs = [
260- function ( ) { return this . prop . img || this . toImg ( ) ; }
261+ function checkImg ( ) { return this . prop . img || this . toImg ( ) ; }
261262 ] ;
262263
263264 // Fulfill prereqs then perform the appropriate output.
264- return this . thenList ( prereqs ) . then ( function ( ) {
265+ return this . thenList ( prereqs ) . then ( function outputImg_main ( ) {
265266 switch ( type ) {
266267 case undefined :
267268 case 'img' :
@@ -281,13 +282,13 @@ Worker.prototype.outputImg = function outputImg(type, options) {
281282Worker . prototype . save = function save ( filename ) {
282283 // Set up function prerequisites.
283284 var prereqs = [
284- function ( ) { return this . prop . pdf || this . toPdf ( ) ; }
285+ function checkPdf ( ) { return this . prop . pdf || this . toPdf ( ) ; }
285286 ] ;
286287
287288 // Fulfill prereqs, update the filename (if provided), and save the PDF.
288289 return this . thenList ( prereqs ) . set (
289290 filename ? { filename : filename } : null
290- ) . then ( function ( ) {
291+ ) . then ( function save_main ( ) {
291292 this . prop . pdf . save ( this . opt . filename ) ;
292293 } ) ;
293294} ;
@@ -327,7 +328,7 @@ Worker.prototype.set = function set(opt) {
327328} ;
328329
329330Worker . prototype . get = function get ( key , cbk ) {
330- return this . then ( function ( ) {
331+ return this . then ( function get_main ( ) {
331332 // Fetch the requested property, either as a predefined prop or in opt.
332333 var val = ( key in Worker . template . prop ) ? this . prop [ key ] : this . opt [ key ] ;
333334 return cbk ? cbk ( val ) : val ;
@@ -418,10 +419,10 @@ Worker.prototype.then = function then(onFulfilled, onRejected) {
418419
419420 // Update progress while queuing, calling, and resolving `then`.
420421 self . updateProgress ( null , null , 1 , [ onFulfilled ] ) ;
421- var returnVal = Promise . prototype . then . call ( self , function ( val ) {
422+ var returnVal = Promise . prototype . then . call ( self , function then_pre ( val ) {
422423 self . updateProgress ( null , onFulfilled ) ;
423424 return val ;
424- } ) . then ( onFulfilled , onRejected ) . then ( function ( val ) {
425+ } ) . then ( onFulfilled , onRejected ) . then ( function then_post ( val ) {
425426 self . updateProgress ( 1 ) ;
426427 return val ;
427428 } ) ;
@@ -463,15 +464,15 @@ Worker.prototype.catchExternal = function catchExternal(onRejected) {
463464Worker . prototype . thenList = function thenList ( fns ) {
464465 // Queue a series of promise 'factories' into the promise chain.
465466 var self = this ;
466- fns . forEach ( function ( fn ) {
467+ fns . forEach ( function thenList_forEach ( fn ) {
467468 self = self . thenCore ( fn ) ;
468469 } ) ;
469470 return self ;
470471} ;
471472
472473Worker . prototype . error = function error ( msg ) {
473474 // Throw the error in the Promise chain.
474- return this . then ( function ( ) {
475+ return this . then ( function error_main ( ) {
475476 throw msg ;
476477 } ) ;
477478} ;
0 commit comments