MCPcopy Index your code
hub / github.com/angular/angular / TcbHostElementOp

Class TcbHostElementOp

packages/compiler/src/typecheck/ops/host.ts:20–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 * Executing this operation returns a reference to the element variable.
19 */
20export class TcbHostElementOp extends TcbOp {
21 override readonly optional = true;
22
23 constructor(
24 private tcb: Context,
25 private scope: Scope,
26 private element: HostElement,
27 ) {
28 super();
29 }
30
31 override execute(): TcbExpr {
32 const id = this.tcb.allocateId();
33 let tagNames: string;
34
35 if (this.element.tagNames.length === 1) {
36 tagNames = `"${this.element.tagNames[0]}"`;
37 } else {
38 tagNames = `null! as ${this.element.tagNames.map((t) => `"${t}"`).join(' | ')}`;
39 }
40
41 const initializer = new TcbExpr(`document.createElement(${tagNames})`);
42 initializer.addParseSpanInfo(this.element.sourceSpan);
43 this.scope.addStatement(new TcbExpr(`var ${id} = ${initializer.print()}`));
44 return new TcbExpr(id);
45 }
46}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…