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

View File

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

View File

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

View File

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