style: format

This commit is contained in:
三咲智子 Kevin Deng 2023-12-01 01:28:16 +08:00
parent 6a5dbc5143
commit 281d468020
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
5 changed files with 15 additions and 10 deletions

View File

@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}

View File

@ -16,7 +16,7 @@ export interface ComponentInternalInstance {
let uid = 0
export const createComponentInstance = (
component: BlockFn
component: BlockFn,
): ComponentInternalInstance => {
const instance: ComponentInternalInstance = {
uid: uid++,
@ -25,7 +25,7 @@ export const createComponentInstance = (
scope: new EffectScope(true /* detached */)!,
component,
isMounted: false
isMounted: false,
// TODO: registory of provides, appContext, lifecycles, ...
}
return instance

View File

@ -33,7 +33,7 @@ export {
effectScope,
EffectScope,
getCurrentScope,
onScopeDispose
onScopeDispose,
} from '@vue/reactivity'
export { effect } from './scheduler'
export * from './on'

View File

@ -2,7 +2,7 @@ export function on(
el: any,
event: string,
handler: () => any,
options?: EventListenerOptions
options?: EventListenerOptions,
) {
el.addEventListener(event, handler, options)
}

View File

@ -2,7 +2,7 @@ import {
isArray,
normalizeClass,
normalizeStyle,
toDisplayString
toDisplayString,
} from '@vue/shared'
import { ComponentInternalInstance, createComponentInstance } from './component'
@ -14,7 +14,7 @@ export type BlockFn = (props?: any) => Block
export function render(
comp: BlockFn,
container: string | ParentNode
container: string | ParentNode,
): ComponentInternalInstance {
const instance = createComponentInstance(comp)
mountComponent(instance, (container = normalizeContainer(container)))
@ -29,11 +29,11 @@ export function normalizeContainer(container: string | ParentNode): ParentNode {
export const mountComponent = (
instance: ComponentInternalInstance,
container: ParentNode
container: ParentNode,
) => {
instance.container = container
const block = instance.scope.run(
() => (instance.block = instance.component())
() => (instance.block = instance.component()),
)!
insert(block, instance.container)
instance.isMounted = true
@ -55,7 +55,7 @@ export const unmountComponent = (instance: ComponentInternalInstance) => {
export function insert(
block: Block,
parent: ParentNode,
anchor: Node | null = null
anchor: Node | null = null,
) {
// if (!isHydrating) {
if (block instanceof Node) {
@ -151,7 +151,7 @@ export function setDynamicProp(el: Element, key: string, val: any) {
type Children = Record<number, [ChildNode, Children]>
export function children(n: ChildNode): Children {
return { ...Array.from(n.childNodes).map(n => [n, children(n)]) }
return { ...Array.from(n.childNodes).map((n) => [n, children(n)]) }
}
export function createTextNode(val: unknown): Text {