MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / connectedCallback

Method connectedCallback

src/ext/component.js:159–199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

157
158 const ComponentClass = class extends HTMLElement {
159 connectedCallback() {
160 // Skip if already initialized
161 if (this._hypercomp_initialized) return;
162 this._hypercomp_initialized = true;
163
164 // Isolate component scope - ^var resolution stops here
165 this.setAttribute('dom-scope', 'isolated');
166
167 // Capture slot content and clear children immediately,
168 // before processNode can recurse into them
169 this._slotContent = this.innerHTML;
170 this.innerHTML = '';
171
172 // 1. Inject `attrs` proxy into element scope, then apply component-level hyperscript
173 var internalData = runtime.getInternalData(this);
174 if (!internalData.elementScope) internalData.elementScope = {};
175 internalData.elementScope.attrs = createAttrs(this);
176
177 if (componentScript) {
178 this.setAttribute('_', componentScript);
179 _hyperscript.process(this);
180 }
181
182 // 2. Render template after synchronous init completes
183 const self = this;
184 var source = substituteSlots(templateSource, self._slotContent, tagName);
185
186 queueMicrotask(function() {
187 // Initial render - may return a promise if template has async expressions
188 var result = self._renderTemplate(source);
189 if (result && result.then) {
190 result.then(function(html) {
191 self._stampTemplate(html);
192 self._setupReactiveEffect(source);
193 });
194 } else {
195 self._stampTemplate(result);
196 self._setupReactiveEffect(source);
197 }
198 });
199 }
200
201 disconnectedCallback() {
202 reactivity.stopElementEffects(this);

Callers

nothing calls this directly

Calls 6

createAttrsFunction · 0.70
substituteSlotsFunction · 0.70
getInternalDataMethod · 0.45
_renderTemplateMethod · 0.45
_stampTemplateMethod · 0.45
_setupReactiveEffectMethod · 0.45

Tested by

no test coverage detected