From 3483ce6a2c80dd36f4a2e308b7888796bceb142d Mon Sep 17 00:00:00 2001 From: sanderelias Date: Tue, 9 Jun 2020 16:35:56 +0200 Subject: [PATCH] feat(lib): raise an event when the switch is done by the FlashPreventionPlugin --- .../src/lib/flash-prevention.plugin.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libs/scully-plugin-flash-prevention/src/lib/flash-prevention.plugin.ts b/libs/scully-plugin-flash-prevention/src/lib/flash-prevention.plugin.ts index eded61f6d..11612c34e 100644 --- a/libs/scully-plugin-flash-prevention/src/lib/flash-prevention.plugin.ts +++ b/libs/scully-plugin-flash-prevention/src/lib/flash-prevention.plugin.ts @@ -10,7 +10,7 @@ const AppRootAttrsBlacklist = ['_nghost', 'ng-version']; const MockRootAttrsBlacklist = []; registerPlugin('render', FlashPrevention, flashPreventionPlugin); -registerPlugin('router', FlashPrevention, async ur => [{ route: ur }]); +registerPlugin('router', FlashPrevention, async (ur) => [{ route: ur }]); interface FlashPreventionPluginOptions { appRootSelector?: string; @@ -25,7 +25,7 @@ export function getFlashPreventionPlugin({ appLoadedClass, appRootAttributesBlacklist, mockAttributesBlacklist, - displayType + displayType, }: FlashPreventionPluginOptions = {}) { if (appRootSelector) { AppRootSelector = appRootSelector; @@ -88,7 +88,11 @@ async function addBitsToHead(html) { document.body.classList.add('${LoadedClass}'); const tempAppRoot = document.querySelector('${AppRootSelector}-scully'); tempAppRoot.parentNode.removeChild(tempAppRoot); - window.removeEventListener('AngularReady', scullyDiscountFlashPreventionContentScript); + window.removeEventListener('AngularReady', scullyDiscountFlashPreventionContentScript); + window.dispatchEvent(new Event('FlashPreventionSwitchDone', { + bubbles: true, + cancelable: false + })) }