MCPcopy
hub / github.com/vuejs/core / connectedCallback

Method connectedCallback

packages/runtime-dom/src/apiCustomElement.ts:283–323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

281 }
282
283 connectedCallback(): void {
284 // avoid resolving component if it's not connected
285 if (!this.isConnected) return
286
287 // avoid re-parsing slots if already resolved
288 if (!this.shadowRoot && !this._resolved) {
289 this._parseSlots()
290 }
291 this._connected = true
292
293 // locate nearest Vue custom element parent for provide/inject
294 let parent: Node | null = this
295 while (
296 (parent =
297 parent &&
298 // #12479 should check assignedSlot first to get correct parent
299 ((parent as Element).assignedSlot ||
300 parent.parentNode ||
301 (parent as ShadowRoot).host))
302 ) {
303 if (parent instanceof VueElement) {
304 this._parent = parent
305 break
306 }
307 }
308
309 if (!this._instance) {
310 if (this._resolved) {
311 this._mount(this._def)
312 } else {
313 if (parent && parent._pendingResolve) {
314 this._pendingResolve = parent._pendingResolve.then(() => {
315 this._pendingResolve = undefined
316 this._resolveDef()
317 })
318 } else {
319 this._resolveDef()
320 }
321 }
322 }
323 }
324
325 private _setParent(parent = this._parent) {
326 if (parent) {

Callers

nothing calls this directly

Calls 3

_parseSlotsMethod · 0.95
_mountMethod · 0.95
_resolveDefMethod · 0.95

Tested by

no test coverage detected