From 210e8bdbdd764a4ffbb7c1820e3e155ba9c93763 Mon Sep 17 00:00:00 2001 From: Jean-Francois Cere Date: Tue, 13 Mar 2018 20:59:00 -0400 Subject: [PATCH] Fix Prism declaration for server-side rendering (part II) (#55) --- src/app/markdown/markdown.service.spec.ts | 4 ++-- src/app/markdown/markdown.service.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/markdown/markdown.service.spec.ts b/src/app/markdown/markdown.service.spec.ts index 9d91a51a..d2746c6d 100644 --- a/src/app/markdown/markdown.service.spec.ts +++ b/src/app/markdown/markdown.service.spec.ts @@ -168,14 +168,14 @@ describe('MarkdowService', () => { it('should not call Prism when not available', () => { - Prism = undefined; + global['Prism'] = undefined; markdownService.highlight(); }); it('should call Prism when available', () => { - Prism = { highlightAll: () => {} }; + global['Prism'] = { highlightAll: () => {} }; spyOn(Prism, 'highlightAll'); diff --git a/src/app/markdown/markdown.service.ts b/src/app/markdown/markdown.service.ts index 9248ea3d..4c3d00fe 100644 --- a/src/app/markdown/markdown.service.ts +++ b/src/app/markdown/markdown.service.ts @@ -46,10 +46,9 @@ export class MarkdownService { } highlight() { - if (!Prism) { - return; + if (typeof Prism !== 'undefined') { + Prism.highlightAll(false); } - Prism.highlightAll(false); } private extractData(response: Response) {