+++ /dev/null
-{
- "semi": false,
- "singleQuote": true,
- "trailingComma": "all"
-}
if (vaporHelpers.size)
// TODO: extract import codegen
preamble = `import { ${[...vaporHelpers]
- .map((h) => `${h} as _${h}`)
+ .map(h => `${h} as _${h}`)
.join(', ')} } from 'vue/vapor';`
if (helpers.size)
preamble = `import { ${[...helpers]
- .map((h) => `${h} as _${h}`)
+ .map(h => `${h} as _${h}`)
.join(', ')} } from 'vue';`
if (!isSetupInlined) {
// directive
pushMulti(
['[', ']', ', '],
- ...opers.map((oper) => () => {
+ ...opers.map(oper => () => {
push('[')
const { dir, builtin } = oper
function genDirectiveModifiers(modifiers: string[]) {
return modifiers
.map(
- (value) =>
+ value =>
`${isSimpleIdentifier(value) ? value : JSON.stringify(value)}: true`,
)
.join(', ')
export function genInsertNode(oper: InsertNodeIRNode, context: CodegenContext) {
const { newline, pushFnCall, vaporHelper } = context
const elements = ([] as number[]).concat(oper.element)
- let element = elements.map((el) => `n${el}`).join(', ')
+ let element = elements.map(el => `n${el}`).join(', ')
if (elements.length > 1) element = `[${element}]`
newline()
pushFnCall(
pushFnCall(
vaporHelper('prepend'),
`n${oper.parent}`,
- oper.elements.map((el) => `n${el}`).join(', '),
+ oper.elements.map(el => `n${el}`).join(', '),
)
}
pushFnCall(
vaporHelper('append'),
`n${oper.parent}`,
- oper.elements.map((el) => `n${el}`).join(', '),
+ oper.elements.map(el => `n${el}`).join(', '),
)
}
},
// 4th arg, gen options
!!options.length &&
- (() => push(`{ ${options.map((v) => `${v}: true`).join(', ')} }`)),
+ (() => push(`{ ${options.map(v => `${v}: true`).join(', ')} }`)),
)
function genEventHandler(context: CodegenContext) {
}
function genArrayExpression(elements: string[]) {
- return `[${elements.map((it) => JSON.stringify(it)).join(', ')}]`
+ return `[${elements.map(it => JSON.stringify(it)).join(', ')}]`
}
) {
return this.registerOperation(...operations)
}
- const existing = this.block.effect.find((e) =>
+ const existing = this.block.effect.find(e =>
isSameExpression(e.expressions, expressions as IRExpression[]),
)
if (existing) {
registerTemplate() {
let templateNode: TemplateFactoryIRNode | FragmentFactoryIRNode
- const existing = root.template.findIndex((t) =>
+ const existing = root.template.findIndex(t =>
this.template
? t.type === IRNodeTypes.TEMPLATE_FACTORY &&
t.template === this.template
ctx.registerOperation({
type: IRNodeTypes.INSERT_NODE,
loc: node.loc,
- element: prevChildren.map((child) => child.id!),
+ element: prevChildren.map(child => child.id!),
parent: ctx.reference(),
anchor,
})
ctx.registerOperation({
type: IRNodeTypes.PREPEND_NODE,
loc: node.loc,
- elements: prevChildren.map((child) => child.id!),
+ elements: prevChildren.map(child => child.id!),
parent: ctx.reference(),
})
}
ctx.registerOperation({
type: IRNodeTypes.APPEND_NODE,
loc: node.loc,
- elements: prevChildren.map((child) => child.id!),
+ elements: prevChildren.map(child => child.id!),
parent: ctx.reference(),
})
}
children: [
extend({}, node, {
props: node.props.filter(
- (p) => p.type !== NodeTypes.DIRECTIVE && p.name !== 'if',
+ p => p.type !== NodeTypes.DIRECTIVE && p.name !== 'if',
),
} as TemplateChildNode),
],
+++ /dev/null
-{
- "semi": false,
- "singleQuote": true,
- "trailingComma": "all"
-}
scope.run(() => {
source = ref(0)
- watchEffect((onCleanup) => {
+ watchEffect(onCleanup => {
source.value
onCleanup(() => (dummy += 2))
return { source, change, renderSource, changeRender }
},
// render
- (_ctx) => {
+ _ctx => {
// Render Watch API
renderEffect(() => {
const current = _ctx.renderSource
})
renderWatch(
() => _ctx.renderSource,
- (value) => {
+ value => {
calls.push(`renderWatch ${value}`)
onEffectCleanup(() => calls.push(`renderWatch cleanup ${value}`))
},
return { source, update }
},
// render
- (ctx) => {
+ ctx => {
renderEffect(() => {
ctx.source
})
return { source, update }
},
// render
- (ctx) => {
+ ctx => {
renderEffect(() => {
ctx.source
})
expectedTypes: PropType<any> | void | null | true,
): number {
if (isArray(expectedTypes)) {
- return expectedTypes.findIndex((t) => isSameType(t, type))
+ return expectedTypes.findIndex(t => isSameType(t, type))
} else if (isFunction(expectedTypes)) {
return isSameType(expectedTypes, type) ? 0 : -1
}
): AssignerFn {
const metadata = instance.metadata.get(el)!
const fn: any = metadata.props['onUpdate:modelValue']
- return isArray(fn) ? (value) => invokeArrayFns(fn, value) : fn
+ return isArray(fn) ? value => invokeArrayFns(fn, value) : fn
}
function onCompositionStart(e: Event) {
assignKeyMap.set(el, assigner)
const castToNumber = number // || (vnode.props && vnode.props.type === 'number')
- on(el, lazy ? 'change' : 'input', (e) => {
+ on(el, lazy ? 'change' : 'input', e => {
if ((e.target as any).composing) return
let domValue: string | number = el.value
if (trim) {
if (isFunction(fn)) {
const res = callWithErrorHandling(fn, instance, type, args)
if (res && isPromise(res)) {
- res.catch((err) => {
+ res.catch(err => {
handleError(err, instance, type)
})
}
renderWatch(
() => !!condition(),
- (value) => {
+ value => {
parent ||= anchor.parentNode
if ((branch = value ? b1 : b2)) {
let scope = effectScope()
const createMiddleware =
(instance: ComponentInternalInstance | null): BaseWatchMiddleware =>
- (next) => {
+ next => {
let value: unknown
// with lifecycle
if (instance && instance.isMounted) {
}
export const createVaporPreScheduler: SchedulerFactory =
- (instance) => (job, effect, isInit) => {
+ instance => (job, effect, isInit) => {
if (isInit) {
effect.run()
} else {
}
export const createVaporRenderingScheduler: SchedulerFactory =
- (instance) => (job, effect, isInit) => {
+ instance => (job, effect, isInit) => {
if (isInit) {
effect.run()
} else {