2
0
三咲智子 Kevin Deng 2 жил өмнө
parent
commit
281d468020

+ 5 - 0
packages/runtime-vapor/.prettierrc

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

+ 2 - 2
packages/runtime-vapor/src/component.ts

@@ -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

+ 1 - 1
packages/runtime-vapor/src/index.ts

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

+ 1 - 1
packages/runtime-vapor/src/on.ts

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

+ 6 - 6
packages/runtime-vapor/src/render.ts

@@ -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 {