Skip to content

Commit 9907149

Browse files
committed
Don't parse/render input hidden nodes
1 parent 645fcd6 commit 9907149

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

dist/html2canvas.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ window.html2canvas = function(nodeList, options) {
5252

5353
var node = ((nodeList === undefined) ? [document.documentElement] : ((nodeList.length) ? nodeList : [nodeList]))[0];
5454
node.setAttribute(html2canvasNodeAttribute, "true");
55-
5655
return renderDocument(node.ownerDocument, options, window.innerWidth, window.innerHeight).then(function(canvas) {
5756
if (typeof(options.onrendered) === "function") {
5857
log("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas");
@@ -541,7 +540,12 @@ NodeContainer.prototype.assignStack = function(stack) {
541540
};
542541

543542
NodeContainer.prototype.isElementVisible = function() {
544-
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (this.css('display') !== "none" && this.css('visibility') !== "hidden" && !this.node.hasAttribute("data-html2canvas-ignore"));
543+
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (
544+
this.css('display') !== "none" &&
545+
this.css('visibility') !== "hidden" &&
546+
!this.node.hasAttribute("data-html2canvas-ignore") &&
547+
(this.node.nodeName !== "INPUT" || this.node.getAttribute("type") !== "hidden")
548+
);
545549
};
546550

547551
NodeContainer.prototype.css = function(attribute) {

dist/html2canvas.min.js

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

src/nodecontainer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ NodeContainer.prototype.assignStack = function(stack) {
1818
};
1919

2020
NodeContainer.prototype.isElementVisible = function() {
21-
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (this.css('display') !== "none" && this.css('visibility') !== "hidden" && !this.node.hasAttribute("data-html2canvas-ignore"));
21+
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (
22+
this.css('display') !== "none" &&
23+
this.css('visibility') !== "hidden" &&
24+
!this.node.hasAttribute("data-html2canvas-ignore") &&
25+
(this.node.nodeName !== "INPUT" || this.node.getAttribute("type") !== "hidden")
26+
);
2227
};
2328

2429
NodeContainer.prototype.css = function(attribute) {

tests/cases/forms.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
</head>
1212
<body>
13+
<input type="hidden" value="THIS SHOULD NOT BE VISIBLE!" />
1314
<input type="text" value="textbox" />
1415
<input type="text" value="textbox" style="border:5px solid navy;" />
1516
<input type="text" value="textbox" style="border:5px solid navy;height:40px;" />

0 commit comments

Comments
 (0)