diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16 diff --git a/src/worker.js b/src/worker.js index 336d7b3..5ec9f4a 100644 --- a/src/worker.js +++ b/src/worker.js @@ -61,7 +61,7 @@ Worker.prototype.from = function from(src, type) { function getType(src) { switch (objType(src)) { case 'string': return 'string'; - case 'element': return src.nodeName.toLowerCase === 'canvas' ? 'canvas' : 'element'; + case 'element': return src.nodeName.toLowerCase && src.nodeName.toLowerCase() === 'canvas' ? 'canvas' : 'element'; default: return 'unknown'; } } @@ -168,7 +168,8 @@ Worker.prototype.toImg = function toImg() { Worker.prototype.toPdf = function toPdf() { // Set up function prerequisites. var prereqs = [ - function checkCanvas() { return this.prop.canvas || this.toCanvas(); } + function checkCanvas() { return this.prop.canvas || this.toCanvas(); }, + function checkPageSize() { return this.prop.pageSize || this.setPageSize(); } ]; // Fulfill prereqs then create the image. diff --git a/test/reference/snapshot/all-tags.pdf b/test/reference/snapshot/all-tags.pdf index 0a46dc0..17ef244 100644 Binary files a/test/reference/snapshot/all-tags.pdf and b/test/reference/snapshot/all-tags.pdf differ diff --git a/test/reference/snapshot/all-tags_canvas.pdf b/test/reference/snapshot/all-tags_canvas.pdf new file mode 100644 index 0000000..afb1e35 Binary files /dev/null and b/test/reference/snapshot/all-tags_canvas.pdf differ diff --git a/test/reference/snapshot/css-selectors.pdf b/test/reference/snapshot/css-selectors.pdf index b7e2f55..f2d7f28 100644 Binary files a/test/reference/snapshot/css-selectors.pdf and b/test/reference/snapshot/css-selectors.pdf differ diff --git a/test/reference/snapshot/lorem-ipsum.pdf b/test/reference/snapshot/lorem-ipsum.pdf index 7401126..34e6a66 100644 Binary files a/test/reference/snapshot/lorem-ipsum.pdf and b/test/reference/snapshot/lorem-ipsum.pdf differ diff --git a/test/reference/snapshot/lorem-ipsum_margin.pdf b/test/reference/snapshot/lorem-ipsum_margin.pdf index fc93bee..51729e9 100644 Binary files a/test/reference/snapshot/lorem-ipsum_margin.pdf and b/test/reference/snapshot/lorem-ipsum_margin.pdf differ diff --git a/test/reference/snapshot/pagebreaks_avoid-all.pdf b/test/reference/snapshot/pagebreaks_avoid-all.pdf index 4cd6a09..345c05f 100644 Binary files a/test/reference/snapshot/pagebreaks_avoid-all.pdf and b/test/reference/snapshot/pagebreaks_avoid-all.pdf differ diff --git a/test/reference/snapshot/pagebreaks_css.pdf b/test/reference/snapshot/pagebreaks_css.pdf index 4f555b8..01049a9 100644 Binary files a/test/reference/snapshot/pagebreaks_css.pdf and b/test/reference/snapshot/pagebreaks_css.pdf differ diff --git a/test/reference/snapshot/pagebreaks_legacy.pdf b/test/reference/snapshot/pagebreaks_legacy.pdf index 55abaee..b2c403c 100644 Binary files a/test/reference/snapshot/pagebreaks_legacy.pdf and b/test/reference/snapshot/pagebreaks_legacy.pdf differ diff --git a/test/reference/snapshot/pagebreaks_specify.pdf b/test/reference/snapshot/pagebreaks_specify.pdf index aa2c8cc..a8d4ca8 100644 Binary files a/test/reference/snapshot/pagebreaks_specify.pdf and b/test/reference/snapshot/pagebreaks_specify.pdf differ diff --git a/test/snapshot.js b/test/snapshot.js index f7739f8..d763723 100644 --- a/test/snapshot.js +++ b/test/snapshot.js @@ -31,6 +31,10 @@ describe('snapshot', () => { runner: window => defaultCondition(window, { margin: 1, jsPDF: { unit: 'in' } }), name: file => `${file}_margin.pdf`, }, + selectCanvas: { + runner: window => defaultCondition(window, {}, window.document.getElementById('canvas')), + name: file => `${file}_canvas.pdf`, + }, selectMainId: { runner: window => defaultCondition(window, {}, window.document.getElementById('main')), name: file => `${file}.pdf`, @@ -56,7 +60,7 @@ describe('snapshot', () => { const filesToTest = { 'blank': [ 'default' ], 'lorem-ipsum': [ 'default', 'legacy', 'margin' ], - 'all-tags': [ 'default' ], + 'all-tags': [ 'default', 'selectCanvas' ], 'css-selectors': [ 'selectMainId' ], 'pagebreaks': [ 'pagebreakLegacy', 'pagebreakCss', 'pagebreakAvoidAll', 'pagebreakSpecify' ], };