html2canvas-pro 2.3.4 → 2.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/html2canvas-pro.cjs +24 -13
- package/dist/html2canvas-pro.cjs.map +1 -1
- package/dist/html2canvas-pro.esm.js +24 -13
- package/dist/html2canvas-pro.esm.js.map +1 -1
- package/dist/html2canvas-pro.js +24 -13
- package/dist/html2canvas-pro.js.map +1 -1
- package/dist/html2canvas-pro.min.js +3 -3
- package/dist/lib/dom/node-parser.js +42 -30
- package/package.json +1 -1
|
@@ -18,37 +18,49 @@ const LIST_OWNERS = ['OL', 'UL', 'MENU'];
|
|
|
18
18
|
const parseNodeTree = (context, node, parent, root) => {
|
|
19
19
|
for (let childNode = node.firstChild, nextNode; childNode; childNode = nextNode) {
|
|
20
20
|
nextNode = childNode.nextSibling;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
parseChildNode(context, childNode, parent, root);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Parse a single node as a child of `parent`.
|
|
26
|
+
*
|
|
27
|
+
* Separated from the tree walk so that nodes assigned to a `<slot>` (including
|
|
28
|
+
* bare text nodes, which have no child nodes) can be parsed directly. Without
|
|
29
|
+
* this, slotted shadow-DOM content such as web component labels was silently
|
|
30
|
+
* dropped because `parseNodeTree` only iterates `node.firstChild` (issue #226).
|
|
31
|
+
*/
|
|
32
|
+
const parseChildNode = (context, childNode, parent, root) => {
|
|
33
|
+
// Fixes #2238 #1624 - Fix the issue of TextNode content being overlooked in rendering due to being perceived as blank by trim().
|
|
34
|
+
if ((0, node_type_guards_1.isTextNode)(childNode) && childNode.data.length > 0) {
|
|
35
|
+
parent.textNodes.push(new text_container_1.TextContainer(context, childNode, parent.styles));
|
|
36
|
+
}
|
|
37
|
+
else if ((0, node_type_guards_1.isElementNode)(childNode)) {
|
|
38
|
+
if ((0, node_type_guards_1.isSlotElement)(childNode) && childNode.assignedNodes) {
|
|
39
|
+
// Slotted content is laid out at the slot's position: parse each
|
|
40
|
+
// assigned node (text or element) as a direct child of the slot's
|
|
41
|
+
// parent container.
|
|
42
|
+
childNode
|
|
43
|
+
.assignedNodes()
|
|
44
|
+
.forEach((assignedNode) => parseChildNode(context, assignedNode, parent, root));
|
|
24
45
|
}
|
|
25
|
-
else
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
parent.elements.push(container);
|
|
44
|
-
if (childNode.shadowRoot) {
|
|
45
|
-
parseNodeTree(context, childNode.shadowRoot, container, root);
|
|
46
|
-
}
|
|
47
|
-
else if (!(0, node_type_guards_1.isTextareaElement)(childNode) &&
|
|
48
|
-
!(0, node_type_guards_1.isSVGElement)(childNode) &&
|
|
49
|
-
!(0, node_type_guards_1.isSelectElement)(childNode)) {
|
|
50
|
-
parseNodeTree(context, childNode, container, root);
|
|
51
|
-
}
|
|
46
|
+
else {
|
|
47
|
+
const container = createContainer(context, childNode);
|
|
48
|
+
if (container.styles.isVisible()) {
|
|
49
|
+
if (createsRealStackingContext(childNode, container, root)) {
|
|
50
|
+
container.createsRealStackingContext = true;
|
|
51
|
+
}
|
|
52
|
+
else if (createsStackingContext(container.styles)) {
|
|
53
|
+
container.createsStackingContext = true;
|
|
54
|
+
}
|
|
55
|
+
if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
|
|
56
|
+
container.isListOwner = true;
|
|
57
|
+
}
|
|
58
|
+
parent.elements.push(container);
|
|
59
|
+
if (childNode.shadowRoot) {
|
|
60
|
+
parseNodeTree(context, childNode.shadowRoot, container, root);
|
|
61
|
+
}
|
|
62
|
+
else if (!(0, node_type_guards_1.isTextareaElement)(childNode) && !(0, node_type_guards_1.isSVGElement)(childNode) && !(0, node_type_guards_1.isSelectElement)(childNode)) {
|
|
63
|
+
parseNodeTree(context, childNode, container, root);
|
|
52
64
|
}
|
|
53
65
|
}
|
|
54
66
|
}
|