MCPcopy
hub / github.com/lit/lit / addController

Function addController

packages/reactive-element/src/reactive-element.ts:1070–1079  ·  view source on GitHub ↗

* Registers a `ReactiveController` to participate in the element's reactive * update cycle. The element automatically calls into any registered * controllers during its lifecycle callbacks. * * If the element is connected when `addController()` is called, the * controller's `hostConne

(controller: ReactiveController)

Source from the content-addressed store, hash-verified

1068 * @category controllers
1069 */
1070 addController(controller: ReactiveController) {
1071 (this.__controllers ??= new Set()).add(controller);
1072 // If a controller is added after the element has been connected,
1073 // call hostConnected. Note, re-using existence of `renderRoot` here
1074 // (which is set in connectedCallback) to avoid the need to track a
1075 // first connected state.
1076 if (this.renderRoot !== undefined && this.isConnected) {
1077 controller.hostConnected?.();
1078 }
1079 }
1080
1081 /**
1082 * Removes a `ReactiveController` from the element.

Callers

nothing calls this directly

Calls 2

addMethod · 0.80
hostConnectedMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…