analyzeBindingsFromOptions() — vue Function Reference
Architecture documentation for the analyzeBindingsFromOptions() function in compileScript.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 3dda6db9_d933_350f_4c9e_16f7fc6b1f16["analyzeBindingsFromOptions()"] aeb67520_c222_7e8e_48f7_9535500e1530["analyzeScriptBindings()"] aeb67520_c222_7e8e_48f7_9535500e1530 -->|calls| 3dda6db9_d933_350f_4c9e_16f7fc6b1f16 ed2a2fd5_ef3d_843d_ad3d_805dc154d881["getObjectOrArrayExpressionKeys()"] 3dda6db9_d933_350f_4c9e_16f7fc6b1f16 -->|calls| ed2a2fd5_ef3d_843d_ad3d_805dc154d881 5df0e9b4_0d3a_2489_eb77_65326f337535["getObjectExpressionKeys()"] 3dda6db9_d933_350f_4c9e_16f7fc6b1f16 -->|calls| 5df0e9b4_0d3a_2489_eb77_65326f337535 style 3dda6db9_d933_350f_4c9e_16f7fc6b1f16 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/compiler-sfc/src/compileScript.ts lines 1675–1749
function analyzeBindingsFromOptions(node: ObjectExpression): BindingMetadata {
const bindings: BindingMetadata = {}
// #3270, #3275
// mark non-script-setup so we don't resolve components/directives from these
Object.defineProperty(bindings, '__isScriptSetup', {
enumerable: false,
value: false
})
for (const property of node.properties) {
if (
property.type === 'ObjectProperty' &&
!property.computed &&
property.key.type === 'Identifier'
) {
// props
if (property.key.name === 'props') {
// props: ['foo']
// props: { foo: ... }
for (const key of getObjectOrArrayExpressionKeys(property.value)) {
bindings[key] = BindingTypes.PROPS
}
}
// inject
else if (property.key.name === 'inject') {
// inject: ['foo']
// inject: { foo: {} }
for (const key of getObjectOrArrayExpressionKeys(property.value)) {
bindings[key] = BindingTypes.OPTIONS
}
}
// computed & methods
else if (
property.value.type === 'ObjectExpression' &&
(property.key.name === 'computed' || property.key.name === 'methods')
) {
// methods: { foo() {} }
// computed: { foo() {} }
for (const key of getObjectExpressionKeys(property.value)) {
bindings[key] = BindingTypes.OPTIONS
}
}
}
// setup & data
else if (
property.type === 'ObjectMethod' &&
property.key.type === 'Identifier' &&
(property.key.name === 'setup' || property.key.name === 'data')
) {
for (const bodyItem of property.body.body) {
// setup() {
// return {
// foo: null
// }
// }
if (
bodyItem.type === 'ReturnStatement' &&
bodyItem.argument &&
bodyItem.argument.type === 'ObjectExpression'
) {
for (const key of getObjectExpressionKeys(bodyItem.argument)) {
bindings[key] =
property.key.name === 'setup'
? BindingTypes.SETUP_MAYBE_REF
: BindingTypes.DATA
}
}
}
}
}
return bindings
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does analyzeBindingsFromOptions() do?
analyzeBindingsFromOptions() is a function in the vue codebase.
What does analyzeBindingsFromOptions() call?
analyzeBindingsFromOptions() calls 2 function(s): getObjectExpressionKeys, getObjectOrArrayExpressionKeys.
What calls analyzeBindingsFromOptions()?
analyzeBindingsFromOptions() is called by 1 function(s): analyzeScriptBindings.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free