10

Encountered when using html2canvas: DOMException: Failed to set the 'adoptedStyleSheets' property on 'ShadowRoot': Sharing constructed stylesheets in multiple documents is not allowed

 html2canvas(document.getElementById('qr-code-content'), {useCORS: true}).then(canvas => {
        document.getElementById('qr-code-content').append(canvas);
        this.base64ImgData = canvas.toDataURL();
        this.sharing = true;
      });
hudaxin
  • 101
  • 1
  • 3

3 Answers3

2

This PR address the issue. https://github.com/niklasvh/html2canvas/pull/2020

You can use the fork if you need a quick solution or wait until it gets merged and get it from the main repo.

Zahema
  • 1,345
  • 2
  • 19
  • 35
  • for the newbies here - i.e. me - how can I download a .js / minified output from this, without pulling the whole repo and running some sort of build step? Or how do I do that if that is the required step? Thanks. – Dave Apr 11 '20 at 16:15
  • Thanks, but I just want the html2canvas.min.js file, not the whole npm repo. – Dave Apr 13 '20 at 00:45
  • 1
    @Dave You have to download the repo then build it then you will find it in the dist folder. I have built in my fork of the reop https://github.com/ibrahimAboelsuod/html2canvas/tree/master/dist – Zahema Apr 13 '20 at 17:49
0

you can also use

https://www.npmjs.com/package/dom-to-image. instead

see https://stackoverflow.com/a/63670250/2087270

Inês Gomes
  • 4,313
  • 1
  • 24
  • 32
0

I updated the Liberia html2canvas and the error stopped appearing, in this link is the most updated version: enter link description here

Apparently it has to do with Js updates in the browser.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 01 '23 at 22:11