( input: HostBindingInput, bindingParser: BindingParser, constantPool: ConstantPool, )
| 96 | * representation. |
| 97 | */ |
| 98 | export function ingestHostBinding( |
| 99 | input: HostBindingInput, |
| 100 | bindingParser: BindingParser, |
| 101 | constantPool: ConstantPool, |
| 102 | ): HostBindingCompilationJob { |
| 103 | const job = new HostBindingCompilationJob( |
| 104 | input.componentName, |
| 105 | constantPool, |
| 106 | TemplateCompilationMode.DomOnly, |
| 107 | input.legacyOptionalChaining, |
| 108 | ); |
| 109 | for (const property of input.properties ?? []) { |
| 110 | let bindingKind = ir.BindingKind.Property; |
| 111 | // TODO: this should really be handled in the parser. |
| 112 | if (property.name.startsWith('attr.')) { |
| 113 | property.name = property.name.substring('attr.'.length); |
| 114 | bindingKind = ir.BindingKind.Attribute; |
| 115 | } |
| 116 | if (property.isLegacyAnimation) { |
| 117 | bindingKind = ir.BindingKind.LegacyAnimation; |
| 118 | } |
| 119 | if (property.isAnimation) { |
| 120 | bindingKind = ir.BindingKind.Animation; |
| 121 | } |
| 122 | const securityContexts = bindingParser |
| 123 | .calcPossibleSecurityContexts( |
| 124 | input.componentSelector, |
| 125 | property.name, |
| 126 | bindingKind === ir.BindingKind.Attribute, |
| 127 | ) |
| 128 | .filter((context) => context !== SecurityContext.NONE); |
| 129 | ingestDomProperty(job, property, bindingKind, securityContexts); |
| 130 | } |
| 131 | for (const [name, expr] of Object.entries(input.attributes) ?? []) { |
| 132 | const securityContexts = bindingParser |
| 133 | .calcPossibleSecurityContexts(input.componentSelector, name, true) |
| 134 | .filter((context) => context !== SecurityContext.NONE); |
| 135 | ingestHostAttribute(job, name, expr, securityContexts); |
| 136 | } |
| 137 | for (const event of input.events ?? []) { |
| 138 | ingestHostEvent(job, event); |
| 139 | } |
| 140 | return job; |
| 141 | } |
| 142 | |
| 143 | // TODO: We should refactor the parser to use the same types and structures for host bindings as |
| 144 | // with ordinary components. This would allow us to share a lot more ingestion code. |
no test coverage detected