html2canvas-pro 2.4.0 → 2.4.1

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.4.0 <https://yorickshan.github.io/html2canvas-pro/>
2
+ * html2canvas-pro 2.4.1 <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
  */
@@ -8089,6 +8089,39 @@
8089
8089
  };
8090
8090
  //#endregion
8091
8091
  //#region src/dom/replaced-elements/svg-element-container.ts
8092
+ const BOX_OFFSET_PROPERTIES = [
8093
+ "position",
8094
+ "inset",
8095
+ "top",
8096
+ "right",
8097
+ "bottom",
8098
+ "left",
8099
+ "inset-inline",
8100
+ "inset-inline-start",
8101
+ "inset-inline-end",
8102
+ "inset-block",
8103
+ "inset-block-start",
8104
+ "inset-block-end",
8105
+ "margin",
8106
+ "margin-top",
8107
+ "margin-right",
8108
+ "margin-bottom",
8109
+ "margin-left",
8110
+ "margin-inline",
8111
+ "margin-inline-start",
8112
+ "margin-inline-end",
8113
+ "margin-block",
8114
+ "margin-block-start",
8115
+ "margin-block-end"
8116
+ ];
8117
+ const serializeWithoutBoxOffsets = (serializer, img) => {
8118
+ const style = img.getAttribute("style");
8119
+ BOX_OFFSET_PROPERTIES.forEach((property) => img.style.removeProperty(property));
8120
+ const serialized = serializer.serializeToString(img);
8121
+ if (style === null) img.removeAttribute("style");
8122
+ else img.setAttribute("style", style);
8123
+ return serialized;
8124
+ };
8092
8125
  var SVGElementContainer = class extends ElementContainer {
8093
8126
  constructor(context, img) {
8094
8127
  super(context, img);
@@ -8096,7 +8129,7 @@
8096
8129
  const bounds = parseBounds(context, img);
8097
8130
  img.setAttribute("width", `${bounds.width}px`);
8098
8131
  img.setAttribute("height", `${bounds.height}px`);
8099
- this.svg = `data:image/svg+xml,${encodeURIComponent(s.serializeToString(img))}`;
8132
+ this.svg = `data:image/svg+xml,${encodeURIComponent(serializeWithoutBoxOffsets(s, img))}`;
8100
8133
  this.intrinsicWidth = img.width.baseVal.value;
8101
8134
  this.intrinsicHeight = img.height.baseVal.value;
8102
8135
  this.context.cache.addImage(this.svg);