html2canvas-pro 2.3.3 → 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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * html2canvas-pro 2.3.3 <https://yorickshan.github.io/html2canvas-pro/>
2
+ * html2canvas-pro 2.3.5 <https://yorickshan.github.io/html2canvas-pro/>
3
3
  * Copyright (c) 2024-present yorickshan and html2canvas-pro contributors
4
4
  * Released under MIT License
5
5
  */
@@ -1734,9 +1734,10 @@
1734
1734
  let arg = [];
1735
1735
  tokens.forEach((token) => {
1736
1736
  if (token.type === 4) {
1737
- if (arg.length === 0) throw new Error(`Error parsing function args, zero tokens for arg`);
1738
- args.push(arg);
1739
- arg = [];
1737
+ if (arg.length) {
1738
+ args.push(arg);
1739
+ arg = [];
1740
+ }
1740
1741
  return;
1741
1742
  }
1742
1743
  if (token.type !== 31) arg.push(token);
@@ -6735,7 +6736,8 @@
6735
6736
  };
6736
6737
  const parseCache = /* @__PURE__ */ new Map();
6737
6738
  const parse = (context, descriptor, style) => {
6738
- const rawValue = style !== null && typeof style !== "undefined" ? style.toString() : descriptor.initialValue;
6739
+ let rawValue = style !== null && typeof style !== "undefined" ? style.toString() : descriptor.initialValue;
6740
+ if (rawValue.trim() === "") rawValue = descriptor.initialValue;
6739
6741
  let valueCache = parseCache.get(descriptor);
6740
6742
  if (valueCache) {
6741
6743
  const cached = valueCache.get(rawValue);
@@ -8184,18 +8186,29 @@
8184
8186
  const parseNodeTree = (context, node, parent, root) => {
8185
8187
  for (let childNode = node.firstChild, nextNode; childNode; childNode = nextNode) {
8186
8188
  nextNode = childNode.nextSibling;
8187
- if (isTextNode(childNode) && childNode.data.length > 0) parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
8188
- else if (isElementNode(childNode)) if (isSlotElement(childNode) && childNode.assignedNodes) childNode.assignedNodes().forEach((assignedNode) => parseNodeTree(context, assignedNode, parent, root));
8189
- else {
8190
- const container = createContainer(context, childNode);
8191
- if (container.styles.isVisible()) {
8192
- if (createsRealStackingContext(childNode, container, root)) container.createsRealStackingContext = true;
8193
- else if (createsStackingContext(container.styles)) container.createsStackingContext = true;
8194
- if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) container.isListOwner = true;
8195
- parent.elements.push(container);
8196
- if (childNode.shadowRoot) parseNodeTree(context, childNode.shadowRoot, container, root);
8197
- else if (!isTextareaElement(childNode) && !isSVGElement(childNode) && !isSelectElement(childNode)) parseNodeTree(context, childNode, container, root);
8198
- }
8189
+ parseChildNode(context, childNode, parent, root);
8190
+ }
8191
+ };
8192
+ /**
8193
+ * Parse a single node as a child of `parent`.
8194
+ *
8195
+ * Separated from the tree walk so that nodes assigned to a `<slot>` (including
8196
+ * bare text nodes, which have no child nodes) can be parsed directly. Without
8197
+ * this, slotted shadow-DOM content such as web component labels was silently
8198
+ * dropped because `parseNodeTree` only iterates `node.firstChild` (issue #226).
8199
+ */
8200
+ const parseChildNode = (context, childNode, parent, root) => {
8201
+ if (isTextNode(childNode) && childNode.data.length > 0) parent.textNodes.push(new TextContainer(context, childNode, parent.styles));
8202
+ else if (isElementNode(childNode)) if (isSlotElement(childNode) && childNode.assignedNodes) childNode.assignedNodes().forEach((assignedNode) => parseChildNode(context, assignedNode, parent, root));
8203
+ else {
8204
+ const container = createContainer(context, childNode);
8205
+ if (container.styles.isVisible()) {
8206
+ if (createsRealStackingContext(childNode, container, root)) container.createsRealStackingContext = true;
8207
+ else if (createsStackingContext(container.styles)) container.createsStackingContext = true;
8208
+ if (LIST_OWNERS.indexOf(childNode.tagName) !== -1) container.isListOwner = true;
8209
+ parent.elements.push(container);
8210
+ if (childNode.shadowRoot) parseNodeTree(context, childNode.shadowRoot, container, root);
8211
+ else if (!isTextareaElement(childNode) && !isSVGElement(childNode) && !isSelectElement(childNode)) parseNodeTree(context, childNode, container, root);
8199
8212
  }
8200
8213
  }
8201
8214
  };