Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
5 changes: 3 additions & 2 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
Expand Down Expand Up @@ -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.
Expand Down
Binary file modified test/reference/snapshot/all-tags.pdf
Binary file not shown.
Binary file added test/reference/snapshot/all-tags_canvas.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/css-selectors.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/lorem-ipsum.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/lorem-ipsum_margin.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/pagebreaks_avoid-all.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/pagebreaks_css.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/pagebreaks_legacy.pdf
Binary file not shown.
Binary file modified test/reference/snapshot/pagebreaks_specify.pdf
Binary file not shown.
6 changes: 5 additions & 1 deletion test/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand All @@ -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' ],
};
Expand Down