Skip to content

Commit 8298323

Browse files
committed
add <template> key warning
1 parent f1e37f6 commit 8298323

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/compiler/parser/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ export function parse (
115115
processFor(element)
116116
processIf(element)
117117
processOnce(element)
118+
processKey(element)
118119

119120
// determine whether this is a plain element after
120121
// removing structural attributes
121122
element.plain = !element.key && !attrs.length
122123

123-
processKey(element)
124124
processRef(element)
125125
processSlot(element)
126126
processComponent(element)
@@ -258,6 +258,9 @@ function processRawAttrs (el) {
258258
function processKey (el) {
259259
const exp = getBindingAttr(el, 'key')
260260
if (exp) {
261+
if (process.env.NODE_ENV !== 'production' && el.tag === 'template') {
262+
warn(`<template> cannot be keyed. Place the key on real elements instead.`)
263+
}
261264
el.key = exp
262265
}
263266
}

0 commit comments

Comments
 (0)