Skip to content

Commit 7e6ec7c

Browse files
author
Benjamin Grand
committed
feat: add skipClone option
1 parent 6020386 commit 7e6ec7c

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

package-lock.json

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
{
2-
"title": "html2canvas",
3-
"name": "html2canvas",
2+
"title": "html-to-canvas",
3+
"name": "html-to-canvas",
44
"description": "Screenshots with JavaScript",
55
"main": "dist/html2canvas.js",
66
"module": "dist/html2canvas.esm.js",
77
"typings": "dist/types/index.d.ts",
88
"browser": "dist/html2canvas.js",
9-
"version": "1.4.1",
10-
"author": {
11-
"name": "Niklas von Hertzen",
12-
"email": "[email protected]",
13-
"url": "https://hertzen.com"
14-
},
15-
"engines": {
16-
"node": ">=8.0.0"
17-
},
18-
"repository": {
19-
"type": "git",
20-
"url": "[email protected]:niklasvh/html2canvas.git"
9+
"version": "1.0.0",
10+
"license": "MIT",
11+
"scripts": {
12+
"prebuild": "rimraf dist/ && rimraf build/ && mkdirp dist && mkdirp build",
13+
"build": "tsc --module commonjs && rollup -c rollup.config.ts && npm run build:create-reftest-list && npm run build:testrunner && npm run build:minify",
14+
"build:testrunner": "rollup -c tests/rollup.config.ts",
15+
"build:minify": "uglifyjs --compress --comments /^!/ -o dist/html2canvas.min.js --mangle -- dist/html2canvas.js",
16+
"build:reftest-result-list": "ts-node scripts/create-reftest-result-list.ts",
17+
"build:create-reftest-list": "ts-node scripts/create-reftest-list.ts tests/reftests/ignore.txt build/reftests.ts",
18+
"build:reftest-preview": "webpack --config www/webpack.config.js",
19+
"release": "standard-version",
20+
"format": "prettier --write \"{src,www/src,tests,scripts}/**/*.ts\"",
21+
"lint": "eslint src/**/*.ts --max-warnings 0",
22+
"test": "npm run lint && npm run unittest && npm run karma",
23+
"unittest": "jest",
24+
"reftests-diff": "mkdirp tmp/snapshots && jest --roots=tests --testMatch=**/reftest-diff.ts",
25+
"karma": "ts-node tests/karma",
26+
"watch": "rollup -c rollup.config.ts -w",
27+
"watch:unittest": "mocha --require ts-node/register --watch-extensions ts -w src/**/__tests__/*.ts",
28+
"start": "ts-node tests/server --port=8080 --cors=8081"
2129
},
22-
"bugs": {
23-
"url": "https://github.com/niklasvh/html2canvas/issues"
30+
"dependencies": {
31+
"css-line-break": "^2.1.0",
32+
"text-segmentation": "^1.0.3"
2433
},
2534
"devDependencies": {
2635
"@babel/cli": "^7.4.3",
@@ -96,29 +105,20 @@
96105
"webpack-cli": "^3.3.12",
97106
"yargs": "^17.0.1"
98107
},
99-
"scripts": {
100-
"prebuild": "rimraf dist/ && rimraf build/ && mkdirp dist && mkdirp build",
101-
"build": "tsc --module commonjs && rollup -c rollup.config.ts && npm run build:create-reftest-list && npm run build:testrunner && npm run build:minify",
102-
"build:testrunner": "rollup -c tests/rollup.config.ts",
103-
"build:minify": "uglifyjs --compress --comments /^!/ -o dist/html2canvas.min.js --mangle -- dist/html2canvas.js",
104-
"build:reftest-result-list": "ts-node scripts/create-reftest-result-list.ts",
105-
"build:create-reftest-list": "ts-node scripts/create-reftest-list.ts tests/reftests/ignore.txt build/reftests.ts",
106-
"build:reftest-preview": "webpack --config www/webpack.config.js",
107-
"release": "standard-version",
108-
"format": "prettier --write \"{src,www/src,tests,scripts}/**/*.ts\"",
109-
"lint": "eslint src/**/*.ts --max-warnings 0",
110-
"test": "npm run lint && npm run unittest && npm run karma",
111-
"unittest": "jest",
112-
"reftests-diff": "mkdirp tmp/snapshots && jest --roots=tests --testMatch=**/reftest-diff.ts",
113-
"karma": "ts-node tests/karma",
114-
"watch": "rollup -c rollup.config.ts -w",
115-
"watch:unittest": "mocha --require ts-node/register --watch-extensions ts -w src/**/__tests__/*.ts",
116-
"start": "ts-node tests/server --port=8080 --cors=8081"
108+
"engines": {
109+
"node": ">=8.0.0"
117110
},
118-
"homepage": "https://html2canvas.hertzen.com",
119-
"license": "MIT",
120-
"dependencies": {
121-
"css-line-break": "^2.1.0",
122-
"text-segmentation": "^1.0.3"
111+
"homepage": "https://github.com/bgrand-ch/html-to-canvas",
112+
"repository": {
113+
"type": "git",
114+
"url": "[email protected]:bgrand-ch/html-to-canvas.git"
115+
},
116+
"bugs": {
117+
"url": "https://github.com/bgrand-ch/html-to-canvas/issues"
118+
},
119+
"author": {
120+
"name": "Niklas von Hertzen",
121+
"email": "[email protected]",
122+
"url": "https://hertzen.com"
123123
}
124124
}

src/dom/document-cloner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {DebuggerType, isDebugging} from '../core/debugger';
2828
export interface CloneOptions {
2929
ignoreElements?: (element: Element) => boolean;
3030
onclone?: (document: Document, element: HTMLElement) => void;
31+
skipClone?: boolean;
3132
allowTaint?: boolean;
3233
}
3334

@@ -66,7 +67,8 @@ export class DocumentCloner {
6667
throw new Error('Cloned element does not have an owner document');
6768
}
6869

69-
this.documentElement = this.cloneNode(element.ownerDocument.documentElement, false) as HTMLElement;
70+
const docElement: HTMLElement = element.ownerDocument.documentElement;
71+
this.documentElement = this.options.skipClone ? docElement : this.cloneNode(docElement, false) as HTMLElement;
7072
}
7173

7274
toIFrame(ownerDocument: Document, windowSize: Bounds): Promise<HTMLIFrameElement> {

0 commit comments

Comments
 (0)