Skip to content

Commit

Permalink
chore: run format
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 12, 2023
1 parent 4902354 commit 4a16b20
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion packages/compiler-core/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions packages/compiler-core/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down
19 changes: 7 additions & 12 deletions packages/runtime-core/__tests__/apiWatch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++
Expand All @@ -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)
})
Expand Down
43 changes: 29 additions & 14 deletions packages/runtime-core/__tests__/componentProps.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ describe('component props', () => {
})

test('warn on type mismatch', () => {
class MyClass {

}
class MyClass {}
const Comp = {
props: {
bool: { type: Boolean },
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,6 @@ describe('BaseTransition', () => {
})
})


// #6835
describe('mode: "out-in" toggle again after unmounted', () => {
async function testOutIn(
Expand Down
13 changes: 7 additions & 6 deletions packages/runtime-core/src/apiWatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ReactiveFlags,
EffectScheduler,
DebuggerOptions,
getCurrentScope,
getCurrentScope
} from '@vue/reactivity'
import { SchedulerJob, queueJob } from './scheduler'
import {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 12 additions & 10 deletions packages/runtime-dom/types/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4a16b20

Please sign in to comment.