8000 dx(vnode): warn on render child nodes in self-closing tag · vuejs/core@44a6b08 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44a6b08

Browse files
author
yangchangtao
committed
dx(vnode): warn on render child nodes in self-closing tag
1 parent 35785f3 commit 44a6b08

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

packages/runtime-core/src/vnode.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isObject,
1010
isOn,
1111
isString,
12+
isVoidTag,
1213
normalizeClass,
1314
normalizeStyle,
1415
} from '@vue/shared'
@@ -618,6 +619,17 @@ function _createVNode(
618619
? ShapeFlags.FUNCTIONAL_COMPONENT
619620
: 0
620621

622+
if (
623+
__DEV__ &&
624+
shapeFlag & ShapeFlags.ELEMENT &&
625+
isVoidTag(type as string) &&
626+
children != null
627+
) {
628+
warn(
629+
`don't render child nodes in a self-closing tag <${type as string} />, it may cause unexpected behavior`,
630+
)
631+
}
632+
621633
if (__DEV__ && shapeFlag & ShapeFlags.STATEFUL_COMPONENT && isProxy(type)) {
622634
type = toRaw(type)
623635
warn(

0 commit comments

Comments
 (0)
0