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

Function genObjectExpression

packages/compiler-core/src/codegen.ts:900–928  ·  packages/compiler-core/src/codegen.ts::genObjectExpression
(node: ObjectExpression, context: CodegenContext)

Source from the content-addressed store, hash-verified

898}
899
900function genObjectExpression(node: ObjectExpression, context: CodegenContext) {
901 const { push, indent, deindent, newline } = context
902 const { properties } = node
903 if (!properties.length) {
904 push(`{}`, NewlineType.None, node)
905 return
906 }
907 const multilines =
908 properties.length > 1 ||
909 ((!__BROWSER__ || __DEV__) &&
910 properties.some(p => p.value.type !== NodeTypes.SIMPLE_EXPRESSION))
911 push(multilines ? `{` : `{ `)
912 multilines && indent()
913 for (let i = 0; i < properties.length; i++) {
914 const { key, value } = properties[i]
915 class="cm">// key
916 genExpressionAsPropertyKey(key, context)
917 push(`: `)
918 class="cm">// value
919 genNode(value, context)
920 if (i < properties.length - 1) {
921 class="cm">// will only reach this if it's multilines
922 push(`,`)
923 newline()
924 }
925 }
926 multilines && deindent()
927 push(multilines ? `}` : ` }`)
928}
929
930function genArrayExpression(node: ArrayExpression, context: CodegenContext) {
931 genNodeListAsArray(node.elements as CodegenNode[], context)

Callers 1

genNodeFunction · 0.85

Calls 7

indentFunction · 0.85
genNodeFunction · 0.85
newlineFunction · 0.85
deindentFunction · 0.85
someMethod · 0.80
pushFunction · 0.70

Tested by

no test coverage detected