From 3cb1f18f976190189440e281581e712aaf0250e4 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Fri, 6 Aug 2021 10:27:05 -0400 Subject: [PATCH] fix(animations): add pure annotations to static property initializers (#43064) Class static properties with initializers that cause code execution (for example, call expressions or new expressions) have the potential to cause side effects at module evaluation. This is similar in effect to module level code. As a result, optimizers can not safely remove a class with such a static property as the potential side effects may have meaningful effects on the state of the application execution. To allow classes with these type of static properties to be optimized and removed if unused, the initializer expressions for the static properties can be annotated as pure. This annotation provides a signal to an optimizer that the expression does not have any potential side effects and is useful in cases where static analysis can not currently prove that there are, in fact, no side effects caused by the initializer. PR Close #43064 --- packages/animations/browser/src/render/animation_driver.ts | 2 +- packages/animations/browser/src/render/special_cased_styles.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/animations/browser/src/render/animation_driver.ts b/packages/animations/browser/src/render/animation_driver.ts index 32cd21bd771..0dc61bd8899 100644 --- a/packages/animations/browser/src/render/animation_driver.ts +++ b/packages/animations/browser/src/render/animation_driver.ts @@ -47,7 +47,7 @@ export class NoopAnimationDriver implements AnimationDriver { * @publicApi */ export abstract class AnimationDriver { - static NOOP: AnimationDriver = new NoopAnimationDriver(); + static NOOP: AnimationDriver = /* @__PURE__ */ new NoopAnimationDriver(); abstract validateStyleProperty(prop: string): boolean; diff --git a/packages/animations/browser/src/render/special_cased_styles.ts b/packages/animations/browser/src/render/special_cased_styles.ts index c2e012db9f5..c01076e85f0 100644 --- a/packages/animations/browser/src/render/special_cased_styles.ts +++ b/packages/animations/browser/src/render/special_cased_styles.ts @@ -44,7 +44,7 @@ export function packageNonAnimatableStyles( * `destroy()` is called then all styles will be removed. */ export class SpecialCasedStyles { - static initialStylesByElement = new WeakMap(); + static initialStylesByElement = /* @__PURE__ */ new WeakMap(); private _state = SpecialCasedStylesState.Pending; private _initialStyles!: {[key: string]: any};