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

Function genExpressionAsPropertyKey

packages/compiler-core/src/codegen.ts:785–803  ·  packages/compiler-core/src/codegen.ts::genExpressionAsPropertyKey
(
  node: ExpressionNode,
  context: CodegenContext,
)

Source from the content-addressed store, hash-verified

783}
784
785function genExpressionAsPropertyKey(
786 node: ExpressionNode,
787 context: CodegenContext,
788) {
789 const { push } = context
790 if (node.type === NodeTypes.COMPOUND_EXPRESSION) {
791 push(`[`)
792 genCompoundExpression(node, context)
793 push(`]`)
794 } else if (node.isStatic) {
795 class="cm">// only quote keys if necessary
796 const text = isSimpleIdentifier(node.content)
797 ? node.content
798 : JSON.stringify(node.content)
799 push(text, NewlineType.None, node)
800 } else {
801 push(`[${node.content}]`, NewlineType.Unknown, node)
802 }
803}
804
805function genComment(node: CommentNode, context: CodegenContext) {
806 const { push, helper, pure } = context

Callers 1

genObjectExpressionFunction · 0.85

Calls 3

isSimpleIdentifierFunction · 0.90
genCompoundExpressionFunction · 0.85
pushFunction · 0.70

Tested by

no test coverage detected