[Bug] Everything in `<slot>` is not rendered
Reproduction: https://jsfiddle.net/fu6hLzxm/1/
I checked the code and it seemed like the renderer supports slot elements. However, the DocumentCloner does not clone elements that are contained in slots.
After some more investigation, this bug seems to be caused by slotElement.assignedNodes() returning an empty array in the following two places.
https://github.com/yorickshan/html2canvas-pro/blob/f84f057ac36aa2f48a5768c10051eaa6311cb663/src/dom/document-cloner.ts#L301-L305
https://github.com/yorickshan/html2canvas-pro/blob/f84f057ac36aa2f48a5768c10051eaa6311cb663/src/dom/node-parser.ts#L25-L26
[...slotElement.childNodes] seems to be more appropriate in these locations.
For those who come across the same issue, the current workaround is to run this before rendering the elements:
elementToRender.querySelectorAll('slot').forEach(slot => {
slot.assignedNodes = () => [...slot.childNodes];
});
Is this issue resolved yet?
Reproduction: https://jsfiddle.net/fu6hLzxm/1/
I checked the code and it seemed like the renderer supports slot elements. However, the
DocumentClonerdoes not clone elements that are contained in slots.
try to use this REPO fix all 🐞:https://github.com/qq15725/modern-screenshot