diff --git a/CHANGELOG.md b/CHANGELOG.md index 6533dcd..2d51122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,22 @@ +## 1.0.3 - 2023-12-07 + +### Bug Fixes + +* Remove leading and trailing whitespace + + ## 1.0.2 - 2023-12-06 ### Bug Fixes -* use xlink:href additionally to href in img +* Use xlink:href additionally to href in img ## 1.0.1 - 2023-12-06 ### Features -* Update document +* Update README ## 1.0.0 - 2023-12-06 @@ -20,4 +27,4 @@ ### Bug Fixes -* Safari returns 2 DOMRects when wrapping text. \ No newline at end of file +* Safari returns 2 DOMRects when wrapping text \ No newline at end of file diff --git a/lib/text.ts b/lib/text.ts index 67676cb..b27acbb 100644 --- a/lib/text.ts +++ b/lib/text.ts @@ -30,6 +30,9 @@ export function handleTextNode(textNode: Text, context: TraversalContext): void // Make sure the y attribute is the bottom of the box, not the baseline svgTextElement.setAttribute('dominant-baseline', 'text-after-edge') + // Remove leading and trailing whitespace + textNode.textContent = textNode.textContent!.trim() + const lineRange = textNode.ownerDocument.createRange() lineRange.setStart(textNode, 0) lineRange.setEnd(textNode, 0) diff --git a/package.json b/package.json index 160ca0f..ed925e0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "dom2svg", "type": "module", - "version": "1.0.2", + "version": "1.0.3", "description": "Take SVG screenshots of DOM elements", "author": "xiashui", "license": "MIT",