refactor(ivy): remove global state access from inputs-related functions (#32370)

PR Close #32370
This commit is contained in:
Pawel Kozlowski 2019-08-28 16:12:26 +02:00 committed by Miško Hevery
parent 1bb9ce5d8c
commit d4703d9316
3 changed files with 7 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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<T>(
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;
}