html2canvas-pro 1.6.3 → 1.6.4

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 1.6.3 <https://yorickshan.github.io/html2canvas-pro/>
2
+ * html2canvas-pro 1.6.4 <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
  */
@@ -6063,7 +6063,20 @@ class DocumentCloner {
6063
6063
  * */
6064
6064
  const baseUri = documentClone.baseURI;
6065
6065
  documentClone.open();
6066
- documentClone.write(`${serializeDoctype(document.doctype)}<html></html>`);
6066
+ try {
6067
+ // fixing "This document requires 'TrustedHTML' assignment. The action has been blocked." error
6068
+ // @ts-ignore
6069
+ const policy = trustedTypes.createPolicy('my-policy', {
6070
+ createHTML: (string) => string
6071
+ });
6072
+ const rawHTML = serializeDoctype(document.doctype) + '<html></html>';
6073
+ const trustedHTML = policy.createHTML(rawHTML);
6074
+ documentClone.write(trustedHTML);
6075
+ }
6076
+ catch (e) {
6077
+ // if browser does not support trustedTypes
6078
+ documentClone.write(serializeDoctype(document.doctype) + '<html></html>');
6079
+ }
6067
6080
  // Chrome scrolls the parent document for some reason after the write to the cloned window???
6068
6081
  restoreOwnerScroll(this.referenceElement.ownerDocument, scrollX, scrollY);
6069
6082
  /**