Skip to content

Commit bccb5ef

Browse files
committed
feat(vue-jsx-vapor): support array expression
1 parent 7764ba3 commit bccb5ef

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/compiler/src/utils.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ export function getLiteralExpressionValue(
6767
export const isConstant = (node: Node | null | undefined): boolean => {
6868
if (!node) return false
6969
if (node.type === 'Identifier') {
70-
return node.name === 'undefined'
70+
return node.name === 'undefined' || isGloballyAllowed(node.name)
71+
}
72+
if (['JSXElement', 'JSXFragment', 'NullLiteral'].includes(node.type)) {
73+
return true
7174
}
7275
if (node.type === 'ArrayExpression') {
7376
const { elements } = node

packages/vue-jsx-vapor/src/core/runtime.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,15 @@ function normalizeNode(node: any, anchor?: Node): Block {
9191
}
9292
}
9393

94-
function resolveValue(current: Block, value: any, anchor?: Node) {
95-
const node = normalizeNode(value, anchor)
94+
function resolveValue(current: Block, value: any, _anchor?: Node) {
95+
const node = normalizeNode(value, _anchor)
9696
if (current) {
9797
if (isFragment(current)) {
9898
const { anchor } = current
9999
if (anchor && anchor.parentNode) {
100100
remove(current.nodes, anchor.parentNode)
101101
insert(node, anchor.parentNode, anchor)
102-
anchor.parentNode.removeChild(anchor)
102+
!_anchor && anchor.parentNode.removeChild(anchor)
103103
}
104104
} else if (current instanceof Node) {
105105
if (isFragment(node) && current.parentNode) {

0 commit comments

Comments
 (0)