analyzeBindingsFromOptions() — vue Function Reference
Architecture documentation for the analyzeBindingsFromOptions() function in compileScript.ts from the vue codebase.
Entity Profile
Dependency Diagram
graph TD 12e37f87_181a_b7e1_6837_4d27d75b0ec4["analyzeBindingsFromOptions()"] b9f12a63_b611_1b00_0717_3ff21d7ce156["compileScript.ts"] 12e37f87_181a_b7e1_6837_4d27d75b0ec4 -->|defined in| b9f12a63_b611_1b00_0717_3ff21d7ce156 989e8fc5_57b3_7826_b914_70e76c9bcd53["analyzeScriptBindings()"] 989e8fc5_57b3_7826_b914_70e76c9bcd53 -->|calls| 12e37f87_181a_b7e1_6837_4d27d75b0ec4 06cfe60d_6232_4eda_cb43_dc95bd9c2836["getObjectOrArrayExpressionKeys()"] 12e37f87_181a_b7e1_6837_4d27d75b0ec4 -->|calls| 06cfe60d_6232_4eda_cb43_dc95bd9c2836 a79c3254_76a7_3bc1_1ee5_ed892faddd0a["getObjectExpressionKeys()"] 12e37f87_181a_b7e1_6837_4d27d75b0ec4 -->|calls| a79c3254_76a7_3bc1_1ee5_ed892faddd0a style 12e37f87_181a_b7e1_6837_4d27d75b0ec4 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
Defined In
Called By
Source
Frequently Asked Questions
What does analyzeBindingsFromOptions() do?
analyzeBindingsFromOptions() is a function in the vue codebase, defined in packages/compiler-sfc/src/compileScript.ts.
Where is analyzeBindingsFromOptions() defined?
analyzeBindingsFromOptions() is defined in packages/compiler-sfc/src/compileScript.ts at line 1675.
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