MCPcopy Create free account
hub / github.com/angular/angular / isApplyingToNode

Method isApplyingToNode

packages/core/src/render3/queries/query.ts:227–254  ·  view source on GitHub ↗
(tNode: TNode)

Source from the content-addressed store, hash-verified

225 }
226
227 private isApplyingToNode(tNode: TNode): boolean {
228 if (
229 this._appliesToNextNode &&
230 (this.metadata.flags & QueryFlags.descendants) !== QueryFlags.descendants
231 ) {
232 const declarationNodeIdx = this._declarationNodeIndex;
233 let parent = tNode.parent;
234 // Determine if a given TNode is a "direct" child of a node on which a content query was
235 // declared (only direct children of query's host node can match with the descendants: false
236 // option). There are 3 main use-case / conditions to consider here:
237 // - <needs-target><i #target></i></needs-target>: here <i #target> parent node is a query
238 // host node;
239 // - <needs-target><ng-template [ngIf]="true"><i #target></i></ng-template></needs-target>:
240 // here <i #target> parent node is null;
241 // - <needs-target><ng-container><i #target></i></ng-container></needs-target>: here we need
242 // to go past `<ng-container>` to determine <i #target> parent node (but we shouldn't traverse
243 // up past the query's host node!).
244 while (
245 parent !== null &&
246 parent.type & TNodeType.ElementContainer &&
247 parent.index !== declarationNodeIdx
248 ) {
249 parent = parent.parent;
250 }
251 return declarationNodeIdx === (parent !== null ? parent.index : -1);
252 }
253 return this._appliesToNextNode;
254 }
255
256 private matchTNode(tView: TView, tNode: TNode): void {
257 const predicate = this.metadata.predicate;

Callers 2

elementStartMethod · 0.95
embeddedTViewMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected