( directive: TcbDirectiveMetadata, node: Template | Element, )
| 75 | export type TcbDirectiveInput = TcbDirectiveBoundInput | TcbDirectiveUnsetInput; |
| 76 | |
| 77 | export 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 | |
| 129 | export function checkSplitTwoWayBinding( |
| 130 | inputName: string, |
no test coverage detected