Browse Source

feat(compiler-vapor): add source mapping for object key

三咲智子 Kevin Deng 2 years ago
parent
commit
6d098b6871
1 changed files with 8 additions and 2 deletions
  1. 8 2
      packages/compiler-vapor/src/generators/prop.ts

+ 8 - 2
packages/compiler-vapor/src/generators/prop.ts

@@ -2,7 +2,7 @@ import { type CodeFragment, type CodegenContext, NEWLINE } from '../generate'
 import type { SetDynamicPropsIRNode, SetPropIRNode, VaporHelper } from '../ir'
 import type { SetDynamicPropsIRNode, SetPropIRNode, VaporHelper } from '../ir'
 import { genExpression } from './expression'
 import { genExpression } from './expression'
 import type { DirectiveTransformResult } from '../transform'
 import type { DirectiveTransformResult } from '../transform'
-import { isSimpleIdentifier } from '@vue/compiler-core'
+import { NewlineType, isSimpleIdentifier } from '@vue/compiler-core'
 
 
 // only the static key prop will reach here
 // only the static key prop will reach here
 export function genSetProp(
 export function genSetProp(
@@ -87,7 +87,13 @@ function genPropertyKey(
   if (node.isStatic) {
   if (node.isStatic) {
     // only quote keys if necessary
     // only quote keys if necessary
     const keyName = node.content
     const keyName = node.content
-    return [isSimpleIdentifier(keyName) ? keyName : JSON.stringify(keyName)]
+    return [
+      [
+        isSimpleIdentifier(keyName) ? keyName : JSON.stringify(keyName),
+        NewlineType.None,
+        node.loc,
+      ],
+    ]
   }
   }
 
 
   const key = genExpression(node, context)
   const key = genExpression(node, context)