]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: update
authordaiwei <daiwei521@126.com>
Sat, 1 Feb 2025 03:37:03 +0000 (11:37 +0800)
committerdaiwei <daiwei521@126.com>
Sat, 1 Feb 2025 03:37:03 +0000 (11:37 +0800)
packages/runtime-core/src/hydration.ts

index aa94eb09619224f19b052ae1411215cda25d0392..bc938b58775bccd6eb4a392232d9c0c54f7796c1 100644 (file)
@@ -19,6 +19,7 @@ import {
   ShapeFlags,
   def,
   getEscapedCssVarName,
+  hasOwn,
   includeBooleanAttr,
   isBooleanAttr,
   isKnownHtmlAttr,
@@ -677,7 +678,7 @@ export function createHydrationFunctions(
   ): Node | null => {
     if (
       !isMismatchAllowed(node.parentElement!, MismatchTypes.CHILDREN) &&
-      !isCommentNodeMismatch(node, vnode)
+      !isMismatchAllowedForCommentNode(node, vnode)
     ) {
       ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) &&
         warn(
@@ -998,10 +999,13 @@ function isMismatchAllowed(
 }
 
 // data-allow-mismatch + v-if
-function isCommentNodeMismatch(node: Node, vnode: VNode): boolean {
-  if (node.nodeType !== DOMNodeTypes.COMMENT || !vnode.props) {
-    return false
-  }
-
-  return allowMismatchAttr in vnode.props
+function isMismatchAllowedForCommentNode(
+  node: Node,
+  { props }: VNode,
+): boolean {
+  return (
+    node.nodeType === DOMNodeTypes.COMMENT &&
+    props != null &&
+    hasOwn(props, allowMismatchAttr)
+  )
 }