refactor(ivy): simplify differentiation of LView, RNode
, LView
, LContainer
, StylingContext
(#28947)
For efficiency reasons we often put several different data types (`RNode`, `LView`, `LContainer`, `StylingContext`) in same location in `LView`. This is because we don't want to pre-allocate space for it because the storage is sparse. This file contains utilities for dealing with such data types. How do we know what is stored at a given location in `LView`. - `Array.isArray(value) === false` => `RNode` (The normal storage value) - `Array.isArray(value) === true` => than the `value[0]` represents the wrapped value. - `typeof value[TYPE] === 'object'` => `LView` - This happens when we have a component at a given location - `typeof value[TYPE] === 'number'` => `StylingContext` - This happens when we have style/class binding at a given location. - `typeof value[TYPE] === true` => `LContainer` - This happens when we have `LContainer` binding at a given location. NOTE: it is assumed that `Array.isArray` and `typeof` operations are very efficient. PR Close #28947
This commit is contained in:

committed by
Miško Hevery

parent
bd65f58784
commit
3cb497c6ac
@ -21,7 +21,7 @@ import {CHILD_HEAD, CLEANUP, FLAGS, HEADER_OFFSET, HookData, LView, LViewFlags,
|
||||
import {assertNodeType} from './node_assert';
|
||||
import {renderStringify} from './util/misc_utils';
|
||||
import {findComponentView, getLViewParent} from './util/view_traversal_utils';
|
||||
import {getNativeByTNode, isComponent, isLContainer, isLView, isRootView, readElementValue} from './util/view_utils';
|
||||
import {getNativeByTNode, isComponent, isLContainer, isLView, isRootView, unwrapRNode} from './util/view_utils';
|
||||
|
||||
const unusedValueToPlacateAjd = unused1 + unused2 + unused3 + unused4 + unused5;
|
||||
|
||||
@ -200,8 +200,8 @@ function walkTNodeTree(
|
||||
* being passed as an argument.
|
||||
*/
|
||||
function executeNodeAction(
|
||||
action: WalkTNodeTreeAction, renderer: Renderer3, parent: RElement | null,
|
||||
node: RComment | RElement | RText, tNode: TNode, beforeNode?: RNode | null) {
|
||||
action: WalkTNodeTreeAction, renderer: Renderer3, parent: RElement | null, node: RNode,
|
||||
tNode: TNode, beforeNode?: RNode | null) {
|
||||
if (action === WalkTNodeTreeAction.Insert) {
|
||||
nativeInsertBefore(renderer, parent !, node, beforeNode || null);
|
||||
} else if (action === WalkTNodeTreeAction.Detach) {
|
||||
@ -454,7 +454,7 @@ function removeListeners(lView: LView): void {
|
||||
const idxOrTargetGetter = tCleanup[i + 1];
|
||||
const target = typeof idxOrTargetGetter === 'function' ?
|
||||
idxOrTargetGetter(lView) :
|
||||
readElementValue(lView[idxOrTargetGetter]);
|
||||
unwrapRNode(lView[idxOrTargetGetter]);
|
||||
const listener = lCleanup[tCleanup[i + 2]];
|
||||
const useCaptureOrSubIdx = tCleanup[i + 3];
|
||||
if (typeof useCaptureOrSubIdx === 'boolean') {
|
||||
|
Reference in New Issue
Block a user