diff --git a/packages/compiler/src/render3/view/compiler.ts b/packages/compiler/src/render3/view/compiler.ts index 08b6344011..eb1b14ba6d 100644 --- a/packages/compiler/src/render3/view/compiler.ts +++ b/packages/compiler/src/render3/view/compiler.ts @@ -177,7 +177,7 @@ export function compileComponentFromMetadata( const template = meta.template; const templateBuilder = new TemplateDefinitionBuilder( - constantPool, BindingScope.ROOT_SCOPE, 0, templateTypeName, null, null, templateName, + constantPool, BindingScope.createRootScope(), 0, templateTypeName, null, null, templateName, directiveMatcher, directivesUsed, meta.pipes, pipesUsed, R3.namespaceHTML, meta.relativeContextFilePath, meta.i18nUseExternalIds); diff --git a/packages/compiler/src/render3/view/template.ts b/packages/compiler/src/render3/view/template.ts index f92a3904ce..b75e162fe7 100644 --- a/packages/compiler/src/render3/view/template.ts +++ b/packages/compiler/src/render3/view/template.ts @@ -1605,13 +1605,8 @@ export class BindingScope implements LocalResolver { private map = new Map(); private referenceNameIndex = 0; private restoreViewVariable: o.ReadVarExpr|null = null; - private static _ROOT_SCOPE: BindingScope; - - static get ROOT_SCOPE(): BindingScope { - if (!BindingScope._ROOT_SCOPE) { - BindingScope._ROOT_SCOPE = new BindingScope().set(0, '$event', o.variable('$event')); - } - return BindingScope._ROOT_SCOPE; + static createRootScope(): BindingScope { + return new BindingScope().set(0, '$event', o.variable('$event')); } private constructor(public bindingLevel: number = 0, private parent: BindingScope|null = null) {}