refactor(ivy): remove duplicated TNode utility (#32495)

Before this refactoring we had 2 utility functions to check if a given
TNode has matching directives. This PR leaves just one such function
(one that does less memory read).

PR Close #32495
This commit is contained in:
Pawel Kozlowski 2019-09-05 14:03:45 +02:00 committed by Kara Erickson
parent 024765b86a
commit 6674746e86
3 changed files with 4 additions and 12 deletions

View File

@ -12,10 +12,12 @@ import {isObservable} from '../../util/lang';
import {EMPTY_OBJ} from '../empty';
import {PropertyAliasValue, TNode, TNodeFlags, TNodeType} from '../interfaces/node';
import {GlobalTargetResolver, RElement, Renderer3, isProceduralRenderer} from '../interfaces/renderer';
import {isDirectiveHost} from '../interfaces/type_checks';
import {CLEANUP, FLAGS, LView, LViewFlags, RENDERER, TVIEW} from '../interfaces/view';
import {assertNodeOfPossibleTypes} from '../node_assert';
import {getLView, getPreviousOrParentTNode} from '../state';
import {getComponentViewByIndex, getNativeByTNode, hasDirectives, unwrapRNode} from '../util/view_utils';
import {getComponentViewByIndex, getNativeByTNode, unwrapRNode} from '../util/view_utils';
import {BindingDirection, generatePropertyAliases, getCleanup, handleError, loadComponentRenderer, markViewDirty} from './shared';
/**
@ -145,7 +147,7 @@ function listenerInternal(
// Also, we don't have to search for existing listeners is there are no directives
// matching on a given node as we can't register multiple event handlers for the same event in
// a template (this would mean having duplicate attributes).
if (!eventTargetResolver && hasDirectives(tNode)) {
if (!eventTargetResolver && isDirectiveHost(tNode)) {
existingListener = findExistingListener(lView, eventName, tNode.index);
}
if (existingListener !== null) {

View File

@ -117,13 +117,6 @@ export function getNativeByTNodeOrNull(tNode: TNode, lView: LView): RNode|null {
}
/**
* A helper function that returns `true` if a given `TNode` has any matching directives.
*/
export function hasDirectives(tNode: TNode): boolean {
return tNode.directiveEnd > tNode.directiveStart;
}
export function getTNode(index: number, view: LView): TNode {
ngDevMode && assertGreaterThan(index, -1, 'wrong index for TNode');
ngDevMode && assertLessThan(index, view[TVIEW].data.length, 'wrong index for TNode');

View File

@ -908,9 +908,6 @@
{
"name": "hasClassInput"
},
{
"name": "hasDirectives"
},
{
"name": "hasParentInjector"
},