MCPcopy Index your code
hub / github.com/angular/angular / TQuery_

Class TQuery_

packages/core/src/render3/queries/query.ts:173–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171}
172
173class TQuery_ implements TQuery {
174 matches: number[] | null = null;
175 indexInDeclarationView = -1;
176 crossesNgTemplate = false;
177
178 /**
179 * A node index on which a query was declared (-1 for view queries and ones inherited from the
180 * declaration template). We use this index (alongside with _appliesToNextNode flag) to know
181 * when to apply content queries to elements in a template.
182 */
183 private _declarationNodeIndex: number;
184
185 /**
186 * A flag indicating if a given query still applies to nodes it is crossing. We use this flag
187 * (alongside with _declarationNodeIndex) to know when to stop applying content queries to
188 * elements in a template.
189 */
190 private _appliesToNextNode = true;
191
192 constructor(
193 public metadata: TQueryMetadata,
194 nodeIndex: number = -1,
195 ) {
196 this._declarationNodeIndex = nodeIndex;
197 }
198
199 elementStart(tView: TView, tNode: TNode): void {
200 if (this.isApplyingToNode(tNode)) {
201 this.matchTNode(tView, tNode);
202 }
203 }
204
205 elementEnd(tNode: TNode): void {
206 if (this._declarationNodeIndex === tNode.index) {
207 this._appliesToNextNode = false;
208 }
209 }
210
211 template(tView: TView, tNode: TNode): void {
212 this.elementStart(tView, tNode);
213 }
214
215 embeddedTView(tNode: TNode, childQueryIndex: number): TQuery | null {
216 if (this.isApplyingToNode(tNode)) {
217 this.crossesNgTemplate = true;
218 // A marker indicating a `<ng-template>` element (a placeholder for query results from
219 // embedded views created based on this `<ng-template>`).
220 this.addMatch(-tNode.index, childQueryIndex);
221 return new TQuery_(this.metadata);
222 }
223 return null;
224 }
225
226 private isApplyingToNode(tNode: TNode): boolean {
227 if (
228 this._appliesToNextNode &&
229 (this.metadata.flags & QueryFlags.descendants) !== QueryFlags.descendants
230 ) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…