File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -638,6 +638,26 @@ describe('compiler: v-for', () => {
638
638
} )
639
639
} )
640
640
} )
641
+
642
+ test ( 'template v-for key no prefixing on attribute key' , ( ) => {
643
+ const {
644
+ node : { codegenNode }
645
+ } = parseWithForTransform (
646
+ '<template v-for="item in items" key="key">test</template>' ,
647
+ { prefixIdentifiers : true }
648
+ )
649
+ const innerBlock = codegenNode . children . arguments [ 1 ] . returns
650
+ expect ( innerBlock ) . toMatchObject ( {
651
+ type : NodeTypes . VNODE_CALL ,
652
+ tag : FRAGMENT ,
653
+ props : createObjectMatcher ( {
654
+ key : {
655
+ type : NodeTypes . SIMPLE_EXPRESSION ,
656
+ content : 'key'
657
+ }
658
+ } )
659
+ } )
660
+ } )
641
661
} )
642
662
643
663
describe ( 'codegen' , ( ) => {
Original file line number Diff line number Diff line change @@ -68,7 +68,12 @@ export const transformFor = createStructuralDirectiveTransform(
68
68
: keyProp . exp ! )
69
69
const keyProperty = keyProp ? createObjectProperty ( `key` , keyExp ! ) : null
70
70
71
- if ( ! __BROWSER__ && context . prefixIdentifiers && keyProperty ) {
71
+ if (
72
+ ! __BROWSER__ &&
73
+ context . prefixIdentifiers &&
74
+ keyProperty &&
75
+ keyProp ! . type !== NodeTypes . ATTRIBUTE
76
+ ) {
72
77
// #2085 process :key expression needs to be processed in order for it
73
78
// to behave consistently for <template v-for> and <div v-for>.
74
79
// In the case of `<template v-for>`, the node is discarded and never
You can’t perform that action at this time.
0 commit comments