Home / Function/ scopedPlugin() — vue Function Reference

scopedPlugin() — vue Function Reference

Architecture documentation for the scopedPlugin() function in scoped.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  4b2e229f_d6b9_e76e_db88_f797ff948c08["scopedPlugin()"]
  a8e4176a_85a7_66ad_a2b0_98c89cfc57f1["doCompileStyle()"]
  a8e4176a_85a7_66ad_a2b0_98c89cfc57f1 -->|calls| 4b2e229f_d6b9_e76e_db88_f797ff948c08
  99a3bcbe_5e50_5f54_c9cf_4fcc3035fdfa["processRule()"]
  4b2e229f_d6b9_e76e_db88_f797ff948c08 -->|calls| 99a3bcbe_5e50_5f54_c9cf_4fcc3035fdfa
  style 4b2e229f_d6b9_e76e_db88_f797ff948c08 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/compiler-sfc/src/stylePlugins/scoped.ts lines 7–59

const scopedPlugin: PluginCreator<string> = (id = '') => {
  const keyframes = Object.create(null)
  const shortId = id.replace(/^data-v-/, '')

  return {
    postcssPlugin: 'vue-sfc-scoped',
    Rule(rule) {
      processRule(id, rule)
    },
    AtRule(node) {
      if (
        /-?keyframes$/.test(node.name) &&
        !node.params.endsWith(`-${shortId}`)
      ) {
        // register keyframes
        keyframes[node.params] = node.params = node.params + '-' + shortId
      }
    },
    OnceExit(root) {
      if (Object.keys(keyframes).length) {
        // If keyframes are found in this <style>, find and rewrite animation names
        // in declarations.
        // Caveat: this only works for keyframes and animation rules in the same
        // <style> element.
        // individual animation-name declaration
        root.walkDecls(decl => {
          if (animationNameRE.test(decl.prop)) {
            decl.value = decl.value
              .split(',')
              .map(v => keyframes[v.trim()] || v.trim())
              .join(',')
          }
          // shorthand
          if (animationRE.test(decl.prop)) {
            decl.value = decl.value
              .split(',')
              .map(v => {
                const vals = v.trim().split(/\s+/)
                const i = vals.findIndex(val => keyframes[val])
                if (i !== -1) {
                  vals.splice(i, 1, keyframes[vals[i]])
                  return vals.join(' ')
                } else {
                  return v
                }
              })
              .join(',')
          }
        })
      }
    }
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does scopedPlugin() do?
scopedPlugin() is a function in the vue codebase.
What does scopedPlugin() call?
scopedPlugin() calls 1 function(s): processRule.
What calls scopedPlugin()?
scopedPlugin() is called by 1 function(s): doCompileStyle.

Analyze Your Own Codebase

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

Try Supermodel Free