Skip to content

Commit

Permalink
fix: styles not copied properly in VFXSpan, VFXDiv and VFXP
Browse files Browse the repository at this point in the history
  • Loading branch information
fand committed Jun 17, 2021
1 parent 18fc691 commit acf2662
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/dom-to-canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ export default function getCanvasFromElement(
// Clone element with styles in text attribute
// to apply styles in SVG
const newElement = cloneNode(element);
const styles = window.getComputedStyle(element, "");
const styleText = styles.cssText;
newElement.setAttribute("style", styleText);
newElement.style.setProperty("margin", "0");
const styles = window.getComputedStyle(element);
Array.from(styles).forEach(key => {
newElement.style.setProperty(
key,
styles.getPropertyValue(key),
styles.getPropertyPriority(key)
);
});
newElement.innerHTML = element.innerHTML;

// Wrap the element for text styling
Expand Down

0 comments on commit acf2662

Please sign in to comment.