|
@@ -14,14 +14,7 @@ import {
|
|
|
getSelfName,
|
|
getSelfName,
|
|
|
isVSlot,
|
|
isVSlot,
|
|
|
} from '@vue/compiler-dom'
|
|
} from '@vue/compiler-dom'
|
|
|
-import {
|
|
|
|
|
- EMPTY_OBJ,
|
|
|
|
|
- NOOP,
|
|
|
|
|
- extend,
|
|
|
|
|
- isArray,
|
|
|
|
|
- isInlineTag,
|
|
|
|
|
- isString,
|
|
|
|
|
-} from '@vue/shared'
|
|
|
|
|
|
|
+import { EMPTY_OBJ, NOOP, extend, isArray, isString } from '@vue/shared'
|
|
|
import {
|
|
import {
|
|
|
type BlockIRNode,
|
|
type BlockIRNode,
|
|
|
DynamicFlag,
|
|
DynamicFlag,
|
|
@@ -111,13 +104,13 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|
|
// whether this node is on the rightmost path of the tree
|
|
// whether this node is on the rightmost path of the tree
|
|
|
// (all ancestors are also last effective children)
|
|
// (all ancestors are also last effective children)
|
|
|
isOnRightmostPath: boolean = true
|
|
isOnRightmostPath: boolean = true
|
|
|
- // whether there is an inline ancestor that needs closing
|
|
|
|
|
- // (i.e. is an inline tag and not on the rightmost path)
|
|
|
|
|
- hasInlineAncestorNeedingClose: boolean = false
|
|
|
|
|
// If an ancestor in the same template must close explicitly, descendants
|
|
// If an ancestor in the same template must close explicitly, descendants
|
|
|
// with matching tags must also close so the browser doesn't consume the
|
|
// with matching tags must also close so the browser doesn't consume the
|
|
|
// ancestor close tag for the descendant.
|
|
// ancestor close tag for the descendant.
|
|
|
templateCloseTags: Set<string> | undefined = undefined
|
|
templateCloseTags: Set<string> | undefined = undefined
|
|
|
|
|
+ // Inline ancestors with explicit close tags also require block descendants
|
|
|
|
|
+ // in the same template to close explicitly.
|
|
|
|
|
+ templateCloseBlocks: boolean = false
|
|
|
|
|
|
|
|
private globalId = 0
|
|
private globalId = 0
|
|
|
private nextIdMap: Map<number, number> | null = null
|
|
private nextIdMap: Map<number, number> | null = null
|
|
@@ -329,25 +322,6 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|
|
const isLastEffectiveChild = this.isEffectivelyLastChild(index)
|
|
const isLastEffectiveChild = this.isEffectivelyLastChild(index)
|
|
|
const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild
|
|
const isOnRightmostPath = this.isOnRightmostPath && isLastEffectiveChild
|
|
|
|
|
|
|
|
- // propagate the inline ancestor status
|
|
|
|
|
- let hasInlineAncestorNeedingClose = this.hasInlineAncestorNeedingClose
|
|
|
|
|
- if (this.node.type === NodeTypes.ELEMENT) {
|
|
|
|
|
- if (this.node.tag === 'template') {
|
|
|
|
|
- // <template> acts as a boundary ensuring its content is parsed as a fragment,
|
|
|
|
|
- // protecting inner blocks from outer inline contexts.
|
|
|
|
|
- hasInlineAncestorNeedingClose = false
|
|
|
|
|
- } else if (
|
|
|
|
|
- !hasInlineAncestorNeedingClose &&
|
|
|
|
|
- !this.isOnRightmostPath &&
|
|
|
|
|
- isInlineTag(this.node.tag)
|
|
|
|
|
- ) {
|
|
|
|
|
- // Logic: if current node (parent of the node being created) is inline
|
|
|
|
|
- // AND it's not on the rightmost path, then it needs closing.
|
|
|
|
|
- // Any block child inside will need to be careful.
|
|
|
|
|
- hasInlineAncestorNeedingClose = true
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
return Object.assign(Object.create(TransformContext.prototype), this, {
|
|
return Object.assign(Object.create(TransformContext.prototype), this, {
|
|
|
node,
|
|
node,
|
|
|
parent: this as any,
|
|
parent: this as any,
|
|
@@ -363,8 +337,8 @@ export class TransformContext<T extends AllNode = AllNode> {
|
|
|
effectiveParent,
|
|
effectiveParent,
|
|
|
isLastEffectiveChild,
|
|
isLastEffectiveChild,
|
|
|
isOnRightmostPath,
|
|
isOnRightmostPath,
|
|
|
- hasInlineAncestorNeedingClose,
|
|
|
|
|
templateCloseTags: this.templateCloseTags,
|
|
templateCloseTags: this.templateCloseTags,
|
|
|
|
|
+ templateCloseBlocks: this.templateCloseBlocks,
|
|
|
} satisfies Partial<TransformContext<T>>)
|
|
} satisfies Partial<TransformContext<T>>)
|
|
|
}
|
|
}
|
|
|
|
|
|