@@ -34,6 +34,7 @@ import { cloneLoc } from '../parser'
3434import { CREATE_COMMENT , FRAGMENT } from '../runtimeHelpers'
3535import { findDir , findProp , getMemoedVNodeCall , injectProp } from '../utils'
3636import { PatchFlags } from '@vue/shared'
37+ import { transformBindShorthand } from './vBind'
3738
3839export const transformIf : NodeTransform = createStructuralDirectiveTransform (
3940 / ^ ( i f | e l s e | e l s e - i f ) $ / ,
@@ -108,7 +109,7 @@ export function processIf(
108109 }
109110
110111 if ( dir . name === 'if' ) {
111- const branch = createIfBranch ( node , dir )
112+ const branch = createIfBranch ( node , dir , context )
112113 const ifNode : IfNode = {
113114 type : NodeTypes . IF ,
114115 loc : cloneLoc ( node . loc ) ,
@@ -153,7 +154,7 @@ export function processIf(
153154
154155 // move the node to the if node's branches
155156 context . removeNode ( )
156- const branch = createIfBranch ( node , dir )
157+ const branch = createIfBranch ( node , dir , context )
157158 if (
158159 __DEV__ &&
159160 comments . length &&
@@ -205,8 +206,17 @@ export function processIf(
205206 }
206207}
207208
208- function createIfBranch ( node : ElementNode , dir : DirectiveNode ) : IfBranchNode {
209+ function createIfBranch (
210+ node : ElementNode ,
211+ dir : DirectiveNode ,
212+ context : TransformContext ,
213+ ) : IfBranchNode {
209214 const isTemplateIf = node . tagType === ElementTypes . TEMPLATE
215+ const keyProp = findProp ( node , `key` , false , true )
216+ // resolve :key shorthand #11321
217+ if ( keyProp && keyProp . type === NodeTypes . DIRECTIVE && ! keyProp . exp ) {
218+ transformBindShorthand ( keyProp , context )
219+ }
210220 return {
211221 type : NodeTypes . IF_BRANCH ,
212222 loc : node . loc ,
0 commit comments