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

Method _resolveDef

packages/runtime-dom/src/apiCustomElement.ts:372–434  ·  view source on GitHub ↗

* resolve inner component definition (handle possible async component)

()

Source from the content-addressed store, hash-verified

370 * resolve inner component definition (handle possible async component)
371 */
372 private _resolveDef() {
373 if (this._pendingResolve) {
374 return
375 }
376
377 // set initial attrs
378 for (let i = 0; i < this.attributes.length; i++) {
379 this._setAttr(this.attributes[i].name)
380 }
381
382 // watch future attr changes
383 this._ob = new MutationObserver(this._processMutations.bind(this))
384
385 this._ob.observe(this, { attributes: true })
386
387 const resolve = (def: InnerComponentDef, isAsync = false) => {
388 this._resolved = true
389 this._pendingResolve = undefined
390
391 const { props, styles } = def
392
393 // cast Number-type props set before resolve
394 let numberProps
395 if (props && !isArray(props)) {
396 for (const key in props) {
397 const opt = props[key]
398 if (opt === Number || (opt && opt.type === Number)) {
399 if (key in this._props) {
400 this._props[key] = toNumber(this._props[key])
401 }
402 ;(numberProps || (numberProps = Object.create(null)))[
403 camelize(key)
404 ] = true
405 }
406 }
407 }
408 this._numberProps = numberProps
409 this._resolveProps(def)
410
411 // apply CSS
412 if (this.shadowRoot) {
413 this._applyStyles(styles)
414 } else if (__DEV__ && styles) {
415 warn(
416 'Custom element style injection is not supported when using ' +
417 'shadowRoot: false',
418 )
419 }
420
421 // initial mount
422 this._mount(def)
423 }
424
425 const asyncDef = (this._def as ComponentOptions).__asyncLoader
426 if (asyncDef) {
427 this._pendingResolve = asyncDef().then((def: InnerComponentDef) => {
428 def.configureApp = this._def.configureApp
429 resolve((this._def = def), true)

Callers 1

connectedCallbackMethod · 0.95

Calls 2

_setAttrMethod · 0.95
resolveFunction · 0.50

Tested by

no test coverage detected