aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/graph/postProcessSVG.ts
diff options
context:
space:
mode:
Diffstat (limited to 'subprojects/frontend/src/graph/postProcessSVG.ts')
-rw-r--r--subprojects/frontend/src/graph/postProcessSVG.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/subprojects/frontend/src/graph/postProcessSVG.ts b/subprojects/frontend/src/graph/postProcessSVG.ts
index bf990f3a..97130012 100644
--- a/subprojects/frontend/src/graph/postProcessSVG.ts
+++ b/subprojects/frontend/src/graph/postProcessSVG.ts
@@ -144,14 +144,14 @@ function replaceImages(node: SVGGElement) {
144 } 144 }
145 const width = image.getAttribute('width')?.replace('px', '') ?? ''; 145 const width = image.getAttribute('width')?.replace('px', '') ?? '';
146 const height = image.getAttribute('height')?.replace('px', '') ?? ''; 146 const height = image.getAttribute('height')?.replace('px', '') ?? '';
147 const foreign = document.createElementNS(SVG_NS, 'foreignObject'); 147 const use = document.createElementNS(SVG_NS, 'use');
148 foreign.setAttribute('x', image.getAttribute('x') ?? ''); 148 use.setAttribute('x', image.getAttribute('x') ?? '');
149 foreign.setAttribute('y', image.getAttribute('y') ?? ''); 149 use.setAttribute('y', image.getAttribute('y') ?? '');
150 foreign.setAttribute('width', width); 150 use.setAttribute('width', width);
151 foreign.setAttribute('height', height); 151 use.setAttribute('height', height);
152 const div = document.createElement('div'); 152 const iconName = `icon-${href.replace('#', '')}`;
153 div.classList.add('icon', `icon-${href.replace('#', '')}`); 153 use.setAttribute('href', `#refinery-${iconName}`);
154 foreign.appendChild(div); 154 use.classList.add('icon', iconName);
155 const sibling = image.nextElementSibling; 155 const sibling = image.nextElementSibling;
156 // Since dot doesn't respect the `id` attribute on table cells with a single image, 156 // Since dot doesn't respect the `id` attribute on table cells with a single image,
157 // compute the ID based on the ID of the next element (the label). 157 // compute the ID based on the ID of the next element (the label).
@@ -160,9 +160,9 @@ function replaceImages(node: SVGGElement) {
160 sibling.tagName.toLowerCase() === 'g' && 160 sibling.tagName.toLowerCase() === 'g' &&
161 sibling.id !== '' 161 sibling.id !== ''
162 ) { 162 ) {
163 foreign.id = `${sibling.id},icon`; 163 use.id = `${sibling.id},icon`;
164 } 164 }
165 image.parentNode?.replaceChild(foreign, image); 165 image.parentNode?.replaceChild(use, image);
166 }); 166 });
167} 167}
168 168