Skip to content

Commit

Permalink
reset shadow value for getNodeTextWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mrowetz committed May 5, 2017
1 parent 5722be5 commit 277468e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ts/helpers/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ let getTestSVGEl = (() => {
export function getNodeTextWidth(textNode: SVGTextElement, skipClone: boolean = false): number {
let tmp = getTestSVGEl();
let tmpTextNode: SVGTextElement;
let shadow;
if (skipClone) {
shadow = textNode.style.textShadow;
tmpTextNode = textNode;
} else {
tmpTextNode = textNode.cloneNode(true) as SVGTextElement;
Expand All @@ -158,5 +160,9 @@ export function getNodeTextWidth(textNode: SVGTextElement, skipClone: boolean =
tmpTextNode.style.textShadow = "0";
tmp.appendChild(tmpTextNode);
window.document.body.appendChild(tmp);
return tmpTextNode.getBBox().width;
const width = tmpTextNode.getBBox().width;
if (skipClone && shadow !== undefined) {
textNode.style.textShadow = shadow;
}
return width;
}

0 comments on commit 277468e

Please sign in to comment.