Skip to content

Commit 51a7b6e

Browse files
author
Aleksander Burzec
committed
temporary fix: tsayen#125 Marker is not included(arrow)
1 parent ebd40ae commit 51a7b6e

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

dist/dom-to-image.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/dom-to-image.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
.then(done).catch(done);
106106
});
107107

108+
it('should render svg <line> with marker head in <defs> tag', function (done) {
109+
loadTestPage('svg-arrow-head/dom-node.html', 'svg-arrow-head/style.css', 'svg-arrow-head/control-image')
110+
.then(renderAndCheck)
111+
.then(done).catch(done);
112+
});
113+
108114
it('should render whole node when its scrolled', function (done) {
109115
var domNode;
110116
loadTestPage('scroll/dom-node.html', 'scroll/style.css', 'scroll/control-image')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAC3UlEQVR4Xu3bsW3bYBQE4NMCKVwYSJAt3HsCT5AqVdKkygL2BBkgA3gbL+IlFPxCFBCCFPLIX6d75Kn1s9/v+3gUIdi7PbBHXjYJ7BrIDtjZnGjDBzlYBMTnCgiIj8XhJAEJiFkCZsdJQwJiloDZcdKQgJglYHacOQ35CuAOwC+z32UVx2FBfgBoIO31GpT+1wAL8hPAl8ExgtLZhAVp64PSGWH44+aABMUQJChXQpnbkONxcvvqDLMUJE0xBAlKR5QeDcntyxQkTekA07MhaYopSJqyAOYaDUlTTEHSlBkw12xImmIKkqYQMIqGpCmmIGnKBBhlQ9IUU5A05T8wt2hImmIKkqacgbllQ9IUU5A0ZQDj0JA0xRQkTTH9h51N/+GE0y1r+Ba3WRRXkM3evpxB5qK8APgI4PuETyrsRtxBWJSG8fQ35QbyZpf4yIEqgExFGWK072kY5VpSBWQM5RTjeB2Wa0klkEsoHwa3qdMbQrmWVAM5RXkHcD9yWy7VkoogR5RHAJ8nvGmXaklVkEvvGZd8yrSkIgiLUeqJqxrIHIxST1yVQJZglGlJFZClGGVaUgHkE4BnAA8TnqjGRuyfuCqAHENuIN86wFg/cVUC6QVj3ZKKID1gbFtSGWQJjG1L1gAyF8ayJWsCYWEsW7JGEAbGriVrBpkCY9eSLYCMwVi1ZEsgl2CsWrJFkHMwNi3ZMsgQpn0s83vsgzDF1wOiSJnYERAiLMVoQBQpEzsCQoSlGA2IImViR0CIsBSjAVGkTOwICBGWYjQgipSJHQEhwlKMBkSRMrEjIERYitGAKFImdgSECEsxGhBFysSOgBBhKUYDokiZ2BEQIizFaEAUKRM7AkKEpRgNiCJlYkdAiLAUowFRpEzsCAgRlmI0IIqUiR0BIcJSjAZEkTKxIyBEWIrRgChSJnYEhAhLMRoQRcrEjoAQYSlGA6JImdgRECIsxeg/EMWy7JiWwB8pKgC7pb/IIwAAAABJRU5ErkJggg==
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div id="root">
2+
<svg xmlns="http://www.w3.org/1999/xhtml" height="94px" width="94px">
3+
<defs>
4+
<marker id="arrow" markerWidth="10" markerHeight="10" refX="0" refY="3" orient="auto"
5+
markerUnits="strokeWidth">
6+
<path d="M0,0 L0,6 L9,3 z" class="svg-line-head"/>
7+
</marker>
8+
</defs>
9+
<line marker-end="url(#arrow)" x1="5" y1="5" x2="40" y2="40" class="svg-line"/>
10+
</svg>
11+
</div>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#dom-node {
2+
width: 100px;
3+
overflow: hidden;
4+
}
5+
6+
#root {
7+
border: 1px solid red;
8+
position: relative;
9+
height: 100px;
10+
}
11+
12+
svg {
13+
position: absolute;
14+
left: 5px;
15+
top: 5px;
16+
}
17+
.svg-line {
18+
cursor: crosshair;
19+
stroke: rgba(0, 0, 0, 0.8);
20+
stroke-width: 3;
21+
}
22+
.svg-line-head {
23+
fill: rgba(0, 0, 0, 0.8);
24+
}

src/dom-to-image.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@
246246

247247
function cloneStyle() {
248248
copyStyle(window.getComputedStyle(original), clone.style);
249-
249+
// temporary fix of: https://github.com/tsayen/dom-to-image/issues/125
250+
if (util.isChrome() && clone.style.marker && clone.tagName === 'line') {
251+
clone.style.marker = '';
252+
}
250253
function copyStyle(source, target) {
251254
target.fontStretch == '';
252255
if (source.cssText) {
@@ -385,7 +388,8 @@
385388
escapeXhtml: escapeXhtml,
386389
makeImage: makeImage,
387390
width: width,
388-
height: height
391+
height: height,
392+
isChrome: isChrome,
389393
};
390394

391395
function mimes() {
@@ -596,6 +600,10 @@
596600
var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
597601
return parseFloat(value.replace('px', ''));
598602
}
603+
604+
function isChrome() {
605+
return /chrome/i.test( navigator.userAgent );
606+
}
599607
}
600608

601609
function newInliner() {

0 commit comments

Comments
 (0)