MCPcopy
hub / github.com/angular/angular / getDirectives

Function getDirectives

packages/core/src/render3/util/discovery_utils.ts:202–226  ·  view source on GitHub ↗
(node: Node)

Source from the content-addressed store, hash-verified

200 * @publicApi
201 */
202export function getDirectives(node: Node): {}[] {
203 // Skip text nodes because we can't have directives associated with them.
204 if (node instanceof Text) {
205 return [];
206 }
207
208 const context = getLContext(node)!;
209 const lView = context ? context.lView : null;
210 if (lView === null) {
211 return [];
212 }
213
214 const tView = lView[TVIEW];
215 const nodeIndex = context.nodeIndex;
216 if (!tView?.data[nodeIndex]) {
217 return [];
218 }
219 if (context.directives === undefined) {
220 context.directives = getDirectivesAtNodeIndex(nodeIndex, lView);
221 }
222
223 // The `directives` in this case are a named array called `LComponentView`. Clone the
224 // result so we don't expose an internal data structure in the user's console.
225 return context.directives === null ? [] : [...context.directives];
226}
227
228/** Metadata common to directives from all frameworks. */
229export interface BaseDirectiveDebugMetadata {

Callers 3

Calls 2

getLContextFunction · 0.90
getDirectivesAtNodeIndexFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…