New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOMException: Failed to set the 'adoptedStyleSheets' property on 'ShadowRoot': Sharing constructed stylesheets in multiple documents is not allowed #2058
Comments
i have the same problem; how to deal with it ? |
same problem using in angular 8 and ionic 4 |
Same problem ionic4, how to solve it? |
I'm facing the same problem with ionic 5... Did someone find any solution? |
Interim plan from Yupeng in ionic4
<body>
<div id="html2canvas"></div>
<app-root></app-root>
</body>
const element = document.getElementById('html2canvas');
const targetElement = document.getElementById('target').cloneNode(true);
element.appendChild(targetElement);
this.html2canvas.html2canvas(element.firstChild).then((img) => {
this.img = img;
element.firstChild.remove();
}).catch((res) => {
console.log(res);
});
import {Injectable} from '@angular/core';
import {AlertService} from './alert.service';
declare let html2canvas;
@Injectable()
export class Html2canvasService {
constructor(private alert: AlertService) {
}
public html2canvas(ele) {
if (!ele) {
return;
}
const option = {allowTaint: true, useCORS: true};
return html2canvas(ele, option).then((canvas) => {
if (canvas) {
return canvas.toDataURL('image/png');
}
return null;
}).catch((res) => {
console.log(res);
return res;
});
}
} |
@G-yanpeng Can you please elaborate more your solution? Im trying do the same for ionic 4 angular8 version. Thank you! |
Same problem. Did someone find any solution? Thanks! |
angular8 有了新的变更,导致 html2canvas 不能正常工作。那么就有了这个临时解决方案,让 html2canvas 在 angular 之外工作,将需要生成图片的 dom 拷贝到 angular 入口(app-root)的同层来避免angular造成的影响。 Angular8 has new changes that cause html2canvas to not work properly. Then there is this temporary solution to make html2canvas work outside of angular, copy the dom that needs to generate the image to the same layer of the angular entry (app-root) to avoid the impact of angular. |
您能否提供xxx.ts组件文件的完整代码? 尝试导出到.pdf时,我们也遇到相同的错误。 除此错误外,其他一切都正常。 我也可以查看.pdf文件。
` |
@ravimallya |
Thank you so much! Great workaround! |
I get the following error: "ERROR TypeError: html2canvas is not a function" in the following function call from the service:
|
This works vey well. Thank you so much for the solution. With ionic native elements(like ion-text, ion-icon inside the element to copy) this is not working. But i changed my ionic elements to html. Now it is working perfect. |
welp... 2021 and this issue is still present. The above workaround doesn't work for me. I still get the same error. |
Same problem here :( |
angular9,Same problem is still present. |
What solved it for me was using dom-to-image-improved https://www.npmjs.com/package/dom-to-image-improved if (result) { Can't for the life of me get the code block to work... |
For anyone arriving here via Google looking for a solution, @ibrahimAboelsuod's fork contains a built version of a fix here. I was able to swap out the built |
@lanrene thank you |
DOMException: Failed to set the 'adoptedStyleSheets' property on 'ShadowRoot': Sharing constructed stylesheets in multiple documents is not allowed
The text was updated successfully, but these errors were encountered: