]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: rename key to $key
authordaiwei <daiwei521@126.com>
Fri, 7 Mar 2025 07:25:46 +0000 (15:25 +0800)
committerdaiwei <daiwei521@126.com>
Fri, 7 Mar 2025 07:25:46 +0000 (15:25 +0800)
packages/compiler-vapor/__tests__/transforms/TransformTransition.spec.ts
packages/compiler-vapor/__tests__/transforms/__snapshots__/TransformTransition.spec.ts.snap
packages/compiler-vapor/src/generators/block.ts
packages/runtime-vapor/src/block.ts
packages/runtime-vapor/src/components/Transition.ts
packages/runtime-vapor/src/dom/prop.ts

index 28425e5fd38f912e4e32ff5c1fd37ff6ba53394e..3fbabe7337bec846c7219171e634e6db2db68ab1 100644 (file)
@@ -37,7 +37,7 @@ describe('compiler: transition', () => {
 
     expect(code).toMatchSnapshot()
     // n2 should have a key
-    expect(code).contains('n2.key = 2')
+    expect(code).contains('n2.$key = 2')
   })
 
   test('work with dynamic keyed children', () => {
@@ -50,6 +50,6 @@ describe('compiler: transition', () => {
     expect(code).toMatchSnapshot()
     expect(code).contains('_createKeyedFragment(() => _ctx.key')
     // should preserve key
-    expect(code).contains('n0.key = _ctx.key')
+    expect(code).contains('n0.$key = _ctx.key')
   })
 })
index d515ed7a2881b4e80fa02a15f327db9a04e32512..dd33a4ddf25d468a318280f43d2238d3afcd1890 100644 (file)
@@ -24,7 +24,7 @@ export function render(_ctx) {
     "default": () => {
       return _createKeyedFragment(() => _ctx.key, () => {
         const n0 = t0()
-        n0.key = _ctx.key
+        n0.$key = _ctx.key
         return n0
       })
     }
@@ -42,7 +42,7 @@ export function render(_ctx) {
     "default": () => {
       const n0 = _createIf(() => (_ctx.show), () => {
         const n2 = t0()
-        n2.key = 2
+        n2.$key = 2
         return n2
       })
       return n0
index 39354e252a904249247272c3a07252bce4881fab..654816e09d7ef28c9b58c3f4ff319b100f39d9f0 100644 (file)
@@ -61,7 +61,7 @@ export function genBlockContent(
       const keyValue = key
         ? genExpression(key, context)
         : JSON.stringify(child.id)
-      push(NEWLINE, `n${child.id}.key = `, ...keyValue)
+      push(NEWLINE, `n${child.id}.$key = `, ...keyValue)
     }
   }
 
index 18313d191df02bfa5adfeb5d031d00a44c8e84ef..fecdfd659d84aec872e023aef5e39606997ac485 100644 (file)
@@ -20,7 +20,7 @@ import {
 } from './components/Transition'
 
 export interface TransitionOptions {
-  key?: any
+  $key?: any
   $transition?: VaporTransitionHooks
 }
 
@@ -39,7 +39,7 @@ export type Block = TransitionBlock | VaporComponentInstance | Block[]
 export type BlockFn = (...args: any[]) => Block
 
 export class VaporFragment implements TransitionOptions {
-  key?: any
+  $key?: any
   $transition?: VaporTransitionHooks | undefined
   nodes: Block
   anchor?: Node
index e3094ed14b60ded973439958f8c9fff3db18f3e7..d262c472382336bd9e8f8e4c6f0d38d90fc42b41 100644 (file)
@@ -101,7 +101,7 @@ function resolveTransitionHooks(
   postClone?: (hooks: TransitionHooks) => void,
 ): VaporTransitionHooks {
   const context = getTransitionHooksContext(
-    String(block.key),
+    String(block.$key),
     props,
     state,
     instance,
@@ -181,7 +181,7 @@ export function applyTransitionLeaveHooks(
       earlyRemove,
       delayedLeave,
     ) => {
-      state.leavingNodes.set(String(leavingBlock.key), leavingBlock)
+      state.leavingNodes.set(String(leavingBlock.$key), leavingBlock)
       // early removal callback
       block[leaveCbKey] = () => {
         earlyRemove()
@@ -210,7 +210,7 @@ export function findTransitionBlock(block: Block): TransitionBlock | undefined {
     if (block instanceof Element) child = block
   } else if (isVaporComponent(block)) {
     child = findTransitionBlock(block.block)
-    if (child && child.key === undefined) child.key = block.type.__name
+    if (child && child.$key === undefined) child.$key = block.type.__name
   } else if (Array.isArray(block)) {
     child = block[0] as TransitionBlock
     let hasFound = false
index 377d67c934981d274b62e0832871c23803a926b2..6c553337c6d8f3df39f546f00a34908c45086b90 100644 (file)
@@ -268,6 +268,7 @@ export function optimizePropertyLookup(): void {
   isOptimized = true
   const proto = Element.prototype as any
   proto.$transition = undefined
+  proto.$key = undefined
   proto.$evtclick = undefined
   proto.$root = false
   proto.$html =