Skip to content

Commit

Permalink
move <symbol> into <defs>
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Oct 5, 2024
1 parent f16c8cc commit 72563a3
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 71 deletions.
14 changes: 9 additions & 5 deletions src/graph/svg-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ const svgNS = 'http://www.w3.org/2000/svg';
const xlinkNS = 'http://www.w3.org/1999/xlink';

function preprocessVizSVG(svgString: string) {
//Add Relay and Deprecated icons
// eslint-disable-next-line @typescript-eslint/no-base-to-string
svgString = svgString.replace(/<svg [^>]*>/, '$&' + RelayIconSvg);
svgString = svgString.replace(/<svg [^>]*>/, '$&' + DeprecatedIconSvg);

const svg = stringToSvg(svgString);

//Add Relay and Deprecated icons
let defs = svg.querySelector('defs');
if (!defs) {
defs = document.createElementNS(svgNS, 'defs');
svg.insertBefore(defs, svg.firstChild);
}
defs.appendChild(stringToSvg(DeprecatedIconSvg));
defs.appendChild(stringToSvg(RelayIconSvg));

for (const $a of svg.querySelectorAll('a')) {
const $g = $a.parentNode!;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/custom-sdl-graph-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/demo-graph-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/github-graph-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/graph-after-resize-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/graph-before-resize-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/star-wars-graph-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 8 additions & 6 deletions tests/demo.spec.ts-snapshots/yelp-graph-Demo-linux.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 72563a3

Please sign in to comment.