Home / Function/ processSlotContent() — vue Function Reference

processSlotContent() — vue Function Reference

Architecture documentation for the processSlotContent() function in index.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  a805e141_5683_4910_efc8_e49b792fbae3["processSlotContent()"]
  02a69150_0003_c070_7030_ea511121f64b["processElement()"]
  02a69150_0003_c070_7030_ea511121f64b -->|calls| a805e141_5683_4910_efc8_e49b792fbae3
  b701a596_9c82_7ec4_2fc8_2e36d33c4974["getAndRemoveAttr()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| b701a596_9c82_7ec4_2fc8_2e36d33c4974
  0d1a9a6d_9f27_26ff_a82e_63f0ab50e4ee["getBindingAttr()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| 0d1a9a6d_9f27_26ff_a82e_63f0ab50e4ee
  c66bf8fe_579b_d9ec_aef1_172b5cabedf3["addAttr()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| c66bf8fe_579b_d9ec_aef1_172b5cabedf3
  46289d58_aa41_0928_dc46_0a54bc2499fe["getRawBindingAttr()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| 46289d58_aa41_0928_dc46_0a54bc2499fe
  b977def9_3e5f_8912_3c0b_f65308d670f9["getAndRemoveAttrByRegex()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| b977def9_3e5f_8912_3c0b_f65308d670f9
  5fcbfe87_6a4c_186f_fde9_3c764f94bce0["getSlotName()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| 5fcbfe87_6a4c_186f_fde9_3c764f94bce0
  c3257530_0ca9_f5ae_06ab_082337103cbe["createASTElement()"]
  a805e141_5683_4910_efc8_e49b792fbae3 -->|calls| c3257530_0ca9_f5ae_06ab_082337103cbe
  style a805e141_5683_4910_efc8_e49b792fbae3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/compiler/parser/index.ts lines 617–730

function processSlotContent(el) {
  let slotScope
  if (el.tag === 'template') {
    slotScope = getAndRemoveAttr(el, 'scope')
    /* istanbul ignore if */
    if (__DEV__ && slotScope) {
      warn(
        `the "scope" attribute for scoped slots have been deprecated and ` +
          `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
          `can also be used on plain elements in addition to <template> to ` +
          `denote scoped slots.`,
        el.rawAttrsMap['scope'],
        true
      )
    }
    el.slotScope = slotScope || getAndRemoveAttr(el, 'slot-scope')
  } else if ((slotScope = getAndRemoveAttr(el, 'slot-scope'))) {
    /* istanbul ignore if */
    if (__DEV__ && el.attrsMap['v-for']) {
      warn(
        `Ambiguous combined usage of slot-scope and v-for on <${el.tag}> ` +
          `(v-for takes higher priority). Use a wrapper <template> for the ` +
          `scoped slot to make it clearer.`,
        el.rawAttrsMap['slot-scope'],
        true
      )
    }
    el.slotScope = slotScope
  }

  // slot="xxx"
  const slotTarget = getBindingAttr(el, 'slot')
  if (slotTarget) {
    el.slotTarget = slotTarget === '""' ? '"default"' : slotTarget
    el.slotTargetDynamic = !!(
      el.attrsMap[':slot'] || el.attrsMap['v-bind:slot']
    )
    // preserve slot as an attribute for native shadow DOM compat
    // only for non-scoped slots.
    if (el.tag !== 'template' && !el.slotScope) {
      addAttr(el, 'slot', slotTarget, getRawBindingAttr(el, 'slot'))
    }
  }

  // 2.6 v-slot syntax
  if (process.env.NEW_SLOT_SYNTAX) {
    if (el.tag === 'template') {
      // v-slot on <template>
      const slotBinding = getAndRemoveAttrByRegex(el, slotRE)
      if (slotBinding) {
        if (__DEV__) {
          if (el.slotTarget || el.slotScope) {
            warn(`Unexpected mixed usage of different slot syntaxes.`, el)
          }
          if (el.parent && !maybeComponent(el.parent)) {
            warn(
              `<template v-slot> can only appear at the root level inside ` +
                `the receiving component`,
              el
            )
          }
        }
        const { name, dynamic } = getSlotName(slotBinding)
        el.slotTarget = name
        el.slotTargetDynamic = dynamic
        el.slotScope = slotBinding.value || emptySlotScopeToken // force it into a scoped slot for perf
      }
    } else {
      // v-slot on component, denotes default slot
      const slotBinding = getAndRemoveAttrByRegex(el, slotRE)
      if (slotBinding) {
        if (__DEV__) {
          if (!maybeComponent(el)) {
            warn(
              `v-slot can only be used on components or <template>.`,
              slotBinding
            )
          }
          if (el.slotScope || el.slotTarget) {
            warn(`Unexpected mixed usage of different slot syntaxes.`, el)
          }
          if (el.scopedSlots) {
            warn(
              `To avoid scope ambiguity, the default slot should also use ` +
                `<template> syntax when there are other named slots.`,
              slotBinding
            )
          }
        }
        // add the component's children to its default slot
        const slots = el.scopedSlots || (el.scopedSlots = {})
        const { name, dynamic } = getSlotName(slotBinding)
        const slotContainer = (slots[name] = createASTElement(
          'template',
          [],
          el
        ))
        slotContainer.slotTarget = name
        slotContainer.slotTargetDynamic = dynamic
        slotContainer.children = el.children.filter((c: any) => {
          if (!c.slotScope) {
            c.parent = slotContainer
            return true
          }
        })
        slotContainer.slotScope = slotBinding.value || emptySlotScopeToken
        // remove children as they are returned from scopedSlots now
        el.children = []
        // mark el non-plain so data gets generated
        el.plain = false
      }
    }
  }
}

Subdomains

Called By

Frequently Asked Questions

What does processSlotContent() do?
processSlotContent() is a function in the vue codebase.
What does processSlotContent() call?
processSlotContent() calls 7 function(s): addAttr, createASTElement, getAndRemoveAttr, getAndRemoveAttrByRegex, getBindingAttr, getRawBindingAttr, getSlotName.
What calls processSlotContent()?
processSlotContent() is called by 1 function(s): processElement.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free