| 119 | } |
| 120 | |
| 121 | export class BoundEvent implements Node { |
| 122 | constructor( |
| 123 | public name: string, |
| 124 | public type: ParsedEventType, |
| 125 | public handler: AST, |
| 126 | public target: string | null, |
| 127 | public phase: string | null, |
| 128 | public sourceSpan: ParseSourceSpan, |
| 129 | public handlerSpan: ParseSourceSpan, |
| 130 | readonly keySpan: ParseSourceSpan, |
| 131 | ) {} |
| 132 | |
| 133 | static fromParsedEvent(event: ParsedEvent) { |
| 134 | const target: string | null = |
| 135 | event.type === ParsedEventType.Regular ? event.targetOrPhase : null; |
| 136 | const phase: string | null = |
| 137 | event.type === ParsedEventType.LegacyAnimation ? event.targetOrPhase : null; |
| 138 | if (event.keySpan === undefined) { |
| 139 | throw new Error( |
| 140 | `Unexpected state: keySpan must be defined for bound event but was not for ${event.name}: ${event.sourceSpan}`, |
| 141 | ); |
| 142 | } |
| 143 | return new BoundEvent( |
| 144 | event.name, |
| 145 | event.type, |
| 146 | event.handler, |
| 147 | target, |
| 148 | phase, |
| 149 | event.sourceSpan, |
| 150 | event.handlerSpan, |
| 151 | event.keySpan, |
| 152 | ); |
| 153 | } |
| 154 | |
| 155 | visit<Result>(visitor: Visitor<Result>): Result { |
| 156 | return visitor.visitBoundEvent(this); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | export class Element implements Node { |
| 161 | constructor( |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…