From 9bbd3cab3cfb0685e7e7d7bbd2c7287f46568a13 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 20 Jun 2024 22:48:28 +0530 Subject: [PATCH] chore: Use string templates --- docs/config/setup/modules/mermaidAPI.md | 6 +++--- packages/mermaid/src/mermaidAPI.spec.ts | 7 ++----- packages/mermaid/src/mermaidAPI.ts | 4 +--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index 7bdd94775..d7bfe68ef 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -98,7 +98,7 @@ mermaid.initialize(config); #### Defined in -[mermaidAPI.ts:636](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L636) +[mermaidAPI.ts:634](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L634) ## Functions @@ -129,7 +129,7 @@ Return the last node appended #### Defined in -[mermaidAPI.ts:278](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L278) +[mermaidAPI.ts:276](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L276) --- @@ -280,4 +280,4 @@ Remove any existing elements from the given document #### Defined in -[mermaidAPI.ts:328](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L328) +[mermaidAPI.ts:326](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L326) diff --git a/packages/mermaid/src/mermaidAPI.spec.ts b/packages/mermaid/src/mermaidAPI.spec.ts index 6c220b9e1..1134f8635 100644 --- a/packages/mermaid/src/mermaidAPI.spec.ts +++ b/packages/mermaid/src/mermaidAPI.spec.ts @@ -200,11 +200,8 @@ describe('mermaidAPI', () => { }); it('sets src to base64 version of svgCode', () => { - const base64encodedSrc = toBase64( - '' + inputSvgCode + '' - ); - const expectedSrc = 'src="data:text/html;charset=UTF-8;base64,' + base64encodedSrc + '"'; - + const base64encodedSrc = toBase64(`${inputSvgCode}`); + const expectedSrc = `src="data:text/html;charset=UTF-8;base64,${base64encodedSrc}"`; const result = putIntoIFrame(inputSvgCode); expect(result).toContain(expectedSrc); }); diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index a7daa6ca2..ee6696af9 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -254,9 +254,7 @@ export const putIntoIFrame = (svgCode = '', svgElement?: D3Element): string => { const height = svgElement?.viewBox?.baseVal?.height ? svgElement.viewBox.baseVal.height + 'px' : IFRAME_HEIGHT; - const base64encodedSrc = toBase64( - '' + svgCode + '' - ); + const base64encodedSrc = toBase64(`${svgCode}`); return ``;