Skip to content

Commit c7a417a

Browse files
committed
refactor
1 parent 1bc696a commit c7a417a

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

packages/compiler-vapor/src/compile.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import { transformVIf } from './transforms/vIf'
2828
import { transformVFor } from './transforms/vFor'
2929
import { transformComment } from './transforms/transformComment'
3030
import { transformSlotOutlet } from './transforms/transformSlotOutlet'
31-
import type { HackOptions } from './ir'
3231
import { transformVSlot } from './transforms/vSlot'
32+
import type { HackOptions } from './ir'
3333

3434
export { wrapTemplate } from './transforms/utils'
3535

packages/compiler-vapor/src/generators/component.ts

+11-17
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function genCreateComponent(
3434
const { vaporHelper } = context
3535

3636
const tag = genTag()
37-
const { root: isRoot, slots, dynamicSlots } = oper
37+
const { root, slots, dynamicSlots } = oper
3838
const rawProps = genRawProps(oper.props, context)
3939

4040
return [
@@ -43,18 +43,14 @@ export function genCreateComponent(
4343
...genCall(
4444
vaporHelper('createComponent'),
4545
tag,
46-
rawProps || (slots || dynamicSlots || isRoot ? 'null' : false),
47-
slots
48-
? genSlots(slots, context)
49-
: dynamicSlots || isRoot
50-
? 'null'
51-
: false,
46+
rawProps || (slots || dynamicSlots || root ? 'null' : false),
47+
slots ? genSlots(slots, context) : dynamicSlots || root ? 'null' : false,
5248
dynamicSlots
5349
? genDynamicSlots(dynamicSlots, context)
54-
: isRoot
50+
: root
5551
? 'null'
5652
: false,
57-
isRoot && 'true',
53+
root && 'true',
5854
),
5955
...genDirectivesForElement(oper.id, context),
6056
]
@@ -149,12 +145,10 @@ function genModelModifiers(
149145
}
150146

151147
function genSlots(slots: ComponentSlots, context: CodegenContext) {
152-
const slotList = Object.entries(slots!)
148+
const slotList = Object.entries(slots)
153149
return genMulti(
154150
slotList.length > 1 ? SEGMENTS_OBJECT_NEWLINE : SEGMENTS_OBJECT,
155-
...slotList.map(([name, slot]) => {
156-
return [name, ': ', ...genBlock(slot, context)]
157-
}),
151+
...slotList.map(([name, slot]) => [name, ': ', ...genBlock(slot, context)]),
158152
)
159153
}
160154

@@ -164,13 +158,13 @@ function genDynamicSlots(
164158
) {
165159
const slotsExpr = genMulti(
166160
dynamicSlots.length > 1 ? SEGMENTS_ARRAY_NEWLINE : SEGMENTS_ARRAY,
167-
...dynamicSlots.map(({ name, fn }) => {
168-
return genMulti(
161+
...dynamicSlots.map(({ name, fn }) =>
162+
genMulti(
169163
SEGMENTS_OBJECT_NEWLINE,
170164
['name: ', ...genExpression(name, context)],
171165
['fn: ', ...genBlock(fn, context)],
172-
)
173-
}),
166+
),
167+
),
174168
)
175169
return ['() => ', ...slotsExpr]
176170
}

0 commit comments

Comments
 (0)