})
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)
(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))))
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++
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)
})
})
test('warn on type mismatch', () => {
- class MyClass {
-
- }
+ class MyClass {}
const Comp = {
props: {
bool: { type: Boolean },
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
})
})
-
// #6835
describe('mode: "out-in" toggle again after unmounted', () => {
async function testOutIn(
ReactiveFlags,
EffectScheduler,
DebuggerOptions,
- getCurrentScope,
+ getCurrentScope
} from '@vue/reactivity'
import { SchedulerJob, queueJob } from './scheduler'
import {
)
}
- const instance = getCurrentScope() === currentInstance?.scope ? currentInstance : null
+ const instance =
+ getCurrentScope() === currentInstance?.scope ? currentInstance : null
// const instance = currentInstance
let getter: () => any
let forceTrigger = false
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
}
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
}
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