refactor(ivy): store creationMode in LView.flags (#22417)
PR Close #22417
This commit is contained in:
parent
930ecacd86
commit
e454c5a98e
|
@ -12,7 +12,7 @@ import {assertEqual, assertLessThan, assertNotEqual, assertNotNull, assertNull,
|
|||
import {LContainer, TContainer} from './interfaces/container';
|
||||
import {CssSelector, LProjection} from './interfaces/projection';
|
||||
import {LQueries} from './interfaces/query';
|
||||
import {LView, LifecycleStage, TData, TView} from './interfaces/view';
|
||||
import {LView, LViewFlags, LifecycleStage, TData, TView} from './interfaces/view';
|
||||
|
||||
import {LContainerNode, LElementNode, LNode, LNodeFlags, LProjectionNode, LTextNode, LViewNode, TNode, TContainerNode, InitialInputData, InitialInputs, PropertyAliases, PropertyAliasValue,} from './interfaces/node';
|
||||
import {assertNodeType} from './node_assert';
|
||||
|
@ -159,7 +159,7 @@ export function enterView(newView: LView, host: LElementNode | LViewNode | null)
|
|||
data = newView && newView.data;
|
||||
bindingIndex = newView && newView.bindingStartIndex || 0;
|
||||
tData = newView && newView.tView.data;
|
||||
creationMode = newView && newView.creationMode;
|
||||
creationMode = newView && (newView.flags & LViewFlags.CreationMode) === 1;
|
||||
|
||||
cleanup = newView && newView.cleanup;
|
||||
renderer = newView && newView.renderer;
|
||||
|
@ -183,7 +183,7 @@ export function leaveView(newView: LView): void {
|
|||
executeHooks(
|
||||
currentView.data, currentView.tView.viewHooks, currentView.tView.viewCheckHooks,
|
||||
creationMode);
|
||||
currentView.creationMode = false;
|
||||
currentView.flags &= ~LViewFlags.CreationMode; // Clear creationMode bit in view flags
|
||||
currentView.lifecycleStage = LifecycleStage.INIT;
|
||||
currentView.tView.firstTemplatePass = false;
|
||||
enterView(newView, null);
|
||||
|
@ -194,7 +194,8 @@ export function createLView(
|
|||
context: any | null): LView {
|
||||
const newView = {
|
||||
parent: currentView,
|
||||
id: viewId, // -1 for component views
|
||||
id: viewId, // -1 for component views
|
||||
flags: LViewFlags.CreationMode,
|
||||
node: null !, // until we initialize it in createNode.
|
||||
data: [],
|
||||
tView: tView,
|
||||
|
@ -204,7 +205,6 @@ export function createLView(
|
|||
tail: null,
|
||||
next: null,
|
||||
bindingStartIndex: null,
|
||||
creationMode: true,
|
||||
template: template,
|
||||
context: context,
|
||||
dynamicViewCount: 0,
|
||||
|
|
|
@ -25,14 +25,16 @@ import {Renderer3} from './renderer';
|
|||
*/
|
||||
export interface LView {
|
||||
/**
|
||||
* Whether or not the view is in creationMode.
|
||||
* Flags for this view.
|
||||
*
|
||||
* First bit: Whether or not the view is in creationMode.
|
||||
*
|
||||
* This must be stored in the view rather than using `data` as a marker so that
|
||||
* we can properly support embedded views. Otherwise, when exiting a child view
|
||||
* back into the parent view, `data` will be defined and `creationMode` will be
|
||||
* improperly reported as false.
|
||||
*/
|
||||
creationMode: boolean;
|
||||
flags: LViewFlags;
|
||||
|
||||
/**
|
||||
* The parent view is needed when we exit the view and must restore the previous
|
||||
|
@ -180,6 +182,11 @@ export interface LView {
|
|||
queries: LQueries|null;
|
||||
}
|
||||
|
||||
/** Flags associated with an LView (see LView.flags) */
|
||||
export enum LViewFlags {
|
||||
CreationMode = 0b001
|
||||
}
|
||||
|
||||
/** Interface necessary to work with view tree traversal */
|
||||
export interface LViewOrLContainer {
|
||||
next: LView|LContainer|null;
|
||||
|
|
Loading…
Reference in New Issue