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.
@@ -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
- // Fixes #2238 #1624 - Fix the issue of TextNode content being overlooked in rendering due to being perceived as blank by trim().
22
- if ((0, node_type_guards_1.isTextNode)(childNode) && childNode.data.length > 0) {
23
- parent.textNodes.push(new text_container_1.TextContainer(context, childNode, parent.styles));
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 if ((0, node_type_guards_1.isElementNode)(childNode)) {
26
- if ((0, node_type_guards_1.isSlotElement)(childNode) && childNode.assignedNodes) {
27
- childNode
28
- .assignedNodes()
29
- .forEach((assignedNode) => parseNodeTree(context, assignedNode, parent, root));
30
- }
31
- else {
32
- const container = createContainer(context, childNode);
33
- if (container.styles.isVisible()) {
34
- if (createsRealStackingContext(childNode, container, root)) {
35
- container.createsRealStackingContext = true;
36
- }
37
- else if (createsStackingContext(container.styles)) {
38
- container.createsStackingContext = true;
39
- }
40
- if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) {
41
- container.isListOwner = true;
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
  }
package/package.json CHANGED
@@ -19,7 +19,7 @@
19
19
  "default": "./dist/html2canvas-pro.esm.js"
20
20
  }
21
21
  },
22
- "version": "2.3.4",
22
+ "version": "2.3.5",
23
23
  "author": {
24
24
  "name": "yorickshan",
25
25
  "email": "yorickshan@gmail.com",