Anthony Fu 3 лет назад
Родитель
Сommit
4a16b204be

+ 1 - 1
packages/compiler-core/__tests__/parse.spec.ts

@@ -1990,7 +1990,7 @@ foo
       })
       expect(ast.children[2].type).toBe(NodeTypes.INTERPOLATION)
     })
-    
+
     it('should NOT remove whitespaces w/o newline between elements', () => {
       const ast = parse(`<div/> <div/> <div/>`)
       expect(ast.children.length).toBe(5)

+ 3 - 3
packages/compiler-core/src/parse.ts

@@ -273,10 +273,10 @@ function parseChildren(
               (shouldCondense &&
                 ((prev.type === NodeTypes.COMMENT &&
                   next.type === NodeTypes.COMMENT) ||
-                  (prev.type === NodeTypes.COMMENT && 
-                  next.type === NodeTypes.ELEMENT) ||
+                  (prev.type === NodeTypes.COMMENT &&
+                    next.type === NodeTypes.ELEMENT) ||
                   (prev.type === NodeTypes.ELEMENT &&
-                  next.type === NodeTypes.COMMENT) ||
+                    next.type === NodeTypes.COMMENT) ||
                   (prev.type === NodeTypes.ELEMENT &&
                     next.type === NodeTypes.ELEMENT &&
                     /[\r\n]/.test(node.content))))

+ 7 - 12
packages/runtime-core/__tests__/apiWatch.spec.ts

@@ -1158,23 +1158,18 @@ describe('api: watch', () => {
     const Comp = {
       setup() {
         effectScope(true).run(() => {
-          watchEffect(
-            () => {
-              trigger.value
-              countWE++
-            },
-          )
-          watch(
-            trigger,
-            () => countW++
-          )
+          watchEffect(() => {
+            trigger.value
+            countWE++
+          })
+          watch(trigger, () => countW++)
         })
         return () => ''
       }
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
-     // only watchEffect as ran so far
+    // only watchEffect as ran so far
     expect(countWE).toBe(1)
     expect(countW).toBe(0)
     trigger.value++
@@ -1186,7 +1181,7 @@ describe('api: watch', () => {
     await nextTick()
     trigger.value++
     await nextTick()
-     // both watchers run again event though component has been unmounted
+    // both watchers run again event though component has been unmounted
     expect(countWE).toBe(3)
     expect(countW).toBe(2)
   })

+ 29 - 14
packages/runtime-core/__tests__/componentProps.spec.ts

@@ -322,9 +322,7 @@ describe('component props', () => {
   })
 
   test('warn on type mismatch', () => {
-    class MyClass {
-
-    }
+    class MyClass {}
     const Comp = {
       props: {
         bool: { type: Boolean },
@@ -333,28 +331,45 @@ describe('component props', () => {
         arr: { type: Array },
         obj: { type: Object },
         cls: { type: MyClass },
-        fn: { type: Function },
+        fn: { type: Function }
       },
       setup() {
         return () => null
       }
     }
-    render(h(Comp, {
+    render(
+      h(Comp, {
         bool: 'true',
         str: 100,
         num: '100',
         arr: {},
         obj: 'false',
         cls: {},
-        fn: true,
-    }), nodeOps.createElement('div'))
-    expect(`Invalid prop: type check failed for prop "bool". Expected Boolean, got String`).toHaveBeenWarned()
-    expect(`Invalid prop: type check failed for prop "str". Expected String with value "100", got Number with value 100.`).toHaveBeenWarned()
-    expect(`Invalid prop: type check failed for prop "num". Expected Number with value 100, got String with value "100".`).toHaveBeenWarned()
-    expect(`Invalid prop: type check failed for prop "arr". Expected Array, got Object`).toHaveBeenWarned()
-    expect(`Invalid prop: type check failed for prop "obj". Expected Object, got String with value "false"`).toHaveBeenWarned()
-    expect(`Invalid prop: type check failed for prop "fn". Expected Function, got Boolean with value true.`).toHaveBeenWarned()
-    expect(`Invalid prop: type check failed for prop "cls". Expected MyClass, got Object`).toHaveBeenWarned()
+        fn: true
+      }),
+      nodeOps.createElement('div')
+    )
+    expect(
+      `Invalid prop: type check failed for prop "bool". Expected Boolean, got String`
+    ).toHaveBeenWarned()
+    expect(
+      `Invalid prop: type check failed for prop "str". Expected String with value "100", got Number with value 100.`
+    ).toHaveBeenWarned()
+    expect(
+      `Invalid prop: type check failed for prop "num". Expected Number with value 100, got String with value "100".`
+    ).toHaveBeenWarned()
+    expect(
+      `Invalid prop: type check failed for prop "arr". Expected Array, got Object`
+    ).toHaveBeenWarned()
+    expect(
+      `Invalid prop: type check failed for prop "obj". Expected Object, got String with value "false"`
+    ).toHaveBeenWarned()
+    expect(
+      `Invalid prop: type check failed for prop "fn". Expected Function, got Boolean with value true.`
+    ).toHaveBeenWarned()
+    expect(
+      `Invalid prop: type check failed for prop "cls". Expected MyClass, got Object`
+    ).toHaveBeenWarned()
   })
 
   // #3495

+ 0 - 1
packages/runtime-core/__tests__/components/BaseTransition.spec.ts

@@ -770,7 +770,6 @@ describe('BaseTransition', () => {
     })
   })
 
-
   // #6835
   describe('mode: "out-in" toggle again after unmounted', () => {
     async function testOutIn(

+ 7 - 6
packages/runtime-core/src/apiWatch.ts

@@ -8,7 +8,7 @@ import {
   ReactiveFlags,
   EffectScheduler,
   DebuggerOptions,
-  getCurrentScope,
+  getCurrentScope
 } from '@vue/reactivity'
 import { SchedulerJob, queueJob } from './scheduler'
 import {
@@ -198,7 +198,8 @@ function doWatch(
     )
   }
 
-  const instance = getCurrentScope() === currentInstance?.scope ?  currentInstance : null
+  const instance =
+    getCurrentScope() === currentInstance?.scope ? currentInstance : null
   // const instance = currentInstance
   let getter: () => any
   let forceTrigger = false
@@ -331,11 +332,11 @@ function doWatch(
         callWithAsyncErrorHandling(cb, instance, ErrorCodes.WATCH_CALLBACK, [
           newValue,
           // pass undefined as the old value when it's changed for the first time
-          oldValue === INITIAL_WATCHER_VALUE 
+          oldValue === INITIAL_WATCHER_VALUE
             ? undefined
-            : (isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE)
-              ? []
-              : oldValue,
+            : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE
+            ? []
+            : oldValue,
           onCleanup
         ])
         oldValue = newValue

+ 12 - 10
packages/runtime-dom/types/jsx.d.ts

@@ -310,15 +310,15 @@ export interface HTMLAttributes extends AriaAttributes, EventHandlers<Events> {
 }
 
 type HTMLAttributeReferrerPolicy =
-        | ''
-        | 'no-referrer'
-        | 'no-referrer-when-downgrade'
-        | 'origin'
-        | 'origin-when-cross-origin'
-        | 'same-origin'
-        | 'strict-origin'
-        | 'strict-origin-when-cross-origin'
-        | 'unsafe-url'
+  | ''
+  | 'no-referrer'
+  | 'no-referrer-when-downgrade'
+  | 'origin'
+  | 'origin-when-cross-origin'
+  | 'same-origin'
+  | 'strict-origin'
+  | 'strict-origin-when-cross-origin'
+  | 'unsafe-url'
 
 export interface AnchorHTMLAttributes extends HTMLAttributes {
   download?: any
@@ -1316,7 +1316,9 @@ export interface Events {
 }
 
 type EventHandlers<E> = {
-  [K in keyof E]?: E[K] extends (...args: any) => any ? E[K] : (payload: E[K]) => void
+  [K in keyof E]?: E[K] extends (...args: any) => any
+    ? E[K]
+    : (payload: E[K]) => void
 }
 
 // use namespace import to avoid collision with generated types which use