Skip to content

Commit bb65559

Browse files
clydindylhunn
authored andcommittedAug 17, 2021
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
1 parent 738b233 commit bb65559

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎packages/animations/browser/src/render/animation_driver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class NoopAnimationDriver implements AnimationDriver {
4747
* @publicApi
4848
*/
4949
export abstract class AnimationDriver {
50-
static NOOP: AnimationDriver = new NoopAnimationDriver();
50+
static NOOP: AnimationDriver = /* @__PURE__ */ new NoopAnimationDriver();
5151

5252
abstract validateStyleProperty(prop: string): boolean;
5353

‎packages/animations/browser/src/render/special_cased_styles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function packageNonAnimatableStyles(
4444
* `destroy()` is called then all styles will be removed.
4545
*/
4646
export class SpecialCasedStyles {
47-
static initialStylesByElement = new WeakMap<any, {[key: string]: any}>();
47+
static initialStylesByElement = /* @__PURE__ */ new WeakMap<any, {[key: string]: any}>();
4848

4949
private _state = SpecialCasedStylesState.Pending;
5050
private _initialStyles!: {[key: string]: any};

0 commit comments

Comments
 (0)
Please sign in to comment.