refactor(core): Remove host TNode from getOrCreateTNode (#38707)

Host `TNode` was passed into `getOrCreateTNode` just so that we can
compute weather or not we are a root node. This was needed because
`previousOrParentTNode` could have `TNode` from `TView` other then
current `TView`. This is confusing mental model. Previous change
ensured that `previousOrParentTNode` must always be part of `TView`,
which enabled this change to remove the unneeded argument.

PR Close #38707
This commit is contained in:
Misko Hevery
2020-09-04 13:03:46 -07:00
parent 33aaa9e7d0
commit bc6ff7745e
14 changed files with 40 additions and 41 deletions

View File

@ -1355,6 +1355,9 @@
{
"name": "getNodeInjectable"
},
{
"name": "getNonViewFirstChild"
},
{
"name": "getNullInjector"
},

View File

@ -230,8 +230,7 @@ describe('di', () => {
LViewFlags.CheckAlways, null, null, {} as any, {} as any);
enterView(contentView);
try {
const parentTNode =
getOrCreateTNode(contentView[TVIEW], null, 0, TNodeType.Element, null, null);
const parentTNode = getOrCreateTNode(contentView[TVIEW], 0, TNodeType.Element, null, null);
// Simulate the situation where the previous parent is not initialized.
// This happens on first bootstrap because we don't init existing values
// so that we have smaller HelloWorld.

View File

@ -50,7 +50,7 @@ export function setupTestHarness(
directiveRegistry: DirectiveDefList|null = null): TestHarness {
// Create a root view with a container
const hostTView = createTView(TViewType.Root, -1, null, 1, 0, null, null, null, null, consts);
const tContainerNode = getOrCreateTNode(hostTView, null, 0, TNodeType.Container, null, null);
const tContainerNode = getOrCreateTNode(hostTView, 0, TNodeType.Container, null, null);
const hostNode = renderer.createElement('div');
const hostLView = createLView(
null, hostTView, {}, LViewFlags.CheckAlways | LViewFlags.IsRoot, hostNode, null,

View File

@ -278,7 +278,7 @@ export function renderTemplate<T>(
def.pipeDefs = pipes || null;
const componentTView = getOrCreateTComponentView(def);
const hostTNode = getOrCreateTNode(tView, hostLView[T_HOST], 0, TNodeType.Element, null, null);
const hostTNode = getOrCreateTNode(tView, 0, TNodeType.Element, null, null);
hostLView[hostTNode.index] = hostNode;
componentView = createLView(
hostLView, componentTView, context, LViewFlags.CheckAlways, hostNode, hostTNode,