mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Log errors in __DEV__ mode (Fix #905)
This commit is contained in:
parent
9a7075252b
commit
3977ebeadd
@ -17,4 +17,14 @@ export default class Logger {
|
||||
[Date.now() - this.start + 'ms', 'html2canvas:'].concat([].slice.call(args, 0))
|
||||
);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line flowtype/no-weak-types
|
||||
error(...args: any) {
|
||||
Function.prototype.bind
|
||||
.call(window.console.error, window.console)
|
||||
.apply(
|
||||
window.console,
|
||||
[Date.now() - this.start + 'ms', 'html2canvas:'].concat([].slice.call(args, 0))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
10
src/index.js
10
src/index.js
@ -51,7 +51,7 @@ const html2canvas = (element: HTMLElement, config: Options): Promise<HTMLCanvasE
|
||||
return Promise.reject(__DEV__ ? `Invalid canvas element provided in options` : '');
|
||||
}
|
||||
|
||||
return cloneWindow(
|
||||
const result = cloneWindow(
|
||||
ownerDocument,
|
||||
ownerDocument,
|
||||
windowBounds,
|
||||
@ -102,6 +102,14 @@ const html2canvas = (element: HTMLElement, config: Options): Promise<HTMLCanvasE
|
||||
return renderer.render(stack);
|
||||
});
|
||||
});
|
||||
|
||||
if (__DEV__) {
|
||||
return result.catch(e => {
|
||||
logger.error(e);
|
||||
throw e;
|
||||
});
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = html2canvas;
|
||||
|
Loading…
Reference in New Issue
Block a user