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

Function getBoundAttributes

packages/compiler/src/typecheck/ops/bindings.ts:77–127  ·  view source on GitHub ↗
(
  directive: TcbDirectiveMetadata,
  node: Template | Element,
)

Source from the content-addressed store, hash-verified

75export type TcbDirectiveInput = TcbDirectiveBoundInput | TcbDirectiveUnsetInput;
76
77export function getBoundAttributes(
78 directive: TcbDirectiveMetadata,
79 node: Template | Element,
80): TcbBoundAttribute[] {
81 const boundInputs: TcbBoundAttribute[] = [];
82
83 const processAttribute = (attr: BoundAttribute | TextAttribute) => {
84 // Skip non-property bindings.
85 if (
86 attr instanceof BoundAttribute &&
87 attr.type !== BindingType.Property &&
88 attr.type !== BindingType.TwoWay
89 ) {
90 return;
91 }
92
93 // Skip the attribute if the directive does not have an input for it.
94 const inputs = directive.inputs.getByBindingPropertyName(attr.name);
95
96 if (inputs !== null) {
97 boundInputs.push({
98 value: attr.value,
99 sourceSpan: attr.sourceSpan,
100 keySpan: attr.keySpan ?? null,
101 inputs: inputs.map((input: TcbInputMapping) => {
102 return {
103 fieldName: input.classPropertyName,
104 required: input.required,
105 transformType: input.transformType,
106 isSignal: input.isSignal,
107 isTwoWayBinding: attr instanceof BoundAttribute && attr.type === BindingType.TwoWay,
108 };
109 }),
110 });
111 }
112 };
113
114 if (node instanceof Template) {
115 if (node.tagName && isNgTemplate(node.tagName)) {
116 node.inputs.forEach(processAttribute);
117 node.attributes.forEach(processAttribute);
118 }
119
120 node.templateAttrs.forEach(processAttribute);
121 } else {
122 node.inputs.forEach(processAttribute);
123 node.attributes.forEach(processAttribute);
124 }
125
126 return boundInputs;
127}
128
129export function checkSplitTwoWayBinding(
130 inputName: string,

Callers 2

executeMethod · 0.90
executeMethod · 0.90

Calls 2

isNgTemplateFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected