chore: run updated prettier

This commit is contained in:
Evan You 2021-07-19 18:24:18 -04:00
parent 69344ff1ae
commit 47f488350c
110 changed files with 695 additions and 698 deletions

View File

@ -61,11 +61,7 @@ describe('compiler: codegen', () => {
})
const { code } = generate(root, { mode: 'module' })
expect(code).toMatch(
`import { ${helperNameMap[CREATE_VNODE]} as _${
helperNameMap[CREATE_VNODE]
}, ${helperNameMap[RESOLVE_DIRECTIVE]} as _${
helperNameMap[RESOLVE_DIRECTIVE]
} } from "vue"`
`import { ${helperNameMap[CREATE_VNODE]} as _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]} as _${helperNameMap[RESOLVE_DIRECTIVE]} } from "vue"`
)
expect(code).toMatchSnapshot()
})
@ -76,16 +72,10 @@ describe('compiler: codegen', () => {
})
const { code } = generate(root, { mode: 'module', optimizeImports: true })
expect(code).toMatch(
`import { ${helperNameMap[CREATE_VNODE]}, ${
helperNameMap[RESOLVE_DIRECTIVE]
} } from "vue"`
`import { ${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]} } from "vue"`
)
expect(code).toMatch(
`const _${helperNameMap[CREATE_VNODE]} = ${
helperNameMap[CREATE_VNODE]
}, _${helperNameMap[RESOLVE_DIRECTIVE]} = ${
helperNameMap[RESOLVE_DIRECTIVE]
}`
`const _${helperNameMap[CREATE_VNODE]} = ${helperNameMap[CREATE_VNODE]}, _${helperNameMap[RESOLVE_DIRECTIVE]} = ${helperNameMap[RESOLVE_DIRECTIVE]}`
)
expect(code).toMatchSnapshot()
})
@ -97,11 +87,7 @@ describe('compiler: codegen', () => {
const { code } = generate(root, { mode: 'function' })
expect(code).toMatch(`const _Vue = Vue`)
expect(code).toMatch(
`const { ${helperNameMap[CREATE_VNODE]}: _${
helperNameMap[CREATE_VNODE]
}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${
helperNameMap[RESOLVE_DIRECTIVE]
} } = _Vue`
`const { ${helperNameMap[CREATE_VNODE]}: _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${helperNameMap[RESOLVE_DIRECTIVE]} } = _Vue`
)
expect(code).toMatchSnapshot()
})
@ -116,11 +102,7 @@ describe('compiler: codegen', () => {
})
expect(code).not.toMatch(`const _Vue = Vue`)
expect(code).toMatch(
`const { ${helperNameMap[CREATE_VNODE]}: _${
helperNameMap[CREATE_VNODE]
}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${
helperNameMap[RESOLVE_DIRECTIVE]
} } = Vue`
`const { ${helperNameMap[CREATE_VNODE]}: _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${helperNameMap[RESOLVE_DIRECTIVE]} } = Vue`
)
expect(code).toMatchSnapshot()
})
@ -136,30 +118,20 @@ describe('compiler: codegen', () => {
`const _component_Foo = _${helperNameMap[RESOLVE_COMPONENT]}("Foo")\n`
)
expect(code).toMatch(
`const _component_bar_baz = _${
helperNameMap[RESOLVE_COMPONENT]
}("bar-baz")\n`
`const _component_bar_baz = _${helperNameMap[RESOLVE_COMPONENT]}("bar-baz")\n`
)
expect(code).toMatch(
`const _component_barbaz = _${
helperNameMap[RESOLVE_COMPONENT]
}("barbaz")\n`
`const _component_barbaz = _${helperNameMap[RESOLVE_COMPONENT]}("barbaz")\n`
)
// implicit self reference from SFC filename
expect(code).toMatch(
`const _component_Qux = _${
helperNameMap[RESOLVE_COMPONENT]
}("Qux", true)\n`
`const _component_Qux = _${helperNameMap[RESOLVE_COMPONENT]}("Qux", true)\n`
)
expect(code).toMatch(
`const _directive_my_dir_0 = _${
helperNameMap[RESOLVE_DIRECTIVE]
}("my_dir_0")\n`
`const _directive_my_dir_0 = _${helperNameMap[RESOLVE_DIRECTIVE]}("my_dir_0")\n`
)
expect(code).toMatch(
`const _directive_my_dir_1 = _${
helperNameMap[RESOLVE_DIRECTIVE]
}("my_dir_1")\n`
`const _directive_my_dir_1 = _${helperNameMap[RESOLVE_DIRECTIVE]}("my_dir_1")\n`
)
expect(code).toMatch(`let _temp0, _temp1, _temp2`)
expect(code).toMatchSnapshot()

View File

@ -2871,7 +2871,7 @@ foo
]
}
for (const key of Object.keys(patterns) as (keyof (typeof patterns))[]) {
for (const key of Object.keys(patterns) as (keyof typeof patterns)[]) {
describe(key, () => {
for (const { code, errors, options } of patterns[key]) {
test(

View File

@ -355,8 +355,9 @@ describe('compiler: hoistStatic transform', () => {
},
hoistedChildrenArrayMatcher(2)
])
const forBlockCodegen = ((root.children[0] as ElementNode)
.children[0] as ForNode).codegenNode
const forBlockCodegen = (
(root.children[0] as ElementNode).children[0] as ForNode
).codegenNode
expect(forBlockCodegen).toMatchObject({
type: NodeTypes.VNODE_CALL,
tag: FRAGMENT,

View File

@ -290,8 +290,8 @@ describe('compiler: transform v-model', () => {
test('with dynamic argument', () => {
const root = parseWithVModel('<input v-model:[value]="model" />')
const node = root.children[0] as ElementNode
const props = ((node.codegenNode as VNodeCall)
.props as unknown) as CallExpression
const props = (node.codegenNode as VNodeCall)
.props as unknown as CallExpression
expect(props).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
@ -344,8 +344,8 @@ describe('compiler: transform v-model', () => {
prefixIdentifiers: true
})
const node = root.children[0] as ElementNode
const props = ((node.codegenNode as VNodeCall)
.props as unknown) as CallExpression
const props = (node.codegenNode as VNodeCall)
.props as unknown as CallExpression
expect(props).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
@ -417,8 +417,9 @@ describe('compiler: transform v-model', () => {
}
)
expect(root.cached).toBe(0)
const codegen = ((root.children[0] as ForNode)
.children[0] as PlainElementNode).codegenNode as VNodeCall
const codegen = (
(root.children[0] as ForNode).children[0] as PlainElementNode
).codegenNode as VNodeCall
expect(codegen.dynamicProps).toBe(`["modelValue", "onUpdate:modelValue"]`)
expect(
(codegen.props as ObjectExpression).properties[1].value.type
@ -426,13 +427,10 @@ describe('compiler: transform v-model', () => {
})
test('should not cache update handler if it inside v-once', () => {
const root = parseWithVModel(
'<div v-once><input v-model="foo" /></div>',
{
const root = parseWithVModel('<div v-once><input v-model="foo" /></div>', {
prefixIdentifiers: true,
cacheHandlers: true
}
)
})
expect(root.cached).not.toBe(2)
expect(root.cached).toBe(1)
})
@ -444,8 +442,9 @@ describe('compiler: transform v-model', () => {
prefixIdentifiers: true
}
)
const codegen = ((root.children[0] as ComponentNode)
.children[0] as PlainElementNode).codegenNode as VNodeCall
const codegen = (
(root.children[0] as ComponentNode).children[0] as PlainElementNode
).codegenNode as VNodeCall
expect(codegen.dynamicProps).toBe(`["modelValue", "onUpdate:modelValue"]`)
})

View File

@ -531,10 +531,13 @@ describe('compiler: transform v-on', () => {
})
test('should not be cached inside v-once', () => {
const { root } = parseWithVOn(`<div v-once><div v-on:click="foo"/></div>`, {
const { root } = parseWithVOn(
`<div v-once><div v-on:click="foo"/></div>`,
{
prefixIdentifiers: true,
cacheHandlers: true
})
}
)
expect(root.cached).not.toBe(2)
expect(root.cached).toBe(1)
})

View File

@ -237,7 +237,8 @@ export interface CompoundExpressionNode extends Node {
| InterpolationNode
| TextNode
| string
| symbol)[]
| symbol
)[]
/**
* an expression parsed as the params of a function will track
@ -328,7 +329,8 @@ export interface CallExpression extends Node {
| JSChildNode
| SSRCodegenNode
| TemplateChildNode
| TemplateChildNode[])[]
| TemplateChildNode[]
)[]
}
export interface ObjectExpression extends Node {

View File

@ -83,9 +83,8 @@ export function baseCompile(
}
const ast = isString(template) ? baseParse(template, options) : template
const [nodeTransforms, directiveTransforms] = getBaseTransformPreset(
prefixIdentifiers
)
const [nodeTransforms, directiveTransforms] =
getBaseTransformPreset(prefixIdentifiers)
transform(
ast,
extend({}, options, {

View File

@ -774,7 +774,8 @@ function parseAttribute(
const loc = getSelection(context, start)
if (!context.inVPre && /^(v-|:|\.|@|#)/.test(name)) {
const match = /(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
const match =
/(?:^v-([a-z0-9-]+))?(?:(?::|^\.|^@|^#)(\[[^\]]+\]|[^\.]+))?(.+)?$/i.exec(
name
)!

View File

@ -221,11 +221,13 @@ export const transformFor = createStructuralDirectiveTransform(
createSimpleExpression(String(context.cached++))
)
} else {
renderExp.arguments.push(createFunctionExpression(
renderExp.arguments.push(
createFunctionExpression(
createForLoopParams(forNode.parseResult),
childBlock,
true /* force newline */
) as ForIteratorExpression)
) as ForIteratorExpression
)
}
}
})
@ -343,9 +345,7 @@ export function parseForExpression(
validateBrowserExpression(result.source as SimpleExpressionNode, context)
}
let valueContent = LHS.trim()
.replace(stripParensRE, '')
.trim()
let valueContent = LHS.trim().replace(stripParensRE, '').trim()
const trimmedOffset = LHS.indexOf(valueContent)
const iteratorMatch = valueContent.match(forIteratorRE)

View File

@ -319,8 +319,8 @@ function isSameKey(
}
if (
exp.type !== NodeTypes.SIMPLE_EXPRESSION ||
(exp.isStatic !== (branchExp as SimpleExpressionNode).isStatic ||
exp.content !== (branchExp as SimpleExpressionNode).content)
exp.isStatic !== (branchExp as SimpleExpressionNode).isStatic ||
exp.content !== (branchExp as SimpleExpressionNode).content
) {
return false
}

View File

@ -18,7 +18,8 @@ const prohibitedKeywordRE = new RegExp(
)
// strip strings in expressions
const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g
const stripStringRE =
/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g
/**
* Validate a non-prefixed expression.
@ -51,9 +52,7 @@ export function validateBrowserExpression(
.replace(stripStringRE, '')
.match(prohibitedKeywordRE)
if (keywordMatch) {
message = `avoid using JavaScript keyword as property name: "${
keywordMatch[0]
}"`
message = `avoid using JavaScript keyword as property name: "${keywordMatch[0]}"`
}
context.onError(
createCompilerError(

View File

@ -27,8 +27,10 @@ function parseWithVOn(template: string, options: CompilerOptions = {}) {
})
return {
root: ast,
props: (((ast.children[0] as ElementNode).codegenNode as VNodeCall)
.props as ObjectExpression).properties
props: (
((ast.children[0] as ElementNode).codegenNode as VNodeCall)
.props as ObjectExpression
).properties
}
}

View File

@ -112,11 +112,8 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
if (!modifiers.length) return baseResult
let { key, value: handlerExp } = baseResult.props[0]
const {
keyModifiers,
nonKeyModifiers,
eventOptionModifiers
} = resolveModifiers(key, modifiers, context, dir.loc)
const { keyModifiers, nonKeyModifiers, eventOptionModifiers } =
resolveModifiers(key, modifiers, context, dir.loc)
// normalize click.right and click.middle since they don't actually fire
if (nonKeyModifiers.includes('right')) {

View File

@ -678,7 +678,9 @@ export function compileScript(
.map(key => {
let defaultString: string | undefined
if (hasStaticDefaults) {
const prop = (propsRuntimeDefaults as ObjectExpression).properties.find(
const prop = (
propsRuntimeDefaults as ObjectExpression
).properties.find(
(node: any) => node.key.name === key
) as ObjectProperty
if (prop) {
@ -776,9 +778,7 @@ export function compileScript(
// rewrite to `import { x as __default__ } from './x'` and
// add to top
s.prepend(
`import { ${
defaultSpecifier.local.name
} as ${defaultTempVar} } from '${node.source.value}'\n`
`import { ${defaultSpecifier.local.name} as ${defaultTempVar} } from '${node.source.value}'\n`
)
} else {
// export { x as default }
@ -1376,11 +1376,11 @@ export function compileScript(
...scriptSetup,
bindings: bindingMetadata,
content: s.toString(),
map: (s.generateMap({
map: s.generateMap({
source: filename,
hires: true,
includeContent: true
}) as unknown) as RawSourceMap,
}) as unknown as RawSourceMap,
scriptAst,
scriptSetupAst
}
@ -1651,9 +1651,9 @@ function inferRuntimeType(
case 'TSUnionType':
return [
...new Set(
[].concat(node.types.map(t =>
inferRuntimeType(t, declaredTypes)
) as any)
[].concat(
node.types.map(t => inferRuntimeType(t, declaredTypes)) as any
)
)
]
case 'TSIntersectionType':

View File

@ -79,9 +79,10 @@ export function compileStyle(
export function compileStyleAsync(
options: SFCAsyncStyleCompileOptions
): Promise<SFCStyleCompileResults> {
return doCompileStyle({ ...options, isAsync: true }) as Promise<
SFCStyleCompileResults
>
return doCompileStyle({
...options,
isAsync: true
}) as Promise<SFCStyleCompileResults>
}
export function doCompileStyle(

View File

@ -140,14 +140,10 @@ export function compileTemplate(
code: `export default function render() {}`,
source: options.source,
tips: [
`Component ${
options.filename
} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
`Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
],
errors: [
`Component ${
options.filename
} uses lang ${preprocessLang} for template, however it is not installed.`
`Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
]
}
} else {

View File

@ -12,7 +12,8 @@ import { PluginCreator } from 'postcss'
import hash from 'hash-sum'
export const CSS_VARS_HELPER = `useCssVars`
export const cssVarRE = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g
export const cssVarRE =
/\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g
export function genCssVarsFromList(
vars: string[],

View File

@ -3,7 +3,8 @@ import MagicString from 'magic-string'
const defaultExportRE = /((?:^|\n|;)\s*)export(\s*)default/
const namedDefaultExportRE = /((?:^|\n|;)\s*)export(.+)as(\s*)default/s
const exportDefaultClassRE = /((?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/
const exportDefaultClassRE =
/((?:^|\n|;)\s*)export\s+default\s+class\s+([\w$]+)/
/**
* Utility for rewriting `export default` in a script block into a variable

View File

@ -71,9 +71,10 @@ describe('ssr: element', () => {
`)
})
test("multiple _ssrInterpolate at parent and child import dependency once", () => {
expect( compile(`<div>{{ hello }}<textarea v-bind="a"></textarea></div>`).code)
.toMatchInlineSnapshot(`
test('multiple _ssrInterpolate at parent and child import dependency once', () => {
expect(
compile(`<div>{{ hello }}<textarea v-bind="a"></textarea></div>`).code
).toMatchInlineSnapshot(`
"const { ssrRenderAttrs: _ssrRenderAttrs, ssrInterpolate: _ssrInterpolate } = require(\\"@vue/server-renderer\\")
return function ssrRender(_ctx, _push, _parent, _attrs) {
@ -89,8 +90,8 @@ describe('ssr: element', () => {
_ssrInterpolate((\\"value\\" in _temp0) ? _temp0.value : \\"\\")
}</textarea></div>\`)
}"
`);
});
`)
})
test('should pass tag to custom elements w/ dynamic v-bind', () => {
expect(

View File

@ -56,10 +56,9 @@ export function ssrCodegenTransform(ast: RootNode, options: CompilerOptions) {
// Finalize helpers.
// We need to separate helpers imported from 'vue' vs. '@vue/server-renderer'
ast.ssrHelpers = Array.from(new Set([
...ast.helpers.filter(h => h in ssrHelpers),
...context.helpers
]))
ast.ssrHelpers = Array.from(
new Set([...ast.helpers.filter(h => h in ssrHelpers), ...context.helpers])
)
ast.helpers = ast.helpers.filter(h => !(h in ssrHelpers))
}

View File

@ -225,9 +225,8 @@ export function ssrProcessComponent(
export const rawOptionsMap = new WeakMap<RootNode, CompilerOptions>()
const [baseNodeTransforms, baseDirectiveTransforms] = getBaseTransformPreset(
true
)
const [baseNodeTransforms, baseDirectiveTransforms] =
getBaseTransformPreset(true)
const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms]
const vnodeDirectiveTransforms = {
...baseDirectiveTransforms,

View File

@ -24,9 +24,7 @@ declare namespace jest {
}
}
declare module '*.vue' {
}
declare module '*.vue' {}
declare module '*?raw' {
const content: string
export default content

View File

@ -422,7 +422,7 @@ describe('reactivity/collections', () => {
const proxy = reactive(raw)
const thisArg = {}
let count = 0
proxy.forEach(function(this: {}, value, _, set) {
proxy.forEach(function (this: {}, value, _, set) {
++count
expect(this).toBe(thisArg)
expect(value).toBe('value')

View File

@ -178,7 +178,10 @@ describe('reactivity/readonly', () => {
test('should make nested values readonly', () => {
const key1 = {}
const key2 = {}
const original = new Collection([[key1, {}], [key2, {}]])
const original = new Collection([
[key1, {}],
[key2, {}]
])
const wrapped = readonly(original)
expect(wrapped).not.toBe(original)
expect(isProxy(wrapped)).toBe(true)
@ -228,7 +231,10 @@ describe('reactivity/readonly', () => {
test('should retrieve readonly values on iteration', () => {
const key1 = {}
const key2 = {}
const original = new Map([[key1, {}], [key2, {}]])
const original = new Map([
[key1, {}],
[key2, {}]
])
const wrapped: any = readonly(original)
expect(wrapped.size).toBe(2)
for (const [key, value] of wrapped) {
@ -246,7 +252,12 @@ describe('reactivity/readonly', () => {
test('should retrieve reactive + readonly values on iteration', () => {
const key1 = {}
const key2 = {}
const original = reactive(new Map([[key1, {}], [key2, {}]]))
const original = reactive(
new Map([
[key1, {}],
[key2, {}]
])
)
const wrapped: any = readonly(original)
expect(wrapped.size).toBe(2)
for (const [key, value] of wrapped) {

View File

@ -49,7 +49,7 @@ function createArrayInstrumentations() {
// instrument identity-sensitive Array methods to account for possible reactive
// values
;(['includes', 'indexOf', 'lastIndexOf'] as const).forEach(key => {
instrumentations[key] = function(this: unknown[], ...args: unknown[]) {
instrumentations[key] = function (this: unknown[], ...args: unknown[]) {
const arr = toRaw(this) as any
for (let i = 0, l = this.length; i < l; i++) {
track(arr, TrackOpTypes.GET, i + '')
@ -67,7 +67,7 @@ function createArrayInstrumentations() {
// instrument length-altering mutation methods to avoid length being tracked
// which leads to infinite loops in some cases (#2137)
;(['push', 'pop', 'shift', 'unshift', 'splice'] as const).forEach(key => {
instrumentations[key] = function(this: unknown[], ...args: unknown[]) {
instrumentations[key] = function (this: unknown[], ...args: unknown[]) {
pauseTracking()
const res = (toRaw(this) as any)[key].apply(this, args)
resetTracking()

View File

@ -184,7 +184,7 @@ function createIterableMethod(
isReadonly: boolean,
isShallow: boolean
) {
return function(
return function (
this: IterableCollections,
...args: unknown[]
): Iterable & Iterator {
@ -224,7 +224,7 @@ function createIterableMethod(
}
function createReadonlyMethod(type: TriggerOpTypes): Function {
return function(this: CollectionTypes, ...args: unknown[]) {
return function (this: CollectionTypes, ...args: unknown[]) {
if (__DEV__) {
const key = args[0] ? `on key "${args[0]}" ` : ``
console.warn(
@ -242,7 +242,7 @@ function createInstrumentations() {
return get(this, key)
},
get size() {
return size((this as unknown) as IterableCollections)
return size(this as unknown as IterableCollections)
},
has,
add,
@ -257,7 +257,7 @@ function createInstrumentations() {
return get(this, key, false, true)
},
get size() {
return size((this as unknown) as IterableCollections)
return size(this as unknown as IterableCollections)
},
has,
add,
@ -272,7 +272,7 @@ function createInstrumentations() {
return get(this, key, true)
},
get size() {
return size((this as unknown) as IterableCollections, true)
return size(this as unknown as IterableCollections, true)
},
has(this: MapTypes, key: unknown) {
return has.call(this, key, true)
@ -289,7 +289,7 @@ function createInstrumentations() {
return get(this, key, true, true)
},
get size() {
return size((this as unknown) as IterableCollections, true)
return size(this as unknown as IterableCollections, true)
},
has(this: MapTypes, key: unknown) {
return has.call(this, key, true)
@ -384,11 +384,10 @@ export const readonlyCollectionHandlers: ProxyHandler<CollectionTypes> = {
get: /*#__PURE__*/ createInstrumentationGetter(true, false)
}
export const shallowReadonlyCollectionHandlers: ProxyHandler<
CollectionTypes
> = {
export const shallowReadonlyCollectionHandlers: ProxyHandler<CollectionTypes> =
{
get: /*#__PURE__*/ createInstrumentationGetter(true, true)
}
}
function checkIdentityKeys(
target: CollectionTypes,

View File

@ -37,7 +37,7 @@ class ComputedRefImpl<T> {
private _dirty = true
public readonly effect: ReactiveEffect<T>
public readonly __v_isRef = true;
public readonly __v_isRef = true
public readonly [ReactiveFlags.IS_READONLY]: boolean
constructor(

View File

@ -259,7 +259,9 @@ export type ShallowUnwrapRef<T> = {
[K in keyof T]: T[K] extends Ref<infer V>
? V
: T[K] extends Ref<infer V> | undefined // if `V` is `unknown` that means it does not extend `Ref` and is undefined
? unknown extends V ? undefined : V | undefined
? unknown extends V
? undefined
: V | undefined
: T[K]
}
@ -276,7 +278,9 @@ type UnwrapRefSimple<T> = T extends
? T
: T extends Array<any>
? { [K in keyof T]: UnwrapRefSimple<T[K]> }
: T extends object ? UnwrappedObject<T> : T
: T extends object
? UnwrappedObject<T>
: T
// Extract all known symbols from an object
// when unwrapping Object the symbols are not `in keyof`, this should cover all the

View File

@ -123,7 +123,8 @@ describe('SFC <script setup> helpers', () => {
beforeInstance = getCurrentInstance()
const msg = (([__temp, __restore] = withAsyncContext(
const msg =
(([__temp, __restore] = withAsyncContext(
() =>
new Promise(r => {
resolve = r
@ -141,7 +142,10 @@ describe('SFC <script setup> helpers', () => {
})
const root = nodeOps.createElement('div')
render(h(() => h(Suspense, () => h(Comp))), root)
render(
h(() => h(Suspense, () => h(Comp))),
root
)
expect(spy).not.toHaveBeenCalled()
resolve!('hello')
@ -186,7 +190,10 @@ describe('SFC <script setup> helpers', () => {
})
const root = nodeOps.createElement('div')
render(h(() => h(Suspense, () => h(Comp))), root)
render(
h(() => h(Suspense, () => h(Comp))),
root
)
expect(spy).not.toHaveBeenCalled()
reject!()
@ -242,7 +249,10 @@ describe('SFC <script setup> helpers', () => {
})
const root = nodeOps.createElement('div')
render(h(() => h(Suspense, () => h(Comp))), root)
render(
h(() => h(Suspense, () => h(Comp))),
root
)
await ready
expect(inBandInstance).toBe(beforeInstance)

View File

@ -115,8 +115,8 @@ describe('api: template refs', () => {
const fn = jest.fn()
const toggle = ref(true)
const Comp = defineComponent(() => () =>
toggle.value ? h('div', { ref: fn }) : null
const Comp = defineComponent(
() => () => toggle.value ? h('div', { ref: fn }) : null
)
render(h(Comp), root)
expect(fn.mock.calls[0][0]).toBe(root.children[0])

View File

@ -168,7 +168,10 @@ describe('api: watch', () => {
state.count++
count.value++
await nextTick()
expect(dummy).toMatchObject([[2, 2, 3], [1, 1, 2]])
expect(dummy).toMatchObject([
[2, 2, 3],
[1, 1, 2]
])
})
it('watching multiple sources: readonly array', async () => {
@ -188,7 +191,10 @@ describe('api: watch', () => {
state.count++
status.value = true
await nextTick()
expect(dummy).toMatchObject([[2, true], [1, false]])
expect(dummy).toMatchObject([
[2, true],
[1, false]
])
})
it('watching multiple sources: reactive object (with automatic deep: true)', async () => {
@ -568,7 +574,10 @@ describe('api: watch', () => {
count: ref(0)
},
array: [1, 2, 3],
map: new Map([['a', 1], ['b', 2]]),
map: new Map([
['a', 1],
['b', 2]
]),
set: new Set([1, 2, 3])
})
@ -868,7 +877,10 @@ describe('api: watch', () => {
mounted() {
// this call runs while Comp is currentInstance, but
// the effect for this `$watch` should nontheless be registered with Child
this.comp!.$watch(() => this.show, () => void 0)
this.comp!.$watch(
() => this.show,
() => void 0
)
}
})
@ -895,7 +907,7 @@ describe('api: watch', () => {
render() {},
created(this: any) {
instance = this
this.$watch(source, function() {})
this.$watch(source, function () {})
}
})

View File

@ -97,7 +97,7 @@ describe('component: proxy', () => {
expect(() => (instanceProxy.$data = {})).toThrow(TypeError)
expect(`Attempting to mutate public property "$data"`).toHaveBeenWarned()
const nextTickThis = await instanceProxy.$nextTick(function(this: any) {
const nextTickThis = await instanceProxy.$nextTick(function (this: any) {
return this
})
expect(nextTickThis).toBe(instanceProxy)

View File

@ -258,9 +258,8 @@ describe('BaseTransition', () => {
) {
const toggle = ref(true)
const { props, cbs } = mockProps({ mode })
const root = mount(
props,
() => (toggle.value ? trueBranch() : falseBranch())
const root = mount(props, () =>
toggle.value ? trueBranch() : falseBranch()
)
// without appear: true, enter hooks should not be called on mount
@ -348,9 +347,8 @@ describe('BaseTransition', () => {
}: ToggleOptions) {
const toggle = ref(false)
const { props, cbs } = mockProps()
const root = mount(
props,
() => (toggle.value ? trueBranch() : falseBranch())
const root = mount(props, () =>
toggle.value ? trueBranch() : falseBranch()
)
// start enter

View File

@ -841,10 +841,8 @@ describe('KeepAlive', () => {
const instanceRef = ref<any>(null)
const App = {
render: () => {
return h(
KeepAlive,
{ include: 'Foo' },
() => (toggle.value ? h(AsyncComp, { ref: instanceRef }) : null)
return h(KeepAlive, { include: 'Foo' }, () =>
toggle.value ? h(AsyncComp, { ref: instanceRef }) : null
)
}
}

View File

@ -106,7 +106,10 @@ describe('renderer: teleport', () => {
const root = nodeOps.createElement('div')
const children = ref([h('div', 'teleported')])
render(h(() => h(Teleport, { to: target }, children.value)), root)
render(
h(() => h(Teleport, { to: target }, children.value)),
root
)
expect(serializeInner(target)).toMatchInlineSnapshot(
`"<div>teleported</div>"`
)

View File

@ -42,7 +42,10 @@ describe('createSlot', () => {
it('should add each slot to the record when given slot is an array', () => {
const dynamicSlot = [
{ name: 'descriptor', fn: slot },
[{ name: 'descriptor2', fn: slot }, { name: 'descriptor3', fn: slot }]
[
{ name: 'descriptor2', fn: slot },
{ name: 'descriptor3', fn: slot }
]
]
const actual = createSlots(record, dynamicSlot)

View File

@ -38,7 +38,7 @@ describe('renderList', () => {
})
it('should render an item for entry in an iterable', () => {
const iterable = function*() {
const iterable = function* () {
yield 1
yield 2
yield 3

View File

@ -759,9 +759,11 @@ describe('SSR hydration', () => {
})
expect(
(app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
(
app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
el: Element
}).el instanceof SVGElement
}
).el instanceof SVGElement
)
})

View File

@ -321,21 +321,28 @@ describe('renderer: keyed children', () => {
}
for (let n = 0; n < samples; ++n) {
render(h('span', arr.map(n => spanNumWithOpacity(n, '1'))), root)
render(
h(
'span',
arr.map(n => spanNumWithOpacity(n, '1'))
),
root
)
elm = root.children[0] as TestElement
for (let i = 0; i < elms; ++i) {
expect(serializeInner(elm.children[i] as TestElement)).toBe(
i.toString()
)
opacities[i] = Math.random()
.toFixed(5)
.toString()
opacities[i] = Math.random().toFixed(5).toString()
}
const shufArr = shuffle(arr.slice(0))
render(
h('span', arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))),
h(
'span',
arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))
),
root
)
elm = root.children[0] as TestElement

View File

@ -217,7 +217,10 @@ describe('renderer: component', () => {
const Child = {
props: ['value'],
setup(props: any, { emit }: SetupContext) {
watch(() => props.value, (val: number) => emit('update', val))
watch(
() => props.value,
(val: number) => emit('update', val)
)
return () => {
return h('div', props.value)

View File

@ -417,7 +417,8 @@ describe('renderer: optimized mode', () => {
const Comp = defineComponent({
setup(_props, { slots }) {
return () => {
const vnode = (openBlock(),
const vnode =
(openBlock(),
(block = createBlock('div', null, {
default: withCtx(() => [renderSlot(slots, 'default')]),
_: SlotFlags.FORWARDED
@ -449,8 +450,9 @@ describe('renderer: optimized mode', () => {
expect(block!.dynamicChildren![0].type).toBe(Fragment)
expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(1)
expect(
serialize(block!.dynamicChildren![0].dynamicChildren![0]
.el as TestElement)
serialize(
block!.dynamicChildren![0].dynamicChildren![0].el as TestElement
)
).toBe('<p>0</p>')
foo.value++

View File

@ -226,7 +226,7 @@ describe('backwards compat with <=3.0.7', () => {
test('should work on slots', () => {
const Child = {
__scopeId: 'child',
render: withChildId(function(this: any) {
render: withChildId(function (this: any) {
return h('div', renderSlot(this.$slots, 'default'))
})
}

View File

@ -411,9 +411,9 @@ describe('vnode', () => {
})
test('handlers', () => {
let clickHandler1 = function() {}
let clickHandler2 = function() {}
let focusHandler2 = function() {}
let clickHandler1 = function () {}
let clickHandler2 = function () {}
let focusHandler2 = function () {}
let props1: Data = { onClick: clickHandler1 }
let props2: Data = { onClick: clickHandler2, onFocus: focusHandler2 }
@ -439,7 +439,8 @@ describe('vnode', () => {
test('with patchFlags', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
@ -449,7 +450,8 @@ describe('vnode', () => {
test('should not track vnodes with only HYDRATE_EVENTS flag', () => {
const hoist = createVNode('div')
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
createVNode('div', null, 'text', PatchFlags.HYDRATE_EVENTS)
@ -460,11 +462,13 @@ describe('vnode', () => {
test('many times call openBlock', () => {
const hoist = createVNode('div')
let vnode1, vnode2, vnode3
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
(vnode2 = (openBlock(),
(vnode2 =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
@ -477,7 +481,8 @@ describe('vnode', () => {
test('with stateful component', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode({}, null, 'text'))
@ -488,7 +493,8 @@ describe('vnode', () => {
test('with functional component', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
@ -499,7 +505,8 @@ describe('vnode', () => {
test('with suspense', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
hoist,
(vnode1 = createVNode(() => {}, null, 'text'))
@ -516,7 +523,8 @@ describe('vnode', () => {
test('element block should track normalized slot children', () => {
const hoist = createVNode('div')
let vnode1: any
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, {
default: () => {
return [
@ -531,12 +539,14 @@ describe('vnode', () => {
test('openBlock w/ disableTracking: true', () => {
const hoist = createVNode('div')
let vnode1
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
// a v-for fragment block generated by the compiler
// disables tracking because it always diffs its
// children.
(vnode1 = (openBlock(true),
(vnode1 =
(openBlock(true),
createBlock(Fragment, null, [
hoist,
/*vnode2*/ createVNode(() => {}, null, 'text')
@ -549,9 +559,11 @@ describe('vnode', () => {
test('openBlock without disableTracking: true', () => {
const hoist = createVNode('div')
let vnode1, vnode2
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
(vnode1 = (openBlock(),
(vnode1 =
(openBlock(),
createBlock(Fragment, null, [
hoist,
(vnode2 = createVNode(() => {}, null, 'text'))
@ -563,7 +575,8 @@ describe('vnode', () => {
test('should not track openBlock() when tracking is disabled', () => {
let vnode1
const vnode = (openBlock(),
const vnode =
(openBlock(),
createBlock('div', null, [
setBlockTracking(-1),
(vnode1 = (openBlock(), createBlock('div'))),

View File

@ -71,7 +71,8 @@ export function defineAsyncComponent<
let thisRequest: Promise<ConcreteComponent>
return (
pendingRequest ||
(thisRequest = pendingRequest = loader()
(thisRequest = pendingRequest =
loader()
.catch(err => {
err = err instanceof Error ? err : new Error(String(err))
if (userOnError) {

View File

@ -133,7 +133,7 @@ export interface AppContext {
type PluginInstallFunction = (app: App, ...options: any[]) => any
export type Plugin =
| PluginInstallFunction & { install?: PluginInstallFunction }
| (PluginInstallFunction & { install?: PluginInstallFunction })
| {
install: PluginInstallFunction
}

View File

@ -63,9 +63,9 @@ export function injectHook(
}
}
export const createHook = <T extends Function = () => any>(
lifecycle: LifecycleHooks
) => (hook: T, target: ComponentInternalInstance | null = currentInstance) =>
export const createHook =
<T extends Function = () => any>(lifecycle: LifecycleHooks) =>
(hook: T, target: ComponentInternalInstance | null = currentInstance) =>
// post-create lifecycle registrations are noops during SSR (except for serverPrefetch)
(!isInSSRComponentSetup || lifecycle === LifecycleHooks.SERVER_PREFETCH) &&
injectHook(lifecycle, hook, target)

View File

@ -130,12 +130,12 @@ export function defineExpose(exposed?: Record<string, any>) {
type NotUndefined<T> = T extends undefined ? never : T
type InferDefaults<T> = {
[K in keyof T]?: NotUndefined<T[K]> extends (
[K in keyof T]?: NotUndefined<T[K]> extends
| number
| string
| boolean
| symbol
| Function)
| Function
? NotUndefined<T[K]>
: (props: T) => NotUndefined<T[K]>
}

View File

@ -50,9 +50,13 @@ export type WatchCallback<V = any, OV = any> = (
type MapSources<T, Immediate> = {
[K in keyof T]: T[K] extends WatchSource<infer V>
? Immediate extends true ? (V | undefined) : V
? Immediate extends true
? V | undefined
: V
: T[K] extends object
? Immediate extends true ? (T[K] | undefined) : T[K]
? Immediate extends true
? T[K] | undefined
: T[K]
: never
}
@ -81,9 +85,13 @@ export function watchPostEffect(
effect: WatchEffect,
options?: DebuggerOptions
) {
return doWatch(effect, null, (__DEV__
return doWatch(
effect,
null,
(__DEV__
? Object.assign(options || {}, { flush: 'post' })
: { flush: 'post' }) as WatchOptionsBase)
: { flush: 'post' }) as WatchOptionsBase
)
}
// initial value for watchers to trigger on undefined initial values
@ -116,7 +124,7 @@ export function watch<
// overload: single source + cb
export function watch<T, Immediate extends Readonly<boolean> = false>(
source: WatchSource<T>,
cb: WatchCallback<T, Immediate extends true ? (T | undefined) : T>,
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
options?: WatchOptions<Immediate>
): WatchStopHandle
@ -126,7 +134,7 @@ export function watch<
Immediate extends Readonly<boolean> = false
>(
source: T,
cb: WatchCallback<T, Immediate extends true ? (T | undefined) : T>,
cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
options?: WatchOptions<Immediate>
): WatchStopHandle

View File

@ -238,8 +238,9 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
[DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE]: {
message: componentName =>
`Component <${componentName ||
'Anonymous'}> has \`inheritAttrs: false\` but is ` +
`Component <${
componentName || 'Anonymous'
}> has \`inheritAttrs: false\` but is ` +
`relying on class/style fallthrough from parent. In Vue 3, class/style ` +
`are now included in $attrs and will no longer fallthrough when ` +
`inheritAttrs is false. If you are already using v-bind="$attrs" on ` +
@ -317,9 +318,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`${name}="false" instead of removing it in Vue 3. To remove the attribute, ` +
`use \`null\` or \`undefined\` instead. If the usage is intended, ` +
`you can disable the compat behavior and suppress this warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.ATTR_FALSE_VALUE
}: false })\n`,
`\n\n configureCompat({ ${DeprecationTypes.ATTR_FALSE_VALUE}: false })\n`,
link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
},
@ -332,9 +331,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`Always use explicit "true" or "false" values for enumerated attributes. ` +
`If the usage is intended, ` +
`you can disable the compat behavior and suppress this warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.ATTR_ENUMERATED_COERCION
}: false })\n`,
`\n\n configureCompat({ ${DeprecationTypes.ATTR_ENUMERATED_COERCION}: false })\n`,
link: `https://v3.vuejs.org/guide/migration/attribute-coercion.html`
},
@ -348,9 +345,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`default if no "tag" prop is specified. If you do not rely on the span ` +
`for styling, you can disable the compat behavior and suppress this ` +
`warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.TRANSITION_GROUP_ROOT
}: false })\n`,
`\n\n configureCompat({ ${DeprecationTypes.TRANSITION_GROUP_ROOT}: false })\n`,
link: `https://v3.vuejs.org/guide/migration/transition-group.html`
},
@ -366,9 +361,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
`usage and intend to use plain functions for functional components, ` +
`you can disable the compat behavior and suppress this ` +
`warning with:` +
`\n\n configureCompat({ ${
DeprecationTypes.COMPONENT_ASYNC
}: false })\n`
`\n\n configureCompat({ ${DeprecationTypes.COMPONENT_ASYNC}: false })\n`
)
},
link: `https://v3.vuejs.org/guide/migration/async-components.html`
@ -394,9 +387,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
message: (comp: ComponentOptions) => {
const configMsg =
`opt-in to ` +
`Vue 3 behavior on a per-component basis with \`compatConfig: { ${
DeprecationTypes.COMPONENT_V_MODEL
}: false }\`.`
`Vue 3 behavior on a per-component basis with \`compatConfig: { ${DeprecationTypes.COMPONENT_V_MODEL}: false }\`.`
if (
comp.props &&
(isArray(comp.props)
@ -421,9 +412,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
message:
`Vue 3's render function API has changed. ` +
`You can opt-in to the new API with:` +
`\n\n configureCompat({ ${
DeprecationTypes.RENDER_FUNCTION
}: false })\n` +
`\n\n configureCompat({ ${DeprecationTypes.RENDER_FUNCTION}: false })\n` +
`\n (This can also be done per-component via the "compatConfig" option.)`,
link: `https://v3.vuejs.org/guide/migration/render-function-api.html`
},
@ -565,9 +554,7 @@ export function validateCompatConfig(
if (instance && config[DeprecationTypes.OPTIONS_DATA_MERGE] != null) {
warn(
`Deprecation config "${
DeprecationTypes.OPTIONS_DATA_MERGE
}" can only be configured globally.`
`Deprecation config "${DeprecationTypes.OPTIONS_DATA_MERGE}" can only be configured globally.`
)
}
}

View File

@ -177,7 +177,7 @@ const skipLegacyRootLevelProps = /*#__PURE__*/ makeMap(
function convertLegacyProps(
legacyProps: LegacyVNodeProps | undefined,
type: any
): Data & VNodeProps | null {
): (Data & VNodeProps) | null {
if (!legacyProps) {
return null
}

View File

@ -51,7 +51,7 @@ export function legacyBindObjectProps(
if (isSync) {
const on = data.on || (data.on = {})
on[`update:${key}`] = function($event: any) {
on[`update:${key}`] = function ($event: any) {
value[key] = $event
}
}

View File

@ -761,10 +761,8 @@ export function finishComponentSetup(
startMeasure(instance, `compile`)
}
const { isCustomElement, compilerOptions } = instance.appContext.config
const {
delimiters,
compilerOptions: componentCompilerOptions
} = Component
const { delimiters, compilerOptions: componentCompilerOptions } =
Component
const finalCompilerOptions: CompilerOptions = extend(
extend(
{

View File

@ -77,7 +77,9 @@ type RequiredKeys<T> = {
// don't mark Boolean props as undefined
| BooleanConstructor
| { type: BooleanConstructor }
? T[K] extends { default: undefined | (() => undefined) } ? never : K
? T[K] extends { default: undefined | (() => undefined) }
? never
: K
: never
}[keyof T]
@ -106,7 +108,9 @@ type InferPropType<T> = [T] extends [null]
: [T] extends [DateConstructor | { type: DateConstructor }]
? Date
: [T] extends [Prop<infer V, infer D>]
? (unknown extends V ? D : V)
? unknown extends V
? D
: V
: T
export type ExtractPropTypes<O> = O extends object

View File

@ -72,7 +72,9 @@ import { installCompatInstanceProperties } from './compat/instance'
export interface ComponentCustomProperties {}
type IsDefaultMixinComponent<T> = T extends ComponentOptionsMixin
? ComponentOptionsMixin extends T ? true : false
? ComponentOptionsMixin extends T
? true
: false
: false
type MixinToOptionTypes<T> = T extends ComponentOptionsBase<
@ -261,15 +263,8 @@ export interface ComponentRenderContext {
export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
get({ _: instance }: ComponentRenderContext, key: string) {
const {
ctx,
setupState,
data,
props,
accessCache,
type,
appContext
} = instance
const { ctx, setupState, data, props, accessCache, type, appContext } =
instance
// for internal formatters to know that this is a Vue instance
if (__DEV__ && key === '__isVue') {

View File

@ -257,7 +257,7 @@ if (__COMPAT__) {
// export the public type for h/tsx inference
// also to avoid inline import() in generated d.ts files
export const BaseTransition = (BaseTransitionImpl as any) as {
export const BaseTransition = BaseTransitionImpl as any as {
new (): {
$props: BaseTransitionProps<any>
}

View File

@ -329,7 +329,7 @@ if (__COMPAT__) {
// export the public type for h/tsx inference
// also to avoid inline import() in generated d.ts files
export const KeepAlive = (KeepAliveImpl as any) as {
export const KeepAlive = KeepAliveImpl as any as {
__isKeepAlive: true
new (): {
$props: VNodeProps & KeepAliveProps

View File

@ -87,9 +87,7 @@ export const SuspenseImpl = {
}
// Force-casted public typing for h and TSX props inference
export const Suspense = ((__FEATURE_SUSPENSE__
? SuspenseImpl
: null) as any) as {
export const Suspense = (__FEATURE_SUSPENSE__ ? SuspenseImpl : null) as any as {
__isSuspense: true
new (): { $props: VNodeProps & SuspenseProps }
}
@ -520,13 +518,8 @@ function createSuspenseBoundary(
return
}
const {
vnode,
activeBranch,
parentComponent,
container,
isSVG
} = suspense
const { vnode, activeBranch, parentComponent, container, isSVG } =
suspense
// invoke @fallback event
triggerEvent(vnode, 'onFallback')

View File

@ -371,7 +371,7 @@ function hydrateTeleport(
}
// Force-casted public typing for h and TSX props inference
export const Teleport = (TeleportImpl as any) as {
export const Teleport = TeleportImpl as any as {
__isTeleport: true
new (): { $props: VNodeProps & TeleportProps }
}

View File

@ -54,13 +54,11 @@ export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook(
DevtoolsHooks.COMPONENT_ADDED
)
export const devtoolsComponentUpdated = /*#__PURE__*/ createDevtoolsComponentHook(
DevtoolsHooks.COMPONENT_UPDATED
)
export const devtoolsComponentUpdated =
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_UPDATED)
export const devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
DevtoolsHooks.COMPONENT_REMOVED
)
export const devtoolsComponentRemoved =
/*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_REMOVED)
function createDevtoolsComponentHook(hook: DevtoolsHooks) {
return (component: ComponentInternalInstance) => {

View File

@ -15,7 +15,8 @@ export function createSlots(
dynamicSlots: (
| CompiledSlotDescriptor
| CompiledSlotDescriptor[]
| undefined)[]
| undefined
)[]
): Record<string, Slot> {
for (let i = 0; i < dynamicSlots.length; i++) {
const slot = dynamicSlots[i]

View File

@ -1,6 +1,6 @@
export type UnionToIntersection<U> = (U extends any
? (k: U) => void
: never) extends ((k: infer I) => void)
export type UnionToIntersection<U> = (
U extends any ? (k: U) => void : never
) extends (k: infer I) => void
? I
: never

View File

@ -280,8 +280,8 @@ export function createHydrationFunctions(
if (
forcePatchValue ||
!optimized ||
(patchFlag & PatchFlags.FULL_PROPS ||
patchFlag & PatchFlags.HYDRATE_EVENTS)
patchFlag & PatchFlags.FULL_PROPS ||
patchFlag & PatchFlags.HYDRATE_EVENTS
) {
for (const key in props) {
if (
@ -346,7 +346,9 @@ export function createHydrationFunctions(
hasMismatch = true
__DEV__ &&
warn(
`Hydration text content mismatch in <${vnode.type as string}>:\n` +
`Hydration text content mismatch in <${
vnode.type as string
}>:\n` +
`- Client: ${el.textContent}\n` +
`- Server: ${vnode.children as string}`
)

View File

@ -341,9 +341,9 @@ const _compatUtils = {
/**
* @internal only exposed in compat builds.
*/
export const compatUtils = (__COMPAT__
? _compatUtils
: null) as typeof _compatUtils
export const compatUtils = (
__COMPAT__ ? _compatUtils : null
) as typeof _compatUtils
// Ref macros ------------------------------------------------------------------
// for dts generation only

View File

@ -1444,7 +1444,7 @@ function baseCreateRenderer(
}
if (isAsyncWrapper(initialVNode)) {
(initialVNode.type as ComponentOptions).__asyncLoader!().then(
;(initialVNode.type as ComponentOptions).__asyncLoader!().then(
// note: we are moving the render call into an async callback,
// which means it won't track dependencies - but it's ok because
// a server-rendered async wrapper is already in resolved state
@ -2406,10 +2406,9 @@ function baseCreateRenderer(
let hydrate: ReturnType<typeof createHydrationFunctions>[0] | undefined
let hydrateNode: ReturnType<typeof createHydrationFunctions>[1] | undefined
if (createHydrationFns) {
;[hydrate, hydrateNode] = createHydrationFns(internals as RendererInternals<
Node,
Element
>)
;[hydrate, hydrateNode] = createHydrationFns(
internals as RendererInternals<Node, Element>
)
}
return {

View File

@ -44,7 +44,7 @@ import { convertLegacyVModelProps } from './compat/componentVModel'
import { defineLegacyVNodeProperties } from './compat/renderFn'
import { convertLegacyRefInFor } from './compat/ref'
export const Fragment = (Symbol(__DEV__ ? 'Fragment' : undefined) as any) as {
export const Fragment = Symbol(__DEV__ ? 'Fragment' : undefined) as any as {
__isFragment: true
new (): {
$props: VNodeProps
@ -78,7 +78,7 @@ export type VNodeNormalizedRefAtom = {
export type VNodeNormalizedRef =
| VNodeNormalizedRefAtom
| (VNodeNormalizedRefAtom)[]
| VNodeNormalizedRefAtom[]
type VNodeMountHook = (vnode: VNode) => void
type VNodeUpdateHook = (vnode: VNode, oldVNode: VNode) => void
@ -381,11 +381,13 @@ const normalizeKey = ({ key }: VNodeProps): VNode['key'] =>
key != null ? key : null
const normalizeRef = ({ ref }: VNodeProps): VNodeNormalizedRefAtom | null => {
return (ref != null
return (
ref != null
? isString(ref) || isRef(ref) || isFunction(ref)
? { i: currentRenderingInstance, r: ref }
: ref
: null) as any
: null
) as any
}
function createBaseVNode(
@ -475,9 +477,9 @@ function createBaseVNode(
export { createBaseVNode as createElementVNode }
export const createVNode = (__DEV__
? createVNodeWithArgsTransform
: _createVNode) as typeof _createVNode
export const createVNode = (
__DEV__ ? createVNodeWithArgsTransform : _createVNode
) as typeof _createVNode
function _createVNode(
type: VNodeTypes | ClassComponent | typeof NULL_DYNAMIC_COMPONENT,
@ -579,7 +581,7 @@ export function guardReactiveProps(props: (Data & VNodeProps) | null) {
export function cloneVNode<T, U>(
vnode: VNode<T, U>,
extraProps?: Data & VNodeProps | null,
extraProps?: (Data & VNodeProps) | null,
mergeRef = false
): VNode<T, U> {
// This is intentionally NOT using spread or extend to avoid the runtime

View File

@ -17,7 +17,7 @@ const triggerEvent = (type: string, el: Element) => {
const withVModel = (node: VNode, arg: any, mods?: any) =>
withDirectives(node, [[vModelDynamic, arg, '', mods]])
const setValue = function(this: any, value: any) {
const setValue = function (this: any, value: any) {
this.value = value
}

View File

@ -41,9 +41,9 @@ describe('runtime-dom: v-on directive', () => {
})
test('it should support key modifiers and system modifiers', () => {
const keyNames = ["ctrl","shift","meta","alt"]
const keyNames = ['ctrl', 'shift', 'meta', 'alt']
keyNames.forEach(keyName=>{
keyNames.forEach(keyName => {
const el = document.createElement('div')
const fn = jest.fn()
// <div @keyup[keyName].esc="test"/>
@ -73,7 +73,7 @@ describe('runtime-dom: v-on directive', () => {
e.key = 'ArrowLeft'
})
expect(fn).toBeCalledTimes(2)
});
})
})
test('it should support "exact" modifier', () => {
@ -114,7 +114,9 @@ describe('runtime-dom: v-on directive', () => {
const fn = jest.fn()
const handler = withModifiers(fn, [button])
patchEvent(el, 'onMousedown', null, handler, null)
buttons.filter(b => b !== button).forEach(button => {
buttons
.filter(b => b !== button)
.forEach(button => {
triggerEvent(el, 'mousedown', e => (e.button = buttonCodes[button]))
})
expect(fn).not.toBeCalled()

View File

@ -155,10 +155,8 @@ describe('useCssVars', () => {
setup() {
useCssVars(() => state)
return () =>
h(
Child,
null,
() => (value.value ? [h('div')] : [h('div'), h('div')])
h(Child, null, () =>
value.value ? [h('div')] : [h('div'), h('div')]
)
}
}

View File

@ -157,9 +157,9 @@ export const defineSSRCustomElement = ((options: any) => {
return defineCustomElement(options, hydrate)
}) as typeof defineCustomElement
const BaseClass = (typeof HTMLElement !== 'undefined'
? HTMLElement
: class {}) as typeof HTMLElement
const BaseClass = (
typeof HTMLElement !== 'undefined' ? HTMLElement : class {}
) as typeof HTMLElement
export class VueElement extends BaseClass {
/**

View File

@ -69,11 +69,12 @@ const DOMTransitionPropsValidators = {
leaveToClass: String
}
export const TransitionPropsValidators = (Transition.props = /*#__PURE__*/ extend(
export const TransitionPropsValidators = (Transition.props =
/*#__PURE__*/ extend(
{},
(BaseTransition as any).props,
DOMTransitionPropsValidators
))
))
/**
* #3227 Incoming hooks may be merged into arrays when wrapping Transition

View File

@ -159,7 +159,7 @@ if (__COMPAT__) {
const removeMode = (props: any) => delete props.mode
/*#__PURE__*/ removeMode(TransitionGroupImpl.props)
export const TransitionGroup = (TransitionGroupImpl as unknown) as {
export const TransitionGroup = TransitionGroupImpl as unknown as {
new (): {
$props: TransitionGroupProps
}
@ -210,9 +210,9 @@ function hasCSSTransform(
}
moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c))
clone.style.display = 'none'
const container = (root.nodeType === 1
? root
: root.parentNode) as HTMLElement
const container = (
root.nodeType === 1 ? root : root.parentNode
) as HTMLElement
container.appendChild(clone)
const { hasTransform } = getTransitionInfo(clone)
container.removeChild(clone)

View File

@ -181,8 +181,7 @@ export const vModelSelect: ModelDirective<HTMLSelectElement> = {
addEventListener(el, 'change', () => {
const selectedVal = Array.prototype.filter
.call(el.options, (o: HTMLOptionElement) => o.selected)
.map(
(o: HTMLOptionElement) =>
.map((o: HTMLOptionElement) =>
number ? toNumber(getValue(o)) : getValue(o)
)
el._assign(

View File

@ -66,7 +66,7 @@ export const withKeys = (fn: Function, modifiers: string[]) => {
compatUtils.isCompatEnabled(DeprecationTypes.CONFIG_KEY_CODES, instance)
) {
if (instance) {
globalKeyCodes = ((instance.appContext.config as any) as LegacyConfig)
globalKeyCodes = (instance.appContext.config as any as LegacyConfig)
.keyCodes
}
}

View File

@ -8,9 +8,8 @@ export function patchClass(el: Element, value: string | null, isSVG: boolean) {
// classes into account.
const transitionClasses = (el as ElementWithTransition)._vtc
if (transitionClasses) {
value = (value
? [value, ...transitionClasses]
: [...transitionClasses]
value = (
value ? [value, ...transitionClasses] : [...transitionClasses]
).join(' ')
}
if (value == null) {

View File

@ -721,7 +721,7 @@ function testRender(type: string, render: typeof renderToString) {
test('with client-compiled vnode slots', async () => {
const Child = {
__scopeId: 'data-v-child',
render: function(this: any) {
render: function (this: any) {
return h('div', null, [renderSlot(this.$slots, 'default')])
}
}
@ -1069,7 +1069,7 @@ function testRender(type: string, render: typeof renderToString) {
renderError = e
}
expect(renderError).toBe(null)
expect(((capturedError as unknown) as Error).message).toBe('An error')
expect((capturedError as unknown as Error).message).toBe('An error')
})
})
}

View File

@ -43,7 +43,7 @@ describe('ssr: renderList', () => {
})
it('should render an item for entry in an iterable', () => {
const iterable = function*() {
const iterable = function* () {
yield 1
yield 2
yield 3

View File

@ -26,9 +26,7 @@ export function ssrCompile(
isNativeTag: instance.appContext.config.isNativeTag || NO,
onError(err: CompilerError) {
if (__DEV__) {
const message = `[@vue/server-renderer] Template compilation error: ${
err.message
}`
const message = `[@vue/server-renderer] Template compilation error: ${err.message}`
const codeFrame =
err.loc &&
generateCodeFrame(

View File

@ -17,9 +17,7 @@ export function ssrRenderDynamicModel(
case 'radio':
return looseEqual(model, value) ? ' checked' : ''
case 'checkbox':
return (isArray(model)
? ssrLooseContain(model, value)
: model)
return (isArray(model) ? ssrLooseContain(model, value) : model)
? ' checked'
: ''
default:
@ -38,9 +36,7 @@ export function ssrGetDynamicModelProps(
case 'radio':
return looseEqual(model, value) ? { checked: true } : null
case 'checkbox':
return (isArray(model)
? ssrLooseContain(model, value)
: model)
return (isArray(model) ? ssrLooseContain(model, value) : model)
? { checked: true }
: null
default:

View File

@ -74,9 +74,9 @@ async function resolveTeleports(context: SSRContext) {
for (const key in context.__teleportBuffers) {
// note: it's OK to await sequentially here because the Promises were
// created eagerly in parallel.
context.teleports[key] = await unrollBuffer((await Promise.all(
context.__teleportBuffers[key]
)) as SSRBuffer)
context.teleports[key] = await unrollBuffer(
(await Promise.all(context.__teleportBuffers[key])) as SSRBuffer
)
}
}
}

View File

@ -217,12 +217,7 @@ async function doCompileScript(
return [code, compiledScript.bindings]
} catch (e) {
store.errors = [
e.stack
.split('\n')
.slice(0, 12)
.join('\n')
]
store.errors = [e.stack.split('\n').slice(0, 12).join('\n')]
return
}
} else {

View File

@ -54,27 +54,27 @@ describe('utils/looseEqual', () => {
const date2 = new Date(2019, 1, 2, 3, 4, 5, 7)
const file1 = new File([''], 'filename.txt', {
type: 'text/plain',
lastModified: date1.getTime(),
lastModified: date1.getTime()
})
const file2 = new File([''], 'filename.txt', {
type: 'text/plain',
lastModified: date1.getTime(),
lastModified: date1.getTime()
})
const file3 = new File([''], 'filename.txt', {
type: 'text/plain',
lastModified: date2.getTime(),
lastModified: date2.getTime()
})
const file4 = new File([''], 'filename.csv', {
type: 'text/csv',
lastModified: date1.getTime(),
lastModified: date1.getTime()
})
const file5 = new File(['abcdef'], 'filename.txt', {
type: 'text/plain',
lastModified: date1.getTime(),
lastModified: date1.getTime()
})
const file6 = new File(['12345'], 'filename.txt', {
type: 'text/plain',
lastModified: date1.getTime(),
lastModified: date1.getTime()
})
// Identical file object references
@ -163,7 +163,7 @@ describe('utils/looseEqual', () => {
const date1 = new Date(2019, 1, 2, 3, 4, 5, 6)
const file1 = new File([''], 'filename.txt', {
type: 'text/plain',
lastModified: date1.getTime(),
lastModified: date1.getTime()
})
expect(looseEqual(123, '123')).toBe(true)

View File

@ -6,7 +6,9 @@ describe('normalizeClass', () => {
})
test('handles array correctly', () => {
expect(normalizeClass(['foo', undefined, true, false, 'bar'])).toEqual('foo bar')
expect(normalizeClass(['foo', undefined, true, false, 'bar'])).toEqual(
'foo bar'
)
})
test('handles object correctly', () => {

View File

@ -113,11 +113,9 @@ const camelizeRE = /-(\w)/g
/**
* @private
*/
export const camelize = cacheStringFunction(
(str: string): string => {
export const camelize = cacheStringFunction((str: string): string => {
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''))
}
)
})
const hyphenateRE = /\B([A-Z])/g
/**
@ -137,8 +135,8 @@ export const capitalize = cacheStringFunction(
/**
* @private
*/
export const toHandlerKey = cacheStringFunction(
(str: string) => (str ? `on${capitalize(str)}` : ``)
export const toHandlerKey = cacheStringFunction((str: string) =>
str ? `on${capitalize(str)}` : ``
)
// compare whether a value has changed, accounting for NaN.

View File

@ -72,9 +72,7 @@ window.init = () => {
lastSuccessfulMap = new SourceMapConsumer(map!)
lastSuccessfulMap!.computeColumnSpans()
} catch (e) {
lastSuccessfulCode = `/* ERROR: ${
e.message
} (see console for more info) */`
lastSuccessfulCode = `/* ERROR: ${e.message} (see console for more info) */`
console.error(e)
}
return lastSuccessfulCode
@ -195,8 +193,10 @@ window.init = () => {
if (
pos.line != null &&
pos.column != null &&
!// ignore mock location
!(
// ignore mock location
(pos.line === 1 && pos.column === 0)
)
) {
const translatedPos = {
column: pos.column + 1,

View File

@ -48,8 +48,7 @@ const App = {
h(
'a',
{
href:
'https://app.netlify.com/sites/vue-next-template-explorer/deploys',
href: 'https://app.netlify.com/sites/vue-next-template-explorer/deploys',
target: `_blank`
},
'History'
@ -147,7 +146,9 @@ const App = {
checked: compilerOptions.hoistStatic && !isSSR,
disabled: isSSR,
onChange(e: Event) {
compilerOptions.hoistStatic = (e.target as HTMLInputElement).checked
compilerOptions.hoistStatic = (
e.target as HTMLInputElement
).checked
}
}),
h('label', { for: 'hoist' }, 'hoistStatic')
@ -161,7 +162,9 @@ const App = {
checked: usePrefix && compilerOptions.cacheHandlers && !isSSR,
disabled: !usePrefix || isSSR,
onChange(e: Event) {
compilerOptions.cacheHandlers = (e.target as HTMLInputElement).checked
compilerOptions.cacheHandlers = (
e.target as HTMLInputElement
).checked
}
}),
h('label', { for: 'cache' }, 'cacheHandlers')
@ -191,7 +194,9 @@ const App = {
id: 'inline',
checked: compilerOptions.inline,
onChange(e: Event) {
compilerOptions.inline = (e.target as HTMLInputElement).checked
compilerOptions.inline = (
e.target as HTMLInputElement
).checked
}
}),
h('label', { for: 'inline' }, 'inline')
@ -204,8 +209,9 @@ const App = {
id: 'compat',
checked: compilerOptions.compatConfig!.MODE === 2,
onChange(e: Event) {
compilerOptions.compatConfig!.MODE = (e.target as HTMLInputElement)
.checked
compilerOptions.compatConfig!.MODE = (
e.target as HTMLInputElement
).checked
? 2
: 3
}

View File

@ -55,7 +55,8 @@ test('COMPONENT_FUNCTIONAL', async () => {
)
expect(
(deprecationData[DeprecationTypes.COMPONENT_FUNCTIONAL]
.message as Function)(func)
(
deprecationData[DeprecationTypes.COMPONENT_FUNCTIONAL].message as Function
)(func)
).toHaveBeenWarned()
})

View File

@ -26,10 +26,7 @@ describe('FILTERS', () => {
}
function reverse(v: string) {
return v
.split('')
.reverse()
.join('')
return v.split('').reverse().join('')
}
function double(v: number) {

View File

@ -145,10 +145,10 @@ describe('GLOBAL_EXTEND', () => {
})
it('should not merge nested mixins created with Vue.extend', () => {
const a = jest.fn();
const b = jest.fn();
const c = jest.fn();
const d = jest.fn();
const a = jest.fn()
const b = jest.fn()
const c = jest.fn()
const d = jest.fn()
const A = Vue.extend({
created: a
})
@ -163,7 +163,9 @@ describe('GLOBAL_EXTEND', () => {
const D = Vue.extend({
mixins: [C],
created: d,
render() { return null },
render() {
return null
}
})
new D().$mount()
expect(a.mock.calls.length).toStrictEqual(1)
@ -255,7 +257,7 @@ describe('GLOBAL_PROTOTYPE', () => {
})
test('method this context', () => {
Vue.prototype.$test = function() {
Vue.prototype.$test = function () {
return this.msg
}
const vm = new Vue({

View File

@ -57,7 +57,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
})
it('$on', () => {
vm.$on('test', function(this: any) {
vm.$on('test', function (this: any) {
// expect correct context
expect(this).toBe(vm)
spy.apply(this, arguments)
@ -71,7 +71,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
})
it('$on multi event', () => {
vm.$on(['test1', 'test2'], function(this: any) {
vm.$on(['test1', 'test2'], function (this: any) {
expect(this).toBe(vm)
spy.apply(this, arguments)
})
@ -179,8 +179,10 @@ describe('INSTANCE_EVENT_HOOKS', () => {
vm.$mount()
expect(spy).toHaveBeenCalled()
expect(
(deprecationData[DeprecationTypes.INSTANCE_EVENT_HOOKS]
.message as Function)('hook:mounted')
(
deprecationData[DeprecationTypes.INSTANCE_EVENT_HOOKS]
.message as Function
)('hook:mounted')
).toHaveBeenWarned()
})
@ -197,8 +199,10 @@ describe('INSTANCE_EVENT_HOOKS', () => {
}).$mount()
expect(spy).toHaveBeenCalled()
expect(
(deprecationData[DeprecationTypes.INSTANCE_EVENT_HOOKS]
.message as Function)('hook:mounted')
(
deprecationData[DeprecationTypes.INSTANCE_EVENT_HOOKS]
.message as Function
)('hook:mounted')
).toHaveBeenWarned()
})
})
@ -319,7 +323,9 @@ test('INSTANCE_ATTR_CLASS_STYLE', () => {
)
expect(
(deprecationData[DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE]
.message as Function)('Anonymous')
(
deprecationData[DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE]
.message as Function
)('Anonymous')
).toHaveBeenWarned()
})

View File

@ -213,15 +213,21 @@ test('ATTR_ENUMERATED_COERCION', () => {
expect(vm.$el.getAttribute('spellcheck')).toBe('true')
expect(vm.$el.getAttribute('contenteditable')).toBe('true')
expect(
(deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function)('draggable', null, 'false')
(
deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function
)('draggable', null, 'false')
).toHaveBeenWarned()
expect(
(deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function)('spellcheck', 0, 'true')
(
deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function
)('spellcheck', 0, 'true')
).toHaveBeenWarned()
expect(
(deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function)('contenteditable', 'foo', 'true')
(
deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
.message as Function
)('contenteditable', 'foo', 'true')
).toHaveBeenWarned()
})

View File

@ -79,9 +79,9 @@ function compileToFunction(
// with keys that cannot be mangled, and can be quite heavy size-wise.
// In the global build we know `Vue` is available globally so we can avoid
// the wildcard object.
const render = (__GLOBAL__
? new Function(code)()
: new Function('Vue', code)(runtimeDom)) as RenderFunction
const render = (
__GLOBAL__ ? new Function(code)() : new Function('Vue', code)(runtimeDom)
) as RenderFunction
// mark the function as runtime compiled
;(render as InternalRenderFunction)._rc = true

View File

@ -3,15 +3,8 @@ import path from 'path'
import { h, createApp, Transition, ref, nextTick } from 'vue'
describe('e2e: Transition', () => {
const {
page,
html,
classList,
isVisible,
timeout,
nextFrame,
click
} = setupPuppeteer()
const { page, html, classList, isVisible, timeout, nextFrame, click } =
setupPuppeteer()
const baseUrl = `file://${path.resolve(__dirname, './transition.html')}`
const duration = process.env.CI ? 200 : 50
@ -21,7 +14,7 @@ describe('e2e: Transition', () => {
const classWhenTransitionStart = () =>
page().evaluate(() => {
(document.querySelector('#toggleBtn') as any)!.click()
;(document.querySelector('#toggleBtn') as any)!.click()
return Promise.resolve().then(() => {
return document.querySelector('#container div')!.className.split(/\s+/g)
})
@ -1066,7 +1059,7 @@ describe('e2e: Transition', () => {
// change view -> 'two'
await page().evaluate(() => {
(document.querySelector('#changeViewBtn') as any)!.click()
;(document.querySelector('#changeViewBtn') as any)!.click()
})
// enter
expect(await classWhenTransitionStart()).toStrictEqual([
@ -1085,7 +1078,7 @@ describe('e2e: Transition', () => {
// change view -> 'one'
await page().evaluate(() => {
(document.querySelector('#changeViewBtn') as any)!.click()
;(document.querySelector('#changeViewBtn') as any)!.click()
})
// leave
expect(await classWhenTransitionStart()).toStrictEqual([
@ -1172,7 +1165,7 @@ describe('e2e: Transition', () => {
// enter
const enterClass = await page().evaluate(async () => {
(document.querySelector('#toggleBtn') as any)!.click()
;(document.querySelector('#toggleBtn') as any)!.click()
// nextTrick for patch start
await Promise.resolve()
// nextTrick for Suspense resolve
@ -2001,10 +1994,8 @@ describe('e2e: Transition', () => {
const root = document.createElement('div')
createApp({
render() {
return h(
MyTransition,
{ onLeave: () => outerSpy() },
() => (toggle.value ? h('div') : null)
return h(MyTransition, { onLeave: () => outerSpy() }, () =>
toggle.value ? h('div') : null
)
}
}).mount(root)

View File

@ -11,7 +11,7 @@ describe('e2e: TransitionGroup', () => {
const htmlWhenTransitionStart = () =>
page().evaluate(() => {
(document.querySelector('#toggleBtn') as any)!.click()
;(document.querySelector('#toggleBtn') as any)!.click()
return Promise.resolve().then(() => {
return document.querySelector('#container')!.innerHTML
})

View File

@ -18,11 +18,9 @@ export default {
message: 'test: add test for runtime-dom/modules/class (#75)',
tree: {
sha: 'f53f761827af281db86c31d113086c068c1d0789',
url:
'https://api.github.com/repos/vuejs/vue-next/git/trees/f53f761827af281db86c31d113086c068c1d0789'
url: 'https://api.github.com/repos/vuejs/vue-next/git/trees/f53f761827af281db86c31d113086c068c1d0789'
},
url:
'https://api.github.com/repos/vuejs/vue-next/git/commits/d1527fbee422c7170e56845e55b49c4fd6de72a7',
url: 'https://api.github.com/repos/vuejs/vue-next/git/commits/d1527fbee422c7170e56845e55b49c4fd6de72a7',
comment_count: 0,
verification: {
verified: false,
@ -31,8 +29,7 @@ export default {
payload: null
}
},
url:
'https://api.github.com/repos/vuejs/vue-next/commits/d1527fbee422c7170e56845e55b49c4fd6de72a7',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/d1527fbee422c7170e56845e55b49c4fd6de72a7',
html_url:
'https://github.com/vuejs/vue-next/commit/d1527fbee422c7170e56845e55b49c4fd6de72a7',
comments_url:
@ -87,8 +84,7 @@ export default {
parents: [
{
sha: '2383b45e322272ddc102d6914c149b284a25d04f',
url:
'https://api.github.com/repos/vuejs/vue-next/commits/2383b45e322272ddc102d6914c149b284a25d04f',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/2383b45e322272ddc102d6914c149b284a25d04f',
html_url:
'https://github.com/vuejs/vue-next/commit/2383b45e322272ddc102d6914c149b284a25d04f'
}
@ -112,11 +108,9 @@ export default {
message: 'chore: fix typo (#530) [ci skip]',
tree: {
sha: '2a5872ff8dc8ccb8121abd7e890ac3c0c9f1209f',
url:
'https://api.github.com/repos/vuejs/vue-next/git/trees/2a5872ff8dc8ccb8121abd7e890ac3c0c9f1209f'
url: 'https://api.github.com/repos/vuejs/vue-next/git/trees/2a5872ff8dc8ccb8121abd7e890ac3c0c9f1209f'
},
url:
'https://api.github.com/repos/vuejs/vue-next/git/commits/2383b45e322272ddc102d6914c149b284a25d04f',
url: 'https://api.github.com/repos/vuejs/vue-next/git/commits/2383b45e322272ddc102d6914c149b284a25d04f',
comment_count: 0,
verification: {
verified: false,
@ -125,8 +119,7 @@ export default {
payload: null
}
},
url:
'https://api.github.com/repos/vuejs/vue-next/commits/2383b45e322272ddc102d6914c149b284a25d04f',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/2383b45e322272ddc102d6914c149b284a25d04f',
html_url:
'https://github.com/vuejs/vue-next/commit/2383b45e322272ddc102d6914c149b284a25d04f',
comments_url:
@ -182,8 +175,7 @@ export default {
parents: [
{
sha: 'e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
url:
'https://api.github.com/repos/vuejs/vue-next/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
html_url:
'https://github.com/vuejs/vue-next/commit/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad'
}
@ -207,11 +199,9 @@ export default {
message: 'test: fix warning',
tree: {
sha: 'd942b17681e2e2fbbcd2ee04092390c7f2cf534d',
url:
'https://api.github.com/repos/vuejs/vue-next/git/trees/d942b17681e2e2fbbcd2ee04092390c7f2cf534d'
url: 'https://api.github.com/repos/vuejs/vue-next/git/trees/d942b17681e2e2fbbcd2ee04092390c7f2cf534d'
},
url:
'https://api.github.com/repos/vuejs/vue-next/git/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
url: 'https://api.github.com/repos/vuejs/vue-next/git/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
comment_count: 0,
verification: {
verified: false,
@ -220,8 +210,7 @@ export default {
payload: null
}
},
url:
'https://api.github.com/repos/vuejs/vue-next/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
html_url:
'https://github.com/vuejs/vue-next/commit/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
comments_url:
@ -277,8 +266,7 @@ export default {
parents: [
{
sha: '12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e',
url:
'https://api.github.com/repos/vuejs/vue-next/commits/12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e',
html_url:
'https://github.com/vuejs/vue-next/commit/12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e'
}
@ -304,11 +292,9 @@ export default {
message: 'chore: fix tests',
tree: {
sha: '6ac7bd078a6eb0ad32b5102e0c5d2c29f2b20a48',
url:
'https://api.github.com/repos/vuejs/vue-next/git/trees/6ac7bd078a6eb0ad32b5102e0c5d2c29f2b20a48'
url: 'https://api.github.com/repos/vuejs/vue-next/git/trees/6ac7bd078a6eb0ad32b5102e0c5d2c29f2b20a48'
},
url:
'https://api.github.com/repos/vuejs/vue-next/git/commits/ecf4da822eea97f5db5fa769d39f994755384a4b',
url: 'https://api.github.com/repos/vuejs/vue-next/git/commits/ecf4da822eea97f5db5fa769d39f994755384a4b',
comment_count: 0,
verification: {
verified: false,
@ -317,8 +303,7 @@ export default {
payload: null
}
},
url:
'https://api.github.com/repos/vuejs/vue-next/commits/ecf4da822eea97f5db5fa769d39f994755384a4b',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/ecf4da822eea97f5db5fa769d39f994755384a4b',
html_url:
'https://github.com/vuejs/vue-next/commit/ecf4da822eea97f5db5fa769d39f994755384a4b',
comments_url:
@ -374,8 +359,7 @@ export default {
parents: [
{
sha: 'ca296812d54aff123472d7147b83fddfb634d9bc',
url:
'https://api.github.com/repos/vuejs/vue-next/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
html_url:
'https://github.com/vuejs/vue-next/commit/ca296812d54aff123472d7147b83fddfb634d9bc'
}
@ -399,11 +383,9 @@ export default {
message: 'refactor: bring back clone for reused nodes',
tree: {
sha: '2cec32c97686e0ee9af1b87f0abdbbbdc18b6de6',
url:
'https://api.github.com/repos/vuejs/vue-next/git/trees/2cec32c97686e0ee9af1b87f0abdbbbdc18b6de6'
url: 'https://api.github.com/repos/vuejs/vue-next/git/trees/2cec32c97686e0ee9af1b87f0abdbbbdc18b6de6'
},
url:
'https://api.github.com/repos/vuejs/vue-next/git/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
url: 'https://api.github.com/repos/vuejs/vue-next/git/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
comment_count: 0,
verification: {
verified: false,
@ -412,8 +394,7 @@ export default {
payload: null
}
},
url:
'https://api.github.com/repos/vuejs/vue-next/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
html_url:
'https://github.com/vuejs/vue-next/commit/ca296812d54aff123472d7147b83fddfb634d9bc',
comments_url:
@ -469,8 +450,7 @@ export default {
parents: [
{
sha: 'e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
url:
'https://api.github.com/repos/vuejs/vue-next/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
html_url:
'https://github.com/vuejs/vue-next/commit/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b'
}
@ -494,11 +474,9 @@ export default {
message: 'chore: relax render type for tsx',
tree: {
sha: '7e2b3bb92ab91f755b2251e4a7903e6dd2042602',
url:
'https://api.github.com/repos/vuejs/vue-next/git/trees/7e2b3bb92ab91f755b2251e4a7903e6dd2042602'
url: 'https://api.github.com/repos/vuejs/vue-next/git/trees/7e2b3bb92ab91f755b2251e4a7903e6dd2042602'
},
url:
'https://api.github.com/repos/vuejs/vue-next/git/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
url: 'https://api.github.com/repos/vuejs/vue-next/git/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
comment_count: 0,
verification: {
verified: false,
@ -507,8 +485,7 @@ export default {
payload: null
}
},
url:
'https://api.github.com/repos/vuejs/vue-next/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
html_url:
'https://github.com/vuejs/vue-next/commit/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
comments_url:
@ -564,8 +541,7 @@ export default {
parents: [
{
sha: 'ccc835caff0344baad3c92ce786ad4f804bf667b',
url:
'https://api.github.com/repos/vuejs/vue-next/commits/ccc835caff0344baad3c92ce786ad4f804bf667b',
url: 'https://api.github.com/repos/vuejs/vue-next/commits/ccc835caff0344baad3c92ce786ad4f804bf667b',
html_url:
'https://github.com/vuejs/vue-next/commit/ccc835caff0344baad3c92ce786ad4f804bf667b'
}

View File

@ -74,9 +74,9 @@ function compileToFunction(
// with keys that cannot be mangled, and can be quite heavy size-wise.
// In the global build we know `Vue` is available globally so we can avoid
// the wildcard object.
const render = (__GLOBAL__
? new Function(code)()
: new Function('Vue', code)(runtimeDom)) as RenderFunction
const render = (
__GLOBAL__ ? new Function(code)() : new Function('Vue', code)(runtimeDom)
) as RenderFunction
// mark the function as runtime compiled
;(render as InternalRenderFunction)._rc = true