From: Anthony Fu Date: Thu, 12 Jan 2023 11:58:11 +0000 (+0100) Subject: chore: run format X-Git-Tag: v3.2.46~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a16b204be47de546d4b3c9eb3495c370341d336;p=thirdparty%2Fvuejs%2Fcore.git chore: run format --- diff --git a/packages/compiler-core/__tests__/parse.spec.ts b/packages/compiler-core/__tests__/parse.spec.ts index 8979e8fb0e..c4e1a3f2fc 100644 --- a/packages/compiler-core/__tests__/parse.spec.ts +++ b/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(`
`) expect(ast.children.length).toBe(5) diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts index 642f3edafd..93ecf7be39 100644 --- a/packages/compiler-core/src/parse.ts +++ b/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)))) diff --git a/packages/runtime-core/__tests__/apiWatch.spec.ts b/packages/runtime-core/__tests__/apiWatch.spec.ts index 6de8f95dec..7ae72cce7f 100644 --- a/packages/runtime-core/__tests__/apiWatch.spec.ts +++ b/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) }) diff --git a/packages/runtime-core/__tests__/componentProps.spec.ts b/packages/runtime-core/__tests__/componentProps.spec.ts index 195f352154..9763b22d3f 100644 --- a/packages/runtime-core/__tests__/componentProps.spec.ts +++ b/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 diff --git a/packages/runtime-core/__tests__/components/BaseTransition.spec.ts b/packages/runtime-core/__tests__/components/BaseTransition.spec.ts index 7b2fb38954..f0e49f2671 100644 --- a/packages/runtime-core/__tests__/components/BaseTransition.spec.ts +++ b/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( diff --git a/packages/runtime-core/src/apiWatch.ts b/packages/runtime-core/src/apiWatch.ts index a85e0e93be..ac5778cd43 100644 --- a/packages/runtime-core/src/apiWatch.ts +++ b/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 diff --git a/packages/runtime-dom/types/jsx.d.ts b/packages/runtime-dom/types/jsx.d.ts index 9471140310..b5e1487151 100644 --- a/packages/runtime-dom/types/jsx.d.ts +++ b/packages/runtime-dom/types/jsx.d.ts @@ -310,15 +310,15 @@ export interface HTMLAttributes extends AriaAttributes, EventHandlers { } 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 = { - [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