From 19bbf4bc8e885258ba29e81e973b3cbca91a4b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Thu, 30 May 2019 13:53:06 -0700 Subject: [PATCH] test(ivy): fix sanitization state leaking issue Due to sanitization being stored as a temp/global value between instructions, unit tests randomly failed because one test failed to clean up its temporary value. This patch fixes this issue. --- packages/core/test/acceptance/styling_next_spec.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/core/test/acceptance/styling_next_spec.ts b/packages/core/test/acceptance/styling_next_spec.ts index 8186a241e8..1b22f5d273 100644 --- a/packages/core/test/acceptance/styling_next_spec.ts +++ b/packages/core/test/acceptance/styling_next_spec.ts @@ -11,7 +11,7 @@ import {SecurityContext} from '@angular/core/src/core'; import {getLContext} from '@angular/core/src/render3/context_discovery'; import {DebugNode, LViewDebug, toDebug} from '@angular/core/src/render3/debug'; import {SANITIZER} from '@angular/core/src/render3/interfaces/view'; -import {RuntimeStylingMode, runtimeSetStylingMode} from '@angular/core/src/render3/styling_next/state'; +import {RuntimeStylingMode, runtimeSetStylingMode, setCurrentStyleSanitizer} from '@angular/core/src/render3/styling_next/state'; import {loadLContextFromNode} from '@angular/core/src/render3/util/discovery_utils'; import {ngDevModeResetPerfCounters as resetStylingCounters} from '@angular/core/src/util/ng_dev_mode'; import {TestBed} from '@angular/core/testing'; @@ -712,6 +712,10 @@ describe('new styling integration', () => { const node = getDebugNode(element) !; const styles = node.styles !; expect(styles.values['width']).toEqual('200px-safe'); + + // this is here so that it won't get picked up accidentally in another test + lView[SANITIZER] = null; + setCurrentStyleSanitizer(null); }); it('should be able to bind a SafeValue to clip-path', () => {