From d4703d931633b605bc0700a6c42e56eb5e4f492b Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Wed, 28 Aug 2019 16:12:26 +0200 Subject: [PATCH] refactor(ivy): remove global state access from inputs-related functions (#32370) PR Close #32370 --- packages/core/src/render3/instructions/element.ts | 2 +- packages/core/src/render3/instructions/listener.ts | 2 +- packages/core/src/render3/instructions/shared.ts | 11 +++++------ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/core/src/render3/instructions/element.ts b/packages/core/src/render3/instructions/element.ts index 755894002f..fbdef3b505 100644 --- a/packages/core/src/render3/instructions/element.ts +++ b/packages/core/src/render3/instructions/element.ts @@ -84,7 +84,7 @@ export function ɵɵelementStart( ngDevMode && ngDevMode.firstTemplatePass++; resolveDirectives(tView, lView, tNode, localRefs || null); - const inputData = initializeTNodeInputs(tNode); + const inputData = initializeTNodeInputs(tView, tNode); if (inputData && inputData.hasOwnProperty('class')) { tNode.flags |= TNodeFlags.hasClassInput; } diff --git a/packages/core/src/render3/instructions/listener.ts b/packages/core/src/render3/instructions/listener.ts index 6b58d46be3..33b4a3b6e8 100644 --- a/packages/core/src/render3/instructions/listener.ts +++ b/packages/core/src/render3/instructions/listener.ts @@ -179,7 +179,7 @@ function listenerInternal( if (tNode.outputs === undefined) { // if we create TNode here, inputs must be undefined so we know they still need to be // checked - tNode.outputs = generatePropertyAliases(tNode, BindingDirection.Output); + tNode.outputs = generatePropertyAliases(tView, tNode, BindingDirection.Output); } const outputs = tNode.outputs; diff --git a/packages/core/src/render3/instructions/shared.ts b/packages/core/src/render3/instructions/shared.ts index 19a8dc3cc0..a320529f77 100644 --- a/packages/core/src/render3/instructions/shared.ts +++ b/packages/core/src/render3/instructions/shared.ts @@ -813,9 +813,8 @@ export function createTNode( * @param direction whether to consider inputs or outputs * @returns PropertyAliases|null aggregate of all properties if any, `null` otherwise */ -export function generatePropertyAliases(tNode: TNode, direction: BindingDirection): PropertyAliases| - null { - const tView = getLView()[TVIEW]; +export function generatePropertyAliases( + tView: TView, tNode: TNode, direction: BindingDirection): PropertyAliases|null { let propStore: PropertyAliases|null = null; const start = tNode.directiveStart; const end = tNode.directiveEnd; @@ -865,7 +864,7 @@ export function elementPropertyInternal( const tNode = getTNode(index, lView); let inputData: PropertyAliases|null|undefined; let dataValue: PropertyAliasValue|undefined; - if (!nativeOnly && (inputData = initializeTNodeInputs(tNode)) && + if (!nativeOnly && (inputData = initializeTNodeInputs(lView[TVIEW], tNode)) && (dataValue = inputData[propName])) { setInputsForProperty(lView, dataValue, value); if (isComponent(tNode)) markDirtyIfOnPush(lView, index + HEADER_OFFSET); @@ -1784,12 +1783,12 @@ export function storeBindingMetadata(lView: LView, prefix = '', suffix = ''): st export const CLEAN_PROMISE = _CLEAN_PROMISE; -export function initializeTNodeInputs(tNode: TNode): PropertyAliases|null { +export function initializeTNodeInputs(tView: TView, tNode: TNode): PropertyAliases|null { // If tNode.inputs is undefined, a listener has created outputs, but inputs haven't // yet been checked. if (tNode.inputs === undefined) { // mark inputs as checked - tNode.inputs = generatePropertyAliases(tNode, BindingDirection.Input); + tNode.inputs = generatePropertyAliases(tView, tNode, BindingDirection.Input); } return tNode.inputs; }