} from '@vue/runtime-dom'
import { isHydrating } from './dom/hydration'
import { getInheritedScopeIds } from '@vue/runtime-dom'
-import { DynamicFragment, type VaporFragment, isFragment } from './fragment'
+import {
+ type DynamicFragment,
+ type VaporFragment,
+ isFragment,
+} from './fragment'
export interface TransitionOptions {
$key?: any
}
}
-export function findLastChild(node: Block): Node | undefined | null {
- if (node && node instanceof Node) {
- return node
- } else if (isArray(node)) {
- return findLastChild(node[node.length - 1])
- } else if (isVaporComponent(node)) {
- return findLastChild(node.block!)
- } else {
- if (node instanceof DynamicFragment) return node.anchor
- return findLastChild(node.nodes!)
- }
-}
-
/**
* dev / test only
*/
type BlockFn,
type TransitionOptions,
type VaporTransitionHooks,
- findLastChild,
insert,
isValidBlock,
remove,
this.anchor = locateVaporFragmentAnchor(currentHydrationNode!, '')!
} else {
this.anchor = locateVaporFragmentAnchor(currentHydrationNode!, label)!
- if (!this.anchor && label === 'slot') {
- // fallback to fragment end anchor for
- this.anchor = locateVaporFragmentAnchor(currentHydrationNode!, ']')!
- }
- // anchors are not present in ssr slot vnode fallback
- if (!this.anchor) {
- const { parentNode, nextSibling } = findLastChild(this.nodes)!
+ // forwarded slots anchors are not present in ssr vnode-based slot
+ if (
+ !this.anchor &&
+ this.nodes instanceof DynamicFragment &&
+ this.nodes.forwarded
+ ) {
+ const { parentNode, nextSibling } = this.nodes.anchor
parentNode!.insertBefore(
- // TODO use empty text node in PROD?
- (this.anchor = createComment(label)),
+ (this.anchor = __DEV__ ? createComment(label) : createTextNode()),
nextSibling,
)
}