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', () => {
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')
})
})
"default": () => {
return _createKeyedFragment(() => _ctx.key, () => {
const n0 = t0()
- n0.key = _ctx.key
+ n0.$key = _ctx.key
return n0
})
}
"default": () => {
const n0 = _createIf(() => (_ctx.show), () => {
const n2 = t0()
- n2.key = 2
+ n2.$key = 2
return n2
})
return n0
const keyValue = key
? genExpression(key, context)
: JSON.stringify(child.id)
- push(NEWLINE, `n${child.id}.key = `, ...keyValue)
+ push(NEWLINE, `n${child.id}.$key = `, ...keyValue)
}
}
} from './components/Transition'
export interface TransitionOptions {
- key?: any
+ $key?: any
$transition?: VaporTransitionHooks
}
export type BlockFn = (...args: any[]) => Block
export class VaporFragment implements TransitionOptions {
- key?: any
+ $key?: any
$transition?: VaporTransitionHooks | undefined
nodes: Block
anchor?: Node
postClone?: (hooks: TransitionHooks) => void,
): VaporTransitionHooks {
const context = getTransitionHooksContext(
- String(block.key),
+ String(block.$key),
props,
state,
instance,
earlyRemove,
delayedLeave,
) => {
- state.leavingNodes.set(String(leavingBlock.key), leavingBlock)
+ state.leavingNodes.set(String(leavingBlock.$key), leavingBlock)
// early removal callback
block[leaveCbKey] = () => {
earlyRemove()
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
isOptimized = true
const proto = Element.prototype as any
proto.$transition = undefined
+ proto.$key = undefined
proto.$evtclick = undefined
proto.$root = false
proto.$html =