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.
@@ -258,7 +258,14 @@ class CSSParsedCounterDeclaration {
258
258
  exports.CSSParsedCounterDeclaration = CSSParsedCounterDeclaration;
259
259
  const parseCache = new Map();
260
260
  const parse = (context, descriptor, style) => {
261
- const rawValue = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
261
+ let rawValue = style !== null && typeof style !== 'undefined' ? style.toString() : descriptor.initialValue;
262
+ // A whitespace-only (or empty) computed value makes the tokenizer emit only an
263
+ // EOF token, which parseComponentValue() turns into a "unexpected EOF" SyntaxError.
264
+ // Some browsers produce such values for web-component shadow styles (see #225);
265
+ // fall back to the descriptor's initialValue so capture never crashes on them.
266
+ if (rawValue.trim() === '') {
267
+ rawValue = descriptor.initialValue;
268
+ }
262
269
  let valueCache = parseCache.get(descriptor);
263
270
  if (valueCache) {
264
271
  const cached = valueCache.get(rawValue);
@@ -112,11 +112,12 @@ const parseFunctionArgs = (tokens) => {
112
112
  let arg = [];
113
113
  tokens.forEach((token) => {
114
114
  if (token.type === 4 /* TokenType.COMMA_TOKEN */) {
115
- if (arg.length === 0) {
116
- throw new Error(`Error parsing function args, zero tokens for arg`);
115
+ // Skip empty arguments (e.g. "1px,,2px") instead of throwing —
116
+ // real-world computed styles can produce them.
117
+ if (arg.length) {
118
+ args.push(arg);
119
+ arg = [];
117
120
  }
118
- args.push(arg);
119
- arg = [];
120
121
  return;
121
122
  }
122
123
  if (token.type !== 31 /* TokenType.WHITESPACE_TOKEN */) {
@@ -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.3",
22
+ "version": "2.3.5",
23
23
  "author": {
24
24
  "name": "yorickshan",
25
25
  "email": "yorickshan@gmail.com",