mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Add foreignObjectRendering option
This commit is contained in:
parent
53dd885279
commit
f16d581f04
@ -124,6 +124,7 @@ export class DocumentCloner {
|
|||||||
proxy: this.options.proxy,
|
proxy: this.options.proxy,
|
||||||
removeContainer: this.options.removeContainer,
|
removeContainer: this.options.removeContainer,
|
||||||
scale: this.options.scale,
|
scale: this.options.scale,
|
||||||
|
foreignObjectRendering: this.options.foreignObjectRendering,
|
||||||
target: new CanvasRenderer(),
|
target: new CanvasRenderer(),
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
@ -46,8 +46,10 @@ export const renderElement = (
|
|||||||
: documentBackgroundColor
|
: documentBackgroundColor
|
||||||
: options.backgroundColor ? new Color(options.backgroundColor) : null;
|
: options.backgroundColor ? new Color(options.backgroundColor) : null;
|
||||||
|
|
||||||
// $FlowFixMe
|
return (options.foreignObjectRendering
|
||||||
return Feature.SUPPORT_FOREIGNOBJECT_DRAWING.then(
|
? // $FlowFixMe
|
||||||
|
Feature.SUPPORT_FOREIGNOBJECT_DRAWING
|
||||||
|
: Promise.resolve(false)).then(
|
||||||
supportForeignObject =>
|
supportForeignObject =>
|
||||||
supportForeignObject
|
supportForeignObject
|
||||||
? (cloner => {
|
? (cloner => {
|
||||||
|
@ -13,6 +13,7 @@ export type Options = {
|
|||||||
allowTaint: ?boolean,
|
allowTaint: ?boolean,
|
||||||
backgroundColor: string,
|
backgroundColor: string,
|
||||||
canvas: ?HTMLCanvasElement,
|
canvas: ?HTMLCanvasElement,
|
||||||
|
foreignObjectRendering: boolean,
|
||||||
imageTimeout: number,
|
imageTimeout: number,
|
||||||
proxy: ?string,
|
proxy: ?string,
|
||||||
removeContainer: ?boolean,
|
removeContainer: ?boolean,
|
||||||
@ -56,6 +57,7 @@ const html2canvas = (element: HTMLElement, conf: ?Options): Promise<*> => {
|
|||||||
imageTimeout: 15000,
|
imageTimeout: 15000,
|
||||||
proxy: null,
|
proxy: null,
|
||||||
removeContainer: true,
|
removeContainer: true,
|
||||||
|
foreignObjectRendering: true,
|
||||||
scale: defaultView.devicePixelRatio || 1,
|
scale: defaultView.devicePixelRatio || 1,
|
||||||
target: new CanvasRenderer(config.canvas),
|
target: new CanvasRenderer(config.canvas),
|
||||||
x: left,
|
x: left,
|
||||||
|
@ -115,12 +115,16 @@ const assertPath = (result, expected, desc) => {
|
|||||||
});
|
});
|
||||||
it('Should render untainted canvas', () => {
|
it('Should render untainted canvas', () => {
|
||||||
return testContainer.contentWindow
|
return testContainer.contentWindow
|
||||||
.html2canvas(testContainer.contentWindow.forceElement || testContainer.contentWindow.document.documentElement, {
|
.html2canvas(
|
||||||
removeContainer: true,
|
testContainer.contentWindow.forceElement ||
|
||||||
backgroundColor: '#ffffff',
|
testContainer.contentWindow.document.documentElement,
|
||||||
proxy: 'http://localhost:8081/proxy',
|
{
|
||||||
...(testContainer.contentWindow.h2cOptions || {})
|
removeContainer: true,
|
||||||
})
|
backgroundColor: '#ffffff',
|
||||||
|
proxy: 'http://localhost:8081/proxy',
|
||||||
|
...(testContainer.contentWindow.h2cOptions || {})
|
||||||
|
}
|
||||||
|
)
|
||||||
.then(canvas => {
|
.then(canvas => {
|
||||||
try {
|
try {
|
||||||
canvas
|
canvas
|
||||||
|
Loading…
Reference in New Issue
Block a user