Skip to content

Commit 680bed3

Browse files
committed
chore : refactor code
1 parent 74cb6d8 commit 680bed3

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/compiler-core/__tests__/transforms/transformElement.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ describe('compiler: element transform', () => {
12441244
else expect(spy).not.toHaveBeenCalled()
12451245
}
12461246

1247-
test('does not warn if has one children', () => {
1247+
test('does not warn if has one child', () => {
12481248
checkWarning(
12491249
`<KeepAlive>
12501250
<component :is="activeComponent"/>

packages/compiler-core/src/transforms/transformElement.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ export const transformElement: NodeTransform = (node, context) => {
145145
}
146146

147147
// children
148-
if (node.children.length > 0) {
149-
let filterdChildren = node.children
148+
if (node.children.length > 0) {
149+
let children = node.children
150150
if (vnodeTag === KEEP_ALIVE) {
151151
// Although a built-in component, we compile KeepAlive with raw children
152152
// instead of slot functions so that it can be used inside Transition
@@ -158,13 +158,13 @@ export const transformElement: NodeTransform = (node, context) => {
158158
// 2. Force keep-alive to always be updated, since it uses raw children.
159159
patchFlag |= PatchFlags.DYNAMIC_SLOTS
160160
//filter out potential comment nodes
161-
filterdChildren = filterdChildren.filter(c => c.type !== NodeTypes.COMMENT)
161+
children = children.filter(c => c.type !== NodeTypes.COMMENT)
162162
// warn if <KeepAlive> has multiple children
163-
if (__DEV__ && filterdChildren.length > 1) {
163+
if (__DEV__ && children.length > 1) {
164164
context.onError(
165165
createCompilerError(ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN, {
166-
start: filterdChildren[0].loc.start,
167-
end: filterdChildren[filterdChildren.length - 1].loc.end,
166+
start: children[0].loc.start,
167+
end: children[children.length - 1].loc.end,
168168
source: ''
169169
})
170170
)
@@ -184,8 +184,8 @@ export const transformElement: NodeTransform = (node, context) => {
184184
if (hasDynamicSlots) {
185185
patchFlag |= PatchFlags.DYNAMIC_SLOTS
186186
}
187-
} else if (filterdChildren.length === 1 && vnodeTag !== TELEPORT) {
188-
const child = filterdChildren[0]
187+
} else if (children.length === 1 && vnodeTag !== TELEPORT) {
188+
const child = children[0]
189189
const type = child.type
190190
// check for dynamic text children
191191
const hasDynamicTextChild =

0 commit comments

Comments
 (0)