Skip to content

Commit 05d9f53

Browse files
committed
wip: rename key to $key
1 parent 9ffa5ac commit 05d9f53

File tree

6 files changed

+11
-10
lines changed

6 files changed

+11
-10
lines changed

packages/compiler-vapor/__tests__/transforms/TransformTransition.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('compiler: transition', () => {
3737

3838
expect(code).toMatchSnapshot()
3939
// n2 should have a key
40-
expect(code).contains('n2.key = 2')
40+
expect(code).contains('n2.$key = 2')
4141
})
4242

4343
test('work with dynamic keyed children', () => {
@@ -50,6 +50,6 @@ describe('compiler: transition', () => {
5050
expect(code).toMatchSnapshot()
5151
expect(code).contains('_createKeyedFragment(() => _ctx.key')
5252
// should preserve key
53-
expect(code).contains('n0.key = _ctx.key')
53+
expect(code).contains('n0.$key = _ctx.key')
5454
})
5555
})

packages/compiler-vapor/__tests__/transforms/__snapshots__/TransformTransition.spec.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function render(_ctx) {
2424
"default": () => {
2525
return _createKeyedFragment(() => _ctx.key, () => {
2626
const n0 = t0()
27-
n0.key = _ctx.key
27+
n0.$key = _ctx.key
2828
return n0
2929
})
3030
}
@@ -42,7 +42,7 @@ export function render(_ctx) {
4242
"default": () => {
4343
const n0 = _createIf(() => (_ctx.show), () => {
4444
const n2 = t0()
45-
n2.key = 2
45+
n2.$key = 2
4646
return n2
4747
})
4848
return n0

packages/compiler-vapor/src/generators/block.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export function genBlockContent(
6161
const keyValue = key
6262
? genExpression(key, context)
6363
: JSON.stringify(child.id)
64-
push(NEWLINE, `n${child.id}.key = `, ...keyValue)
64+
push(NEWLINE, `n${child.id}.$key = `, ...keyValue)
6565
}
6666
}
6767

packages/runtime-vapor/src/block.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
} from './components/Transition'
2121

2222
export interface TransitionOptions {
23-
key?: any
23+
$key?: any
2424
$transition?: VaporTransitionHooks
2525
}
2626

@@ -39,7 +39,7 @@ export type Block = TransitionBlock | VaporComponentInstance | Block[]
3939
export type BlockFn = (...args: any[]) => Block
4040

4141
export class VaporFragment implements TransitionOptions {
42-
key?: any
42+
$key?: any
4343
$transition?: VaporTransitionHooks | undefined
4444
nodes: Block
4545
anchor?: Node

packages/runtime-vapor/src/components/Transition.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function resolveTransitionHooks(
101101
postClone?: (hooks: TransitionHooks) => void,
102102
): VaporTransitionHooks {
103103
const context = getTransitionHooksContext(
104-
String(block.key),
104+
String(block.$key),
105105
props,
106106
state,
107107
instance,
@@ -181,7 +181,7 @@ export function applyTransitionLeaveHooks(
181181
earlyRemove,
182182
delayedLeave,
183183
) => {
184-
state.leavingNodes.set(String(leavingBlock.key), leavingBlock)
184+
state.leavingNodes.set(String(leavingBlock.$key), leavingBlock)
185185
// early removal callback
186186
block[leaveCbKey] = () => {
187187
earlyRemove()
@@ -210,7 +210,7 @@ export function findTransitionBlock(block: Block): TransitionBlock | undefined {
210210
if (block instanceof Element) child = block
211211
} else if (isVaporComponent(block)) {
212212
child = findTransitionBlock(block.block)
213-
if (child && child.key === undefined) child.key = block.type.__name
213+
if (child && child.$key === undefined) child.$key = block.type.__name
214214
} else if (Array.isArray(block)) {
215215
child = block[0] as TransitionBlock
216216
let hasFound = false

packages/runtime-vapor/src/dom/prop.ts

+1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ export function optimizePropertyLookup(): void {
268268
isOptimized = true
269269
const proto = Element.prototype as any
270270
proto.$transition = undefined
271+
proto.$key = undefined
271272
proto.$evtclick = undefined
272273
proto.$root = false
273274
proto.$html =

0 commit comments

Comments
 (0)