diff --git a/.babelrc.js b/.babelrc.js deleted file mode 100644 index 4104dde65d5..00000000000 --- a/.babelrc.js +++ /dev/null @@ -1,13 +0,0 @@ - -module.exports = { - presets: [ - "@babel/preset-env", - "@babel/preset-typescript" - ], - plugins: [ - require("babel-plugin-transform-vue-jsx"), - require("@babel/plugin-syntax-dynamic-import") - ], - - ignore: ["dist/*.js", "packages/**/*.js"], -}; diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 7bf90e20366..00000000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -flow -dist -packages diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index c1e2b4d03e4..00000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,39 +0,0 @@ -module.exports = { - root: true, - parser: "@typescript-eslint/parser", - - parserOptions: { - // parser: "@typescript-eslint/parser", - // ecmaVersion: 2018, - sourceType: "module", - }, - env: { - es6: true, - node: true, - browser: true, - }, - // plugins: ["flowtype"], - extends: [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - ], - globals: { - __TEST__: true, - WXEnvironment: true, - }, - rules: { - 'no-unused-vars': [ - 'error', - // we are only using this rule to check for unused arguments since TS - // catches unused variables but not args. - { varsIgnorePattern: '.*', args: 'none' } - ], - 'prefer-spread': 0, - 'prefer-rest-params': 0, - 'no-prototype-builtins': 0, - "no-console": process.env.NODE_ENV !== "production" ? 0 : 2, - "no-useless-escape": 0, - "no-empty": 0, - "no-extra-semi": 0 - }, -}; diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000000..ef93d94821a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +semi: false +singleQuote: true +printWidth: 80 +trailingComma: 'none' +arrowParens: 'avoid' diff --git a/examples/.eslintrc.json b/examples/.eslintrc.json deleted file mode 100644 index f7a85281a36..00000000000 --- a/examples/.eslintrc.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "globals": { - "Vue": true, - "firebase": true - } -} diff --git a/package.json b/package.json index 86aa61a70df..c4f37976cc2 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "test:e2e": "npm run build -- web-full-prod,web-server-renderer-basic && vitest run test/e2e", "test:transition": "karma start test/transition/karma.conf.js", "test:types": "tsc -p ./types/tsconfig.json", - "lint": "eslint src scripts test", + "format": "prettier --write --parser typescript \"(src|test|packages)/**/*.ts\"", "ts-check": "tsc -p tsconfig.json --noEmit", "ts-check:test": "tsc -p test/tsconfig.json --noEmit", "bench:ssr": "npm run build:ssr && node benchmarks/ssr/renderToString.js && node benchmarks/ssr/renderToStream.js", @@ -42,7 +42,10 @@ }, "lint-staged": { "*.js": [ - "eslint --fix" + "prettier --write" + ], + "*.ts": [ + "prettier --parser=typescript --write" ] }, "repository": { @@ -65,8 +68,6 @@ "@rollup/plugin-replace": "^4.0.0", "@types/he": "^1.1.2", "@types/node": "^17.0.30", - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.21.0", "acorn": "^8.7.1", "acorn-walk": "^8.2.0", "chalk": "^4.0.0", @@ -77,7 +78,6 @@ "de-indent": "^1.0.2", "esbuild": "^0.14.39", "escodegen": "^2.0.0", - "eslint": "^8.14.0", "file-loader": "^3.0.1", "hash-sum": "^2.0.0", "he": "^1.2.0", @@ -95,6 +95,7 @@ "lru-cache": "^7.8.1", "marked": "^3.0.8", "memory-fs": "^0.5.0", + "prettier": "^2.6.2", "puppeteer": "^14.1.1", "resolve": "^1.22.0", "rollup": "^2.70.2", diff --git a/packages/vue-server-renderer/client-plugin.d.ts b/packages/vue-server-renderer/client-plugin.d.ts index 005c0f619e9..d0d639a6463 100644 --- a/packages/vue-server-renderer/client-plugin.d.ts +++ b/packages/vue-server-renderer/client-plugin.d.ts @@ -1,3 +1,3 @@ -import { WebpackPlugin } from './types/plugin'; -declare const Plugin: WebpackPlugin; -export = Plugin; +import { WebpackPlugin } from './types/plugin' +declare const Plugin: WebpackPlugin +export = Plugin diff --git a/packages/vue-server-renderer/server-plugin.d.ts b/packages/vue-server-renderer/server-plugin.d.ts index 005c0f619e9..d0d639a6463 100644 --- a/packages/vue-server-renderer/server-plugin.d.ts +++ b/packages/vue-server-renderer/server-plugin.d.ts @@ -1,3 +1,3 @@ -import { WebpackPlugin } from './types/plugin'; -declare const Plugin: WebpackPlugin; -export = Plugin; +import { WebpackPlugin } from './types/plugin' +declare const Plugin: WebpackPlugin +export = Plugin diff --git a/packages/vue-server-renderer/types/index.d.ts b/packages/vue-server-renderer/types/index.d.ts index e1ab698940b..6932cd1430f 100644 --- a/packages/vue-server-renderer/types/index.d.ts +++ b/packages/vue-server-renderer/types/index.d.ts @@ -1,50 +1,53 @@ -import Vue, { VNode, VNodeDirective } from 'vue'; -import { Readable } from 'stream'; +import Vue, { VNode, VNodeDirective } from 'vue' +import { Readable } from 'stream' -export declare function createRenderer(options?: RendererOptions): Renderer; +export declare function createRenderer(options?: RendererOptions): Renderer -export declare function createBundleRenderer(bundle: string | object, options?: BundleRendererOptions): BundleRenderer; +export declare function createBundleRenderer( + bundle: string | object, + options?: BundleRendererOptions +): BundleRenderer -type RenderCallback = (err: Error | null, html: string) => void; +type RenderCallback = (err: Error | null, html: string) => void interface Renderer { - renderToString(vm: Vue, callback: RenderCallback): void; - renderToString(vm: Vue, context: object, callback: RenderCallback): void; - renderToString(vm: Vue): Promise; - renderToString(vm: Vue, context: object): Promise; + renderToString(vm: Vue, callback: RenderCallback): void + renderToString(vm: Vue, context: object, callback: RenderCallback): void + renderToString(vm: Vue): Promise + renderToString(vm: Vue, context: object): Promise - renderToStream(vm: Vue, context?: object): Readable; + renderToStream(vm: Vue, context?: object): Readable } interface BundleRenderer { - renderToString(callback: RenderCallback): void; - renderToString(context: object, callback: RenderCallback): void; - renderToString(): Promise; - renderToString(context: object): Promise; + renderToString(callback: RenderCallback): void + renderToString(context: object, callback: RenderCallback): void + renderToString(): Promise + renderToString(context: object): Promise - renderToStream(context?: object): Readable; + renderToStream(context?: object): Readable } interface RendererOptions { - template?: string; - inject?: boolean; - shouldPreload?: (file: string, type: string) => boolean; - shouldPrefetch?: (file: string, type: string) => boolean; - cache?: RenderCache; + template?: string + inject?: boolean + shouldPreload?: (file: string, type: string) => boolean + shouldPrefetch?: (file: string, type: string) => boolean + cache?: RenderCache directives?: { [key: string]: (vnode: VNode, dir: VNodeDirective) => void - }; + } } interface BundleRendererOptions extends RendererOptions { - clientManifest?: object; - serializer?: (state: object) => string; - runInNewContext?: boolean | 'once'; - basedir?: string; + clientManifest?: object + serializer?: (state: object) => string + runInNewContext?: boolean | 'once' + basedir?: string } interface RenderCache { - get: (key: string, cb?: (res: string) => void) => string | void; - set: (key: string, val: string) => void; - has?: (key: string, cb?: (hit: boolean) => void) => boolean | void; + get: (key: string, cb?: (res: string) => void) => string | void + set: (key: string, val: string) => void + has?: (key: string, cb?: (hit: boolean) => void) => boolean | void } diff --git a/packages/vue-server-renderer/types/plugin.d.ts b/packages/vue-server-renderer/types/plugin.d.ts index 89d03c8da7e..423a58b4d81 100644 --- a/packages/vue-server-renderer/types/plugin.d.ts +++ b/packages/vue-server-renderer/types/plugin.d.ts @@ -1,11 +1,11 @@ -import { DefinePlugin } from 'webpack'; +import { DefinePlugin } from 'webpack' interface WebpackPluginOptions { - filename?: string; + filename?: string } export interface WebpackPlugin { // NOTE NOT SURE ABOUT THIS // TODO DOUBLE CHECK HERE - new (options?: WebpackPluginOptions): DefinePlugin; + new (options?: WebpackPluginOptions): DefinePlugin } diff --git a/packages/vue-template-compiler/types/index.d.ts b/packages/vue-template-compiler/types/index.d.ts index e2b603f025b..92476a49e5a 100644 --- a/packages/vue-template-compiler/types/index.d.ts +++ b/packages/vue-template-compiler/types/index.d.ts @@ -1,13 +1,13 @@ -import Vue, { VNode } from "vue" +import Vue, { VNode } from 'vue' /* * Template compilation options / results */ interface CompilerOptions { - modules?: ModuleOptions[]; - directives?: Record; - preserveWhitespace?: boolean; - whitespace?: 'preserve' | 'condense'; + modules?: ModuleOptions[] + directives?: Record + preserveWhitespace?: boolean + whitespace?: 'preserve' | 'condense' outputSourceRange?: any } @@ -16,34 +16,34 @@ interface CompilerOptionsWithSourceRange extends CompilerOptions { } interface ErrorWithRange { - msg: string; - start: number; - end: number; + msg: string + start: number + end: number } interface CompiledResult { - ast: ASTElement | undefined; - render: string; - staticRenderFns: string[]; - errors: ErrorType[]; - tips: ErrorType[]; + ast: ASTElement | undefined + render: string + staticRenderFns: string[] + errors: ErrorType[] + tips: ErrorType[] } interface CompiledResultFunctions { - render: () => VNode; - staticRenderFns: (() => VNode)[]; + render: () => VNode + staticRenderFns: (() => VNode)[] } interface ModuleOptions { - preTransformNode: (el: ASTElement) => ASTElement | undefined; - transformNode: (el: ASTElement) => ASTElement | undefined; - postTransformNode: (el: ASTElement) => void; - genData: (el: ASTElement) => string; - transformCode?: (el: ASTElement, code: string) => string; - staticKeys?: string[]; + preTransformNode: (el: ASTElement) => ASTElement | undefined + transformNode: (el: ASTElement) => ASTElement | undefined + postTransformNode: (el: ASTElement) => void + genData: (el: ASTElement) => string + transformCode?: (el: ASTElement, code: string) => string + staticKeys?: string[] } -type DirectiveFunction = (node: ASTElement, directiveMeta: ASTDirective) => void; +type DirectiveFunction = (node: ASTElement, directiveMeta: ASTDirective) => void /* * AST Types @@ -59,153 +59,153 @@ type DirectiveFunction = (node: ASTElement, directiveMeta: ASTDirective) => void export type SSROptimizability = 0 | 1 | 2 | 3 | 4 export interface ASTModifiers { - [key: string]: boolean; + [key: string]: boolean } export interface ASTIfCondition { - exp: string | undefined; - block: ASTElement; + exp: string | undefined + block: ASTElement } export interface ASTElementHandler { - value: string; - params?: any[]; - modifiers: ASTModifiers | undefined; + value: string + params?: any[] + modifiers: ASTModifiers | undefined } export interface ASTElementHandlers { - [key: string]: ASTElementHandler | ASTElementHandler[]; + [key: string]: ASTElementHandler | ASTElementHandler[] } export interface ASTDirective { - name: string; - rawName: string; - value: string; - arg: string | undefined; - modifiers: ASTModifiers | undefined; + name: string + rawName: string + value: string + arg: string | undefined + modifiers: ASTModifiers | undefined } -export type ASTNode = ASTElement | ASTText | ASTExpression; +export type ASTNode = ASTElement | ASTText | ASTExpression export interface ASTElement { - type: 1; - tag: string; - attrsList: { name: string; value: any }[]; - attrsMap: Record; - parent: ASTElement | undefined; - children: ASTNode[]; - - processed?: true; - - static?: boolean; - staticRoot?: boolean; - staticInFor?: boolean; - staticProcessed?: boolean; - hasBindings?: boolean; - - text?: string; - attrs?: { name: string; value: any }[]; - props?: { name: string; value: string }[]; - plain?: boolean; - pre?: true; - ns?: string; - - component?: string; - inlineTemplate?: true; - transitionMode?: string | null; - slotName?: string; - slotTarget?: string; - slotScope?: string; - scopedSlots?: Record; - - ref?: string; - refInFor?: boolean; - - if?: string; - ifProcessed?: boolean; - elseif?: string; - else?: true; - ifConditions?: ASTIfCondition[]; - - for?: string; - forProcessed?: boolean; - key?: string; - alias?: string; - iterator1?: string; - iterator2?: string; - - staticClass?: string; - classBinding?: string; - staticStyle?: string; - styleBinding?: string; - events?: ASTElementHandlers; - nativeEvents?: ASTElementHandlers; - - transition?: string | true; - transitionOnAppear?: boolean; + type: 1 + tag: string + attrsList: { name: string; value: any }[] + attrsMap: Record + parent: ASTElement | undefined + children: ASTNode[] + + processed?: true + + static?: boolean + staticRoot?: boolean + staticInFor?: boolean + staticProcessed?: boolean + hasBindings?: boolean + + text?: string + attrs?: { name: string; value: any }[] + props?: { name: string; value: string }[] + plain?: boolean + pre?: true + ns?: string + + component?: string + inlineTemplate?: true + transitionMode?: string | null + slotName?: string + slotTarget?: string + slotScope?: string + scopedSlots?: Record + + ref?: string + refInFor?: boolean + + if?: string + ifProcessed?: boolean + elseif?: string + else?: true + ifConditions?: ASTIfCondition[] + + for?: string + forProcessed?: boolean + key?: string + alias?: string + iterator1?: string + iterator2?: string + + staticClass?: string + classBinding?: string + staticStyle?: string + styleBinding?: string + events?: ASTElementHandlers + nativeEvents?: ASTElementHandlers + + transition?: string | true + transitionOnAppear?: boolean model?: { - value: string; - callback: string; - expression: string; - }; + value: string + callback: string + expression: string + } - directives?: ASTDirective[]; + directives?: ASTDirective[] - forbidden?: true; - once?: true; - onceProcessed?: boolean; - wrapData?: (code: string) => string; - wrapListeners?: (code: string) => string; + forbidden?: true + once?: true + onceProcessed?: boolean + wrapData?: (code: string) => string + wrapListeners?: (code: string) => string // 2.4 ssr optimization - ssrOptimizability?: SSROptimizability; + ssrOptimizability?: SSROptimizability } export interface ASTExpression { - type: 2; - expression: string; - text: string; - tokens: (string | Record)[]; - static?: boolean; + type: 2 + expression: string + text: string + tokens: (string | Record)[] + static?: boolean // 2.4 ssr optimization - ssrOptimizability?: SSROptimizability; + ssrOptimizability?: SSROptimizability } export interface ASTText { - type: 3; - text: string; - static?: boolean; - isComment?: boolean; + type: 3 + text: string + static?: boolean + isComment?: boolean // 2.4 ssr optimization - ssrOptimizability?: SSROptimizability; + ssrOptimizability?: SSROptimizability } /* * SFC parser related types */ interface SFCParserOptions { - pad?: true | 'line' | 'space'; + pad?: true | 'line' | 'space' deindent?: boolean } export interface SFCBlock { - type: string; - content: string; - attrs: Record; - start?: number; - end?: number; - lang?: string; - src?: string; - scoped?: boolean; - module?: string | boolean; + type: string + content: string + attrs: Record + start?: number + end?: number + lang?: string + src?: string + scoped?: boolean + module?: string | boolean } export interface SFCDescriptor { - template: SFCBlock | undefined; - script: SFCBlock | undefined; - styles: SFCBlock[]; - customBlocks: SFCBlock[]; + template: SFCBlock | undefined + script: SFCBlock | undefined + styles: SFCBlock[] + customBlocks: SFCBlock[] } /* @@ -219,29 +219,29 @@ export function compile( export function compile( template: string, options?: CompilerOptions -): CompiledResult; +): CompiledResult -export function compileToFunctions(template: string): CompiledResultFunctions; +export function compileToFunctions(template: string): CompiledResultFunctions export function ssrCompile( template: string, options: CompilerOptionsWithSourceRange -): CompiledResult; +): CompiledResult export function ssrCompile( template: string, options?: CompilerOptions -): CompiledResult; +): CompiledResult -export function ssrCompileToFunctions(template: string): CompiledResultFunctions; +export function ssrCompileToFunctions(template: string): CompiledResultFunctions export function parseComponent( file: string, options?: SFCParserOptions -): SFCDescriptor; +): SFCDescriptor export function generateCodeFrame( template: string, start: number, end: number -): string; +): string diff --git a/packages/vue-template-compiler/types/test.ts b/packages/vue-template-compiler/types/test.ts index b0e6cb1549f..3b8484481c7 100644 --- a/packages/vue-template-compiler/types/test.ts +++ b/packages/vue-template-compiler/types/test.ts @@ -1,4 +1,4 @@ -import Vue, { VNode } from "vue"; +import Vue, { VNode } from 'vue' import { compile, compileToFunctions, @@ -6,10 +6,10 @@ import { ssrCompileToFunctions, parseComponent, generateCodeFrame -} from "./"; +} from './' // check compile options -const compiled = compile("
hi
", { +const compiled = compile('
hi
', { outputSourceRange: true, preserveWhitespace: false, whitespace: 'condense', @@ -18,24 +18,24 @@ const compiled = compile("
hi
", { preTransformNode: el => el, transformNode: el => el, postTransformNode: el => { - el.tag = "p"; + el.tag = 'p' }, genData: el => el.tag, transformCode: (el, code) => code, - staticKeys: ["test"] + staticKeys: ['test'] } ], directives: { test: (node, directiveMeta) => { - node.tag; - directiveMeta.value; + node.tag + directiveMeta.value } } -}); +}) // can be passed to function constructor -new Function(compiled.render); -compiled.staticRenderFns.map(fn => new Function(fn)); +new Function(compiled.render) +compiled.staticRenderFns.map(fn => new Function(fn)) // with outputSourceRange: true // errors should be objects with range @@ -61,30 +61,30 @@ errors3.forEach(e => { console.log(e.length) }) -const compiledFns = compileToFunctions("
hi
"); +const compiledFns = compileToFunctions('
hi
') // can be passed to component render / staticRenderFns options const vm = new Vue({ data() { return { - test: "Test" - }; + test: 'Test' + } }, render: compiledFns.render, staticRenderFns: compiledFns.staticRenderFns -}); +}) // can be called with component instance -const vnode: VNode = compiledFns.render.call(vm); +const vnode: VNode = compiledFns.render.call(vm) // check SFC parser -const desc = parseComponent("", { - pad: "space", +const desc = parseComponent('', { + pad: 'space', deindent: false -}); +}) -const templateContent: string = desc.template!.content; -const scriptContent: string = desc.script!.content; -const styleContent: string = desc.styles.map(s => s.content).join("\n"); +const templateContent: string = desc.template!.content +const scriptContent: string = desc.script!.content +const styleContent: string = desc.styles.map(s => s.content).join('\n') const codeframe: string = generateCodeFrame(`foobar`, 0, 4) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 19c27af9e0b..a0f328bffa4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,8 +7,6 @@ specifiers: '@rollup/plugin-replace': ^4.0.0 '@types/he': ^1.1.2 '@types/node': ^17.0.30 - '@typescript-eslint/eslint-plugin': ^5.21.0 - '@typescript-eslint/parser': ^5.21.0 acorn: ^8.7.1 acorn-walk: ^8.2.0 chalk: ^4.0.0 @@ -19,7 +17,6 @@ specifiers: de-indent: ^1.0.2 esbuild: ^0.14.39 escodegen: ^2.0.0 - eslint: ^8.14.0 file-loader: ^3.0.1 hash-sum: ^2.0.0 he: ^1.2.0 @@ -37,6 +34,7 @@ specifiers: lru-cache: ^7.8.1 marked: ^3.0.8 memory-fs: ^0.5.0 + prettier: ^2.6.2 puppeteer: ^14.1.1 resolve: ^1.22.0 rollup: ^2.70.2 @@ -60,8 +58,6 @@ devDependencies: '@rollup/plugin-replace': 4.0.0_rollup@2.74.0 '@types/he': 1.1.2 '@types/node': 17.0.34 - '@typescript-eslint/eslint-plugin': 5.25.0_qo2hgs5jt7x2a3p77h2rutcdae - '@typescript-eslint/parser': 5.25.0_hcfsmds2fshutdssjqluwm76uu acorn: 8.7.1 acorn-walk: 8.2.0 chalk: 4.1.2 @@ -72,7 +68,6 @@ devDependencies: de-indent: 1.0.2 esbuild: 0.14.39 escodegen: 2.0.0 - eslint: 8.15.0 file-loader: 3.0.1_webpack@4.46.0 hash-sum: 2.0.0 he: 1.2.0 @@ -90,6 +85,7 @@ devDependencies: lru-cache: 7.10.1 marked: 3.0.8 memory-fs: 0.5.0 + prettier: 2.6.2 puppeteer: 14.1.1 resolve: 1.22.0 rollup: 2.74.0 @@ -204,64 +200,11 @@ packages: '@cspotcode/source-map-consumer': 0.8.0 dev: true - /@eslint/eslintrc/1.2.3: - resolution: {integrity: sha512-uGo44hIwoLGNyduRpjdEpovcbMdd+Nv7amtmJxnKmI8xj6yd5LncmSwDa5NgX/41lIFJtkjD6YdVfgEzPfJ5UA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - ajv: 6.12.6 - debug: 4.3.4 - espree: 9.3.2 - globals: 13.15.0 - ignore: 5.2.0 - import-fresh: 3.3.0 - js-yaml: 4.1.0 - minimatch: 3.1.2 - strip-json-comments: 3.1.1 - transitivePeerDependencies: - - supports-color - dev: true - - /@humanwhocodes/config-array/0.9.5: - resolution: {integrity: sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw==} - engines: {node: '>=10.10.0'} - dependencies: - '@humanwhocodes/object-schema': 1.2.1 - debug: 4.3.4 - minimatch: 3.1.2 - transitivePeerDependencies: - - supports-color - dev: true - - /@humanwhocodes/object-schema/1.2.1: - resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==} - dev: true - /@hutson/parse-repository-url/3.0.2: resolution: {integrity: sha512-H9XAx3hc0BQHY6l+IFSWHDySypcXsvsuLhgYLUGywmJ5pswRVQJUHpOsobnLYp2ZUaUlKiKDrgWWhosOwAEM8Q==} engines: {node: '>=6.9.0'} dev: true - /@nodelib/fs.scandir/2.1.5: - resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} - engines: {node: '>= 8'} - dependencies: - '@nodelib/fs.stat': 2.0.5 - run-parallel: 1.2.0 - dev: true - - /@nodelib/fs.stat/2.0.5: - resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} - engines: {node: '>= 8'} - dev: true - - /@nodelib/fs.walk/1.2.8: - resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} - engines: {node: '>= 8'} - dependencies: - '@nodelib/fs.scandir': 2.1.5 - fastq: 1.13.0 - dev: true - /@rollup/plugin-alias/3.1.9_rollup@2.74.0: resolution: {integrity: sha512-QI5fsEvm9bDzt32k39wpOwZhVzRcL5ydcffUHMyLVaVaLeC70I8TJZ17F1z1eMoLu4E/UOcH9BWVkKpIKdrfiw==} engines: {node: '>=8.0.0'} @@ -388,10 +331,6 @@ packages: resolution: {integrity: sha512-kSJPcLO1x+oolc0R89pUl2kozldQ/fVQ1C1p5mp8fPoLdF/ZcBvckaTC2M8xXh3GYendXvCpy5m/a2eSbfgNgw==} dev: true - /@types/json-schema/7.0.11: - resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} - dev: true - /@types/minimist/1.2.2: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true @@ -423,132 +362,6 @@ packages: dev: true optional: true - /@typescript-eslint/eslint-plugin/5.25.0_qo2hgs5jt7x2a3p77h2rutcdae: - resolution: {integrity: sha512-icYrFnUzvm+LhW0QeJNKkezBu6tJs9p/53dpPLFH8zoM9w1tfaKzVurkPotEpAqQ8Vf8uaFyL5jHd0Vs6Z0ZQg==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - '@typescript-eslint/parser': ^5.0.0 - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/parser': 5.25.0_hcfsmds2fshutdssjqluwm76uu - '@typescript-eslint/scope-manager': 5.25.0 - '@typescript-eslint/type-utils': 5.25.0_hcfsmds2fshutdssjqluwm76uu - '@typescript-eslint/utils': 5.25.0_hcfsmds2fshutdssjqluwm76uu - debug: 4.3.4 - eslint: 8.15.0 - functional-red-black-tree: 1.0.1 - ignore: 5.2.0 - regexpp: 3.2.0 - semver: 7.3.7 - tsutils: 3.21.0_typescript@4.6.4 - typescript: 4.6.4 - transitivePeerDependencies: - - supports-color - dev: true - - /@typescript-eslint/parser/5.25.0_hcfsmds2fshutdssjqluwm76uu: - resolution: {integrity: sha512-r3hwrOWYbNKP1nTcIw/aZoH+8bBnh/Lh1iDHoFpyG4DnCpvEdctrSl6LOo19fZbzypjQMHdajolxs6VpYoChgA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/scope-manager': 5.25.0 - '@typescript-eslint/types': 5.25.0 - '@typescript-eslint/typescript-estree': 5.25.0_typescript@4.6.4 - debug: 4.3.4 - eslint: 8.15.0 - typescript: 4.6.4 - transitivePeerDependencies: - - supports-color - dev: true - - /@typescript-eslint/scope-manager/5.25.0: - resolution: {integrity: sha512-p4SKTFWj+2VpreUZ5xMQsBMDdQ9XdRvODKXN4EksyBjFp2YvQdLkyHqOffakYZPuWJUDNu3jVXtHALDyTv3cww==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - '@typescript-eslint/types': 5.25.0 - '@typescript-eslint/visitor-keys': 5.25.0 - dev: true - - /@typescript-eslint/type-utils/5.25.0_hcfsmds2fshutdssjqluwm76uu: - resolution: {integrity: sha512-B6nb3GK3Gv1Rsb2pqalebe/RyQoyG/WDy9yhj8EE0Ikds4Xa8RR28nHz+wlt4tMZk5bnAr0f3oC8TuDAd5CPrw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: '*' - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/utils': 5.25.0_hcfsmds2fshutdssjqluwm76uu - debug: 4.3.4 - eslint: 8.15.0 - tsutils: 3.21.0_typescript@4.6.4 - typescript: 4.6.4 - transitivePeerDependencies: - - supports-color - dev: true - - /@typescript-eslint/types/5.25.0: - resolution: {integrity: sha512-7fWqfxr0KNHj75PFqlGX24gWjdV/FDBABXL5dyvBOWHpACGyveok8Uj4ipPX/1fGU63fBkzSIycEje4XsOxUFA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - - /@typescript-eslint/typescript-estree/5.25.0_typescript@4.6.4: - resolution: {integrity: sha512-MrPODKDych/oWs/71LCnuO7NyR681HuBly2uLnX3r5i4ME7q/yBqC4hW33kmxtuauLTM0OuBOhhkFaxCCOjEEw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - typescript: '*' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - '@typescript-eslint/types': 5.25.0 - '@typescript-eslint/visitor-keys': 5.25.0 - debug: 4.3.4 - globby: 11.1.0 - is-glob: 4.0.3 - semver: 7.3.7 - tsutils: 3.21.0_typescript@4.6.4 - typescript: 4.6.4 - transitivePeerDependencies: - - supports-color - dev: true - - /@typescript-eslint/utils/5.25.0_hcfsmds2fshutdssjqluwm76uu: - resolution: {integrity: sha512-qNC9bhnz/n9Kba3yI6HQgQdBLuxDoMgdjzdhSInZh6NaDnFpTUlwNGxplUFWfY260Ya0TRPvkg9dd57qxrJI9g==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - dependencies: - '@types/json-schema': 7.0.11 - '@typescript-eslint/scope-manager': 5.25.0 - '@typescript-eslint/types': 5.25.0 - '@typescript-eslint/typescript-estree': 5.25.0_typescript@4.6.4 - eslint: 8.15.0 - eslint-scope: 5.1.1 - eslint-utils: 3.0.0_eslint@8.15.0 - transitivePeerDependencies: - - supports-color - - typescript - dev: true - - /@typescript-eslint/visitor-keys/5.25.0: - resolution: {integrity: sha512-yd26vFgMsC4h2dgX4+LR+GeicSKIfUvZREFLf3DDjZPtqgLx5AJZr6TetMNwFP9hcKreTTeztQYBTNbNoOycwA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - '@typescript-eslint/types': 5.25.0 - eslint-visitor-keys: 3.3.0 - dev: true - /@webassemblyjs/ast/1.9.0: resolution: {integrity: sha512-C6wW5L+b7ogSDVqymbkkvuW9kruN//YisMED04xzeBBqjHa2FYnmvOlS6Xj68xWQRgWvI9cIglsjFowH/RJyEA==} dependencies: @@ -719,14 +532,6 @@ packages: acorn-walk: 7.2.0 dev: true - /acorn-jsx/5.3.2_acorn@8.7.1: - resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} - peerDependencies: - acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 - dependencies: - acorn: 8.7.1 - dev: true - /acorn-walk/7.2.0: resolution: {integrity: sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==} engines: {node: '>=0.4.0'} @@ -878,10 +683,6 @@ packages: resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} dev: true - /argparse/2.0.1: - resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} - dev: true - /arr-diff/4.0.0: resolution: {integrity: sha512-YVIQ82gZPGBebQV/a8dar4AitzCQs0jjXwMPZllpXMaGjXPYVUawSxQrRsjhjupyVxEvbHgUmIhKVlND+j02kA==} engines: {node: '>=0.10.0'} @@ -901,11 +702,6 @@ packages: resolution: {integrity: sha512-c5AMf34bKdvPhQ7tBGhqkgKNUzMr4WUs+WDtC2ZUGOUncbxKMTvqxYctiseW3+L4bA8ec+GcZ6/A/FW4m8ukng==} dev: true - /array-union/2.1.0: - resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} - engines: {node: '>=8'} - dev: true - /array-unique/0.3.2: resolution: {integrity: sha512-SleRWjh9JUud2wH1hPs9rZBZ33H6T9HOiL0uwGnGx9FpE6wKGyfWugmbkEOIs6qWrZhg0LWeLziLrEwQJhs5mQ==} engines: {node: '>=0.10.0'} @@ -1236,6 +1032,7 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} dev: true + optional: true /camelcase-keys/6.2.2: resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==} @@ -2053,20 +1850,6 @@ packages: randombytes: 2.1.0 dev: true - /dir-glob/3.0.1: - resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} - engines: {node: '>=8'} - dependencies: - path-type: 4.0.0 - dev: true - - /doctrine/3.0.0: - resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} - engines: {node: '>=6.0.0'} - dependencies: - esutils: 2.0.3 - dev: true - /dom-serialize/2.2.1: resolution: {integrity: sha1-ViromZ9Evl6jB29UGdzVnrQ6yVs=} dependencies: @@ -2421,11 +2204,6 @@ packages: engines: {node: '>=0.8.0'} dev: true - /escape-string-regexp/4.0.0: - resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} - engines: {node: '>=10'} - dev: true - /escodegen/2.0.0: resolution: {integrity: sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==} engines: {node: '>=6.0'} @@ -2447,108 +2225,12 @@ packages: estraverse: 4.3.0 dev: true - /eslint-scope/5.1.1: - resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} - engines: {node: '>=8.0.0'} - dependencies: - esrecurse: 4.3.0 - estraverse: 4.3.0 - dev: true - - /eslint-scope/7.1.1: - resolution: {integrity: sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - esrecurse: 4.3.0 - estraverse: 5.3.0 - dev: true - - /eslint-utils/3.0.0_eslint@8.15.0: - resolution: {integrity: sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==} - engines: {node: ^10.0.0 || ^12.0.0 || >= 14.0.0} - peerDependencies: - eslint: '>=5' - dependencies: - eslint: 8.15.0 - eslint-visitor-keys: 2.1.0 - dev: true - - /eslint-visitor-keys/2.1.0: - resolution: {integrity: sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==} - engines: {node: '>=10'} - dev: true - - /eslint-visitor-keys/3.3.0: - resolution: {integrity: sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dev: true - - /eslint/8.15.0: - resolution: {integrity: sha512-GG5USZ1jhCu8HJkzGgeK8/+RGnHaNYZGrGDzUtigK3BsGESW/rs2az23XqE0WVwDxy1VRvvjSSGu5nB0Bu+6SA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - hasBin: true - dependencies: - '@eslint/eslintrc': 1.2.3 - '@humanwhocodes/config-array': 0.9.5 - ajv: 6.12.6 - chalk: 4.1.2 - cross-spawn: 7.0.3 - debug: 4.3.4 - doctrine: 3.0.0 - escape-string-regexp: 4.0.0 - eslint-scope: 7.1.1 - eslint-utils: 3.0.0_eslint@8.15.0 - eslint-visitor-keys: 3.3.0 - espree: 9.3.2 - esquery: 1.4.0 - esutils: 2.0.3 - fast-deep-equal: 3.1.3 - file-entry-cache: 6.0.1 - functional-red-black-tree: 1.0.1 - glob-parent: 6.0.2 - globals: 13.15.0 - ignore: 5.2.0 - import-fresh: 3.3.0 - imurmurhash: 0.1.4 - is-glob: 4.0.3 - js-yaml: 4.1.0 - json-stable-stringify-without-jsonify: 1.0.1 - levn: 0.4.1 - lodash.merge: 4.6.2 - minimatch: 3.1.2 - natural-compare: 1.4.0 - optionator: 0.9.1 - regexpp: 3.2.0 - strip-ansi: 6.0.1 - strip-json-comments: 3.1.1 - text-table: 0.2.0 - v8-compile-cache: 2.3.0 - transitivePeerDependencies: - - supports-color - dev: true - - /espree/9.3.2: - resolution: {integrity: sha512-D211tC7ZwouTIuY5x9XnS0E9sWNChB7IYKX/Xp5eQj3nFXhqmiUDB9q27y76oFl8jTg3pXcQx/bpxMfs3CIZbA==} - engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - dependencies: - acorn: 8.7.1 - acorn-jsx: 5.3.2_acorn@8.7.1 - eslint-visitor-keys: 3.3.0 - dev: true - /esprima/4.0.1: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} hasBin: true dev: true - /esquery/1.4.0: - resolution: {integrity: sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==} - engines: {node: '>=0.10'} - dependencies: - estraverse: 5.3.0 - dev: true - /esrecurse/4.3.0: resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} engines: {node: '>=4.0'} @@ -2707,17 +2389,6 @@ packages: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} dev: true - /fast-glob/3.2.11: - resolution: {integrity: sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==} - engines: {node: '>=8.6.0'} - dependencies: - '@nodelib/fs.stat': 2.0.5 - '@nodelib/fs.walk': 1.2.8 - glob-parent: 5.1.2 - merge2: 1.4.1 - micromatch: 4.0.5 - dev: true - /fast-json-stable-stringify/2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} dev: true @@ -2726,12 +2397,6 @@ packages: resolution: {integrity: sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=} dev: true - /fastq/1.13.0: - resolution: {integrity: sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==} - dependencies: - reusify: 1.0.4 - dev: true - /fd-slicer/1.1.0: resolution: {integrity: sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=} dependencies: @@ -2749,13 +2414,6 @@ packages: escape-string-regexp: 1.0.5 dev: true - /file-entry-cache/6.0.1: - resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} - engines: {node: ^10.12.0 || >=12.0.0} - dependencies: - flat-cache: 3.0.4 - dev: true - /file-loader/3.0.1_webpack@4.46.0: resolution: {integrity: sha512-4sNIOXgtH/9WZq4NvlfU3Opn5ynUsqBwSLyM+I7UOwdGigTBYfVVQEwe/msZNX/j4pCJTIM14Fsw66Svo1oVrw==} engines: {node: '>= 6.9.0'} @@ -2873,14 +2531,6 @@ packages: resolve-dir: 1.0.1 dev: true - /flat-cache/3.0.4: - resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==} - engines: {node: ^10.12.0 || >=12.0.0} - dependencies: - flatted: 3.2.5 - rimraf: 3.0.2 - dev: true - /flatted/3.2.5: resolution: {integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==} dev: true @@ -2988,10 +2638,6 @@ packages: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true - /functional-red-black-tree/1.0.1: - resolution: {integrity: sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=} - dev: true - /get-caller-file/2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} engines: {node: 6.* || 8.* || >= 10.*} @@ -3092,13 +2738,6 @@ packages: is-glob: 4.0.3 dev: true - /glob-parent/6.0.2: - resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} - engines: {node: '>=10.13.0'} - dependencies: - is-glob: 4.0.3 - dev: true - /glob/7.1.4: resolution: {integrity: sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==} dependencies: @@ -3149,25 +2788,6 @@ packages: which: 1.3.1 dev: true - /globals/13.15.0: - resolution: {integrity: sha512-bpzcOlgDhMG070Av0Vy5Owklpv1I6+j96GhUI7Rh7IzDCKLzboflLrrfqMu8NquDbiR4EOQk7XzJwqVJxicxog==} - engines: {node: '>=8'} - dependencies: - type-fest: 0.20.2 - dev: true - - /globby/11.1.0: - resolution: {integrity: sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==} - engines: {node: '>=10'} - dependencies: - array-union: 2.1.0 - dir-glob: 3.0.1 - fast-glob: 3.2.11 - ignore: 5.2.0 - merge2: 1.4.1 - slash: 3.0.0 - dev: true - /graceful-fs/4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} dev: true @@ -3375,11 +2995,6 @@ packages: resolution: {integrity: sha1-xg7taebY/bazEEofy8ocGS3FtQE=} dev: true - /ignore/5.2.0: - resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} - engines: {node: '>= 4'} - dev: true - /import-fresh/3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} @@ -3387,6 +3002,7 @@ packages: parent-module: 1.0.1 resolve-from: 4.0.0 dev: true + optional: true /imurmurhash/0.1.4: resolution: {integrity: sha1-khi5srkoojixPcT7a21XbyMUU+o=} @@ -3692,13 +3308,6 @@ packages: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} dev: true - /js-yaml/4.1.0: - resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} - hasBin: true - dependencies: - argparse: 2.0.1 - dev: true - /jsdom/19.0.0: resolution: {integrity: sha512-RYAyjCbxy/vri/CfnjUWJQQtZ3LKlLnDqj+9XLNnJPgEGeirZs3hllKR20re8LUZ6o1b1X4Jat+Qd26zmP41+A==} engines: {node: '>=12'} @@ -3753,10 +3362,6 @@ packages: resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} dev: true - /json-stable-stringify-without-jsonify/1.0.1: - resolution: {integrity: sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=} - dev: true - /json-stringify-safe/5.0.1: resolution: {integrity: sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=} dev: true @@ -3889,14 +3494,6 @@ packages: type-check: 0.3.2 dev: true - /levn/0.4.1: - resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} - engines: {node: '>= 0.8.0'} - dependencies: - prelude-ls: 1.2.1 - type-check: 0.4.0 - dev: true - /lilconfig/2.0.4: resolution: {integrity: sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==} engines: {node: '>=10'} @@ -4019,10 +3616,6 @@ packages: resolution: {integrity: sha1-dx7Hg540c9nEzeKLGTlMNWL09tM=} dev: true - /lodash.merge/4.6.2: - resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} - dev: true - /lodash.sortby/4.7.0: resolution: {integrity: sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=} dev: true @@ -4213,11 +3806,6 @@ packages: resolution: {integrity: sha512-jz+Cfrg9GWOZbQAnDQ4hlVnQky+341Yk5ru8bZSe6sIDTCIg8n9i/u7hSQGSVOF3C7lH6mGtqjkiT9G4wFLL0w==} dev: true - /merge2/1.4.1: - resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} - engines: {node: '>= 8'} - dev: true - /micromatch/3.1.10: resolution: {integrity: sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==} engines: {node: '>=0.10.0'} @@ -4412,10 +4000,6 @@ packages: - supports-color dev: true - /natural-compare/1.4.0: - resolution: {integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=} - dev: true - /negotiator/0.6.3: resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==} engines: {node: '>= 0.6'} @@ -4598,18 +4182,6 @@ packages: word-wrap: 1.2.3 dev: true - /optionator/0.9.1: - resolution: {integrity: sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==} - engines: {node: '>= 0.8.0'} - dependencies: - deep-is: 0.1.4 - fast-levenshtein: 2.0.6 - levn: 0.4.1 - prelude-ls: 1.2.1 - type-check: 0.4.0 - word-wrap: 1.2.3 - dev: true - /os-browserify/0.3.0: resolution: {integrity: sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=} dev: true @@ -4708,6 +4280,7 @@ packages: dependencies: callsites: 3.1.0 dev: true + optional: true /parse-asn1/5.1.6: resolution: {integrity: sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==} @@ -4817,6 +4390,7 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} dev: true + optional: true /pathval/1.1.1: resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} @@ -4907,9 +4481,10 @@ packages: engines: {node: '>= 0.8.0'} dev: true - /prelude-ls/1.2.1: - resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} - engines: {node: '>= 0.8.0'} + /prettier/2.6.2: + resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==} + engines: {node: '>=10.13.0'} + hasBin: true dev: true /process-nextick-args/2.0.1: @@ -5051,10 +4626,6 @@ packages: deprecated: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. dev: true - /queue-microtask/1.2.3: - resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - dev: true - /quick-lru/4.0.1: resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} engines: {node: '>=8'} @@ -5187,11 +4758,6 @@ packages: safe-regex: 1.1.0 dev: true - /regexpp/3.2.0: - resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} - engines: {node: '>=8'} - dev: true - /remove-trailing-separator/1.1.0: resolution: {integrity: sha1-wkvOKig62tW8P1jg1IJJuSN52O8=} dev: true @@ -5228,6 +4794,7 @@ packages: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} dev: true + optional: true /resolve-from/5.0.0: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} @@ -5278,11 +4845,6 @@ packages: engines: {node: '>=0.12'} dev: true - /reusify/1.0.4: - resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} - engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - dev: true - /rfdc/1.3.0: resolution: {integrity: sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==} dev: true @@ -5337,12 +4899,6 @@ packages: engines: {node: '>=0.12.0'} dev: true - /run-parallel/1.2.0: - resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} - dependencies: - queue-microtask: 1.2.3 - dev: true - /run-queue/1.0.3: resolution: {integrity: sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=} dependencies: @@ -5857,11 +5413,6 @@ packages: engines: {node: '>=8'} dev: true - /strip-json-comments/3.1.1: - resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} - engines: {node: '>=8'} - dev: true - /supports-color/5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} engines: {node: '>=4'} @@ -5960,10 +5511,6 @@ packages: engines: {node: '>=0.10'} dev: true - /text-table/0.2.0: - resolution: {integrity: sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=} - dev: true - /through/2.3.8: resolution: {integrity: sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=} dev: true @@ -6127,16 +5674,6 @@ packages: resolution: {integrity: sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==} dev: true - /tsutils/3.21.0_typescript@4.6.4: - resolution: {integrity: sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==} - engines: {node: '>= 6'} - peerDependencies: - typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' - dependencies: - tslib: 1.14.1 - typescript: 4.6.4 - dev: true - /tty-browserify/0.0.0: resolution: {integrity: sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=} dev: true @@ -6148,13 +5685,6 @@ packages: prelude-ls: 1.1.2 dev: true - /type-check/0.4.0: - resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} - engines: {node: '>= 0.8.0'} - dependencies: - prelude-ls: 1.2.1 - dev: true - /type-detect/4.0.8: resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} engines: {node: '>=4'} @@ -6165,11 +5695,6 @@ packages: engines: {node: '>=10'} dev: true - /type-fest/0.20.2: - resolution: {integrity: sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==} - engines: {node: '>=10'} - dev: true - /type-fest/0.21.3: resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==} engines: {node: '>=10'} @@ -6330,10 +5855,6 @@ packages: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} dev: true - /v8-compile-cache/2.3.0: - resolution: {integrity: sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==} - dev: true - /validate-npm-package-license/3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: diff --git a/src/compiler/codeframe.ts b/src/compiler/codeframe.ts index a06f387f45a..86b540ffc6f 100644 --- a/src/compiler/codeframe.ts +++ b/src/compiler/codeframe.ts @@ -1,4 +1,3 @@ - const range = 2 export function generateCodeFrame( diff --git a/src/compiler/codegen/events.ts b/src/compiler/codegen/events.ts index 1c3685bf729..34de474e8d3 100644 --- a/src/compiler/codegen/events.ts +++ b/src/compiler/codegen/events.ts @@ -36,7 +36,7 @@ const keyNames: { [key: string]: string | Array } = { // #4868: modifiers that prevent the execution of the listener // need to explicitly return null so that we can determine whether to remove // the listener for .once -const genGuard = (condition) => `if(${condition})return null;` +const genGuard = condition => `if(${condition})return null;` const modifierCode: { [key: string]: string } = { stop: '$event.stopPropagation();', @@ -83,7 +83,7 @@ function genHandler( } if (Array.isArray(handler)) { - return `[${handler.map((handler) => genHandler(handler)).join(',')}]` + return `[${handler.map(handler => genHandler(handler)).join(',')}]` } const isMethodPath = simplePathRE.test(handler.value) @@ -114,8 +114,8 @@ function genHandler( const modifiers = handler.modifiers genModifierCode += genGuard( ['ctrl', 'shift', 'alt', 'meta'] - .filter((keyModifier) => !modifiers[keyModifier]) - .map((keyModifier) => `$event.${keyModifier}Key`) + .filter(keyModifier => !modifiers[keyModifier]) + .map(keyModifier => `$event.${keyModifier}Key`) .join('||') ) } else { diff --git a/src/compiler/codegen/index.ts b/src/compiler/codegen/index.ts index 0b7de4492f6..d87bd5e6f5c 100644 --- a/src/compiler/codegen/index.ts +++ b/src/compiler/codegen/index.ts @@ -359,7 +359,7 @@ function genInlineTemplate( return `inlineTemplate:{render:function(){${ inlineRenderFns.render }},staticRenderFns:[${inlineRenderFns.staticRenderFns - .map((code) => `function(){${code}}`) + .map(code => `function(){${code}}`) .join(',')}]}` } } @@ -375,7 +375,7 @@ function genScopedSlots( // for example if the slot contains dynamic names, has v-if or v-for on them... let needsForceUpdate = el.for || - Object.keys(slots).some((key) => { + Object.keys(slots).some(key => { const slot = slots[key] return ( slot.slotTargetDynamic || slot.if || slot.for || containsSlotChild(slot) // is passing down slot from parent which may be dynamic @@ -411,7 +411,7 @@ function genScopedSlots( } const generatedSlots = Object.keys(slots) - .map((key) => genScopedSlot(slots[key], state)) + .map(key => genScopedSlot(slots[key], state)) .join(',') return `scopedSlots:_u([${generatedSlots}]${ @@ -492,7 +492,7 @@ export function genChildren( ? getNormalizationType(children, state.maybeComponent) : 0 const gen = altGenNode || genNode - return `[${children.map((c) => gen(c, state)).join(',')}]${ + return `[${children.map(c => gen(c, state)).join(',')}]${ normalizationType ? `,${normalizationType}` : '' }` } @@ -515,14 +515,14 @@ function getNormalizationType( if ( needsNormalization(el) || (el.ifConditions && - el.ifConditions.some((c) => needsNormalization(c.block))) + el.ifConditions.some(c => needsNormalization(c.block))) ) { res = 2 break } if ( maybeComponent(el) || - (el.ifConditions && el.ifConditions.some((c) => maybeComponent(c.block))) + (el.ifConditions && el.ifConditions.some(c => maybeComponent(c.block))) ) { res = 1 } @@ -563,7 +563,7 @@ function genSlot(el: ASTElement, state: CodegenState): string { const attrs = el.attrs || el.dynamicAttrs ? genProps( - (el.attrs || []).concat(el.dynamicAttrs || []).map((attr) => ({ + (el.attrs || []).concat(el.dynamicAttrs || []).map(attr => ({ // slot props are camelized name: camelize(attr.name), value: attr.value, diff --git a/src/compiler/create-compiler.ts b/src/compiler/create-compiler.ts index 214c0e48a49..f6aa0ae3b17 100644 --- a/src/compiler/create-compiler.ts +++ b/src/compiler/create-compiler.ts @@ -1,4 +1,3 @@ - import { extend } from 'shared/util' import { detectErrors } from './error-detector' import { createCompileToFunctionFn } from './to-function' @@ -13,8 +12,12 @@ export function createCompilerCreator(baseCompile: Function): Function { const errors: WarningMessage[] = [] const tips: WarningMessage[] = [] - let warn = (msg: WarningMessage, range: { start: number, end: number }, tip: string) => { - (tip ? tips : errors).push(msg) + let warn = ( + msg: WarningMessage, + range: { start: number; end: number }, + tip: string + ) => { + ;(tip ? tips : errors).push(msg) } if (options) { @@ -25,8 +28,12 @@ export function createCompilerCreator(baseCompile: Function): Function { // $flow-disable-line const leadingSpaceLength = template.match(/^\s*/)![0].length - warn = (msg: WarningMessage | string, range: { start: number, end: number }, tip: string) => { - const data: WarningMessage = typeof(msg) === 'string' ? { msg } : msg + warn = ( + msg: WarningMessage | string, + range: { start: number; end: number }, + tip: string + ) => { + const data: WarningMessage = typeof msg === 'string' ? { msg } : msg if (range) { if (range.start != null) { data.start = range.start + leadingSpaceLength @@ -35,7 +42,7 @@ export function createCompilerCreator(baseCompile: Function): Function { data.end = range.end + leadingSpaceLength } } - (tip ? tips : errors).push(data) + ;(tip ? tips : errors).push(data) } } // merge custom modules @@ -72,7 +79,7 @@ export function createCompilerCreator(baseCompile: Function): Function { return { compile, - compileToFunctions: createCompileToFunctionFn(compile), + compileToFunctions: createCompileToFunctionFn(compile) } } } diff --git a/src/compiler/directives/bind.ts b/src/compiler/directives/bind.ts index 409852ba5f1..8e646c3c5bc 100644 --- a/src/compiler/directives/bind.ts +++ b/src/compiler/directives/bind.ts @@ -1,4 +1,3 @@ - export default function bind(el: ASTElement, dir: ASTDirective) { el.wrapData = (code: string) => { return `_b(${code},'${el.tag}',${dir.value},${ diff --git a/src/compiler/directives/index.ts b/src/compiler/directives/index.ts index e04df4f1071..72cfb22ab11 100644 --- a/src/compiler/directives/index.ts +++ b/src/compiler/directives/index.ts @@ -1,4 +1,3 @@ - import on from './on' import bind from './bind' import { noop } from 'shared/util' @@ -6,5 +5,5 @@ import { noop } from 'shared/util' export default { on, bind, - cloak: noop, + cloak: noop } diff --git a/src/compiler/directives/model.ts b/src/compiler/directives/model.ts index 39262b53777..c3591027498 100644 --- a/src/compiler/directives/model.ts +++ b/src/compiler/directives/model.ts @@ -1,4 +1,3 @@ - /** * Cross-platform code generation for component v-model */ @@ -25,7 +24,7 @@ export function genComponentModel( el.model = { value: `(${value})`, expression: JSON.stringify(value), - callback: `function (${baseValueExpression}) {${assignment}}`, + callback: `function (${baseValueExpression}) {${assignment}}` } } @@ -74,12 +73,12 @@ export function parseModel(val: string): ModelParseResult { if (index > -1) { return { exp: val.slice(0, index), - key: '"' + val.slice(index + 1) + '"', + key: '"' + val.slice(index + 1) + '"' } } else { return { exp: val, - key: null, + key: null } } } @@ -99,7 +98,7 @@ export function parseModel(val: string): ModelParseResult { return { exp: val.slice(0, expressionPos), - key: val.slice(expressionPos + 1, expressionEndPos), + key: val.slice(expressionPos + 1, expressionEndPos) } } diff --git a/src/compiler/directives/on.ts b/src/compiler/directives/on.ts index 2ca2d124a07..da0d66fbd1a 100644 --- a/src/compiler/directives/on.ts +++ b/src/compiler/directives/on.ts @@ -1,4 +1,3 @@ - import { warn } from 'core/util/index' export default function on(el: ASTElement, dir: ASTDirective) { diff --git a/src/compiler/error-detector.ts b/src/compiler/error-detector.ts index 9271aa5bd92..eb29280be05 100644 --- a/src/compiler/error-detector.ts +++ b/src/compiler/error-detector.ts @@ -1,4 +1,3 @@ - import { dirRE, onRE } from './parser/index' type Range = { start?: number; end?: number } @@ -25,7 +24,8 @@ const unaryOperatorsRE = new RegExp( ) // strip strings in expressions -const stripStringRE = /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g +const stripStringRE = + /'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*\$\{|\}(?:[^`\\]|\\.)*`|`(?:[^`\\]|\\.)*`/g // detect problematic expressions in a template export function detectErrors(ast: ASTNode | undefined, warn: Function) { @@ -117,7 +117,7 @@ function checkExpression( ) { try { new Function(`return ${exp}`) - } catch (e:any) { + } catch (e: any) { const keywordMatch = exp .replace(stripStringRE, '') .match(prohibitedKeywordRE) @@ -146,7 +146,7 @@ function checkFunctionParameterExpression( ) { try { new Function(exp, '') - } catch (e:any) { + } catch (e: any) { warn( `invalid function parameter expression: ${e.message} in\n\n` + ` ${exp}\n\n` + diff --git a/src/compiler/helpers.ts b/src/compiler/helpers.ts index 93c661f785b..be588bdf40d 100644 --- a/src/compiler/helpers.ts +++ b/src/compiler/helpers.ts @@ -1,4 +1,3 @@ - import { emptyObject } from 'shared/util' import { parseFilters } from './parser/filter-parser' @@ -14,7 +13,7 @@ export function pluckModuleFunction( modules: Array | undefined, key: K ): Array { - return modules ? modules.map((m) => m[key]).filter((_) => _) : [] + return modules ? modules.map(m => m[key]).filter(_ => _) : [] } export function addProp( @@ -24,7 +23,7 @@ export function addProp( range?: Range, dynamic?: boolean ) { - (el.props || (el.props = [])).push( + ;(el.props || (el.props = [])).push( rangeSetItem({ name, value, dynamic }, range) ) el.plain = false @@ -65,7 +64,7 @@ export function addDirective( modifiers?: ASTModifiers, range?: Range ) { - (el.directives || (el.directives = [])).push( + ;(el.directives || (el.directives = [])).push( rangeSetItem( { name, @@ -73,7 +72,7 @@ export function addDirective( value, arg, isDynamicArg, - modifiers, + modifiers }, range ) diff --git a/src/compiler/index.ts b/src/compiler/index.ts index 997689ccd2b..585b5c63091 100644 --- a/src/compiler/index.ts +++ b/src/compiler/index.ts @@ -1,4 +1,3 @@ - import { parse } from './parser/index' import { optimize } from './optimizer' import { generate } from './codegen/index' @@ -19,6 +18,6 @@ export const createCompiler = createCompilerCreator(function baseCompile( return { ast, render: code.render, - staticRenderFns: code.staticRenderFns, + staticRenderFns: code.staticRenderFns } }) diff --git a/src/compiler/optimizer.ts b/src/compiler/optimizer.ts index 5b4cb718df9..c0b81736535 100644 --- a/src/compiler/optimizer.ts +++ b/src/compiler/optimizer.ts @@ -1,4 +1,3 @@ - import { makeMap, isBuiltInTag, cached, no } from 'shared/util' let isStaticKey diff --git a/src/compiler/parser/entity-decoder.ts b/src/compiler/parser/entity-decoder.ts index 7e693d8ab0e..031f3291763 100644 --- a/src/compiler/parser/entity-decoder.ts +++ b/src/compiler/parser/entity-decoder.ts @@ -1,4 +1,3 @@ - let decoder export default { @@ -6,5 +5,5 @@ export default { decoder = decoder || document.createElement('div') decoder.innerHTML = html return decoder.textContent - }, + } } diff --git a/src/compiler/parser/filter-parser.ts b/src/compiler/parser/filter-parser.ts index 0684a3751ec..b5aa5b7f4a6 100644 --- a/src/compiler/parser/filter-parser.ts +++ b/src/compiler/parser/filter-parser.ts @@ -1,4 +1,3 @@ - const validDivisionCharRE = /[\w).+\-_$\]]/ export function parseFilters(exp: string): string { @@ -91,7 +90,7 @@ export function parseFilters(exp: string): string { } function pushFilter() { - (filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()) + ;(filters || (filters = [])).push(exp.slice(lastFilterIndex, i).trim()) lastFilterIndex = i + 1 } diff --git a/src/compiler/parser/html-parser.ts b/src/compiler/parser/html-parser.ts index 2913e650240..b1cf9768d24 100644 --- a/src/compiler/parser/html-parser.ts +++ b/src/compiler/parser/html-parser.ts @@ -14,8 +14,10 @@ import { isNonPhrasingTag } from 'web/compiler/util' import { unicodeRegExp } from 'core/util/lang' // Regular Expressions for parsing tags and attributes -const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ -const dynamicArgAttribute = /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ +const attribute = + /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ +const dynamicArgAttribute = + /^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+?\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/ const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeRegExp.source}]*` const qnameCapture = `((?:${ncname}\\:)?${ncname})` const startTagOpen = new RegExp(`^<${qnameCapture}`) @@ -37,7 +39,7 @@ const decodingMap = { '&': '&', ' ': '\n', ' ': '\t', - ''': "'", + ''': "'" } const encodedAttr = /&(?:lt|gt|quot|amp|#39);/g const encodedAttrWithNewLines = /&(?:lt|gt|quot|amp|#39|#10|#9);/g @@ -49,7 +51,7 @@ const shouldIgnoreFirstNewline = (tag, html) => function decodeAttr(value, shouldDecodeNewlines) { const re = shouldDecodeNewlines ? encodedAttrWithNewLines : encodedAttr - return value.replace(re, (match) => decodingMap[match]) + return value.replace(re, match => decodingMap[match]) } export function parseHTML(html, options) { @@ -185,7 +187,7 @@ export function parseHTML(html, options) { options.warn ) { options.warn(`Mal-formatted tag at end of template: "${html}"`, { - start: index + html.length, + start: index + html.length }) } break @@ -206,7 +208,7 @@ export function parseHTML(html, options) { const match: any = { tagName: start[1], attrs: [], - start: index, + start: index } advance(start[0].length) let end, attr @@ -254,7 +256,7 @@ export function parseHTML(html, options) { : options.shouldDecodeNewlines attrs[i] = { name: args[1], - value: decodeAttr(value, shouldDecodeNewlines), + value: decodeAttr(value, shouldDecodeNewlines) } if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) { attrs[i].start = args.start + args[0].match(/^\s*/).length @@ -268,7 +270,7 @@ export function parseHTML(html, options) { lowerCasedTag: tagName.toLowerCase(), attrs: attrs, start: match.start, - end: match.end, + end: match.end }) lastTag = tagName } @@ -306,7 +308,7 @@ export function parseHTML(html, options) { ) { options.warn(`tag <${stack[i].tag}> has no matching end tag.`, { start: stack[i].start, - end: stack[i].end, + end: stack[i].end }) } if (options.end) { diff --git a/src/compiler/parser/index.ts b/src/compiler/parser/index.ts index 5f238a3fdac..d2f2fc21cb7 100644 --- a/src/compiler/parser/index.ts +++ b/src/compiler/parser/index.ts @@ -1,4 +1,3 @@ - import he from 'he' import { parseHTML } from './html-parser' import { parseText } from './text-parser' @@ -17,7 +16,7 @@ import { getAndRemoveAttr, getRawBindingAttr, pluckModuleFunction, - getAndRemoveAttrByRegex, + getAndRemoveAttrByRegex } from '../helpers' export const onRE = /^@|^v-on:/ @@ -68,7 +67,7 @@ export function createASTElement( attrsMap: makeAttrsMap(attrs), rawAttrsMap: {}, parent, - children: [], + children: [] } } @@ -82,12 +81,13 @@ export function parse(template: string, options: CompilerOptions): ASTElement { platformMustUseProp = options.mustUseProp || no platformGetTagNamespace = options.getTagNamespace || no const isReservedTag = options.isReservedTag || no - maybeComponent = (el: ASTElement) => !!( - el.component || - el.attrsMap[':is'] || - el.attrsMap['v-bind:is'] || - !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)) - ) + maybeComponent = (el: ASTElement) => + !!( + el.component || + el.attrsMap[':is'] || + el.attrsMap['v-bind:is'] || + !(el.attrsMap.is ? isReservedTag(el.attrsMap.is) : isReservedTag(el.tag)) + ) transforms = pluckModuleFunction(options.modules, 'transformNode') preTransforms = pluckModuleFunction(options.modules, 'preTransformNode') postTransforms = pluckModuleFunction(options.modules, 'postTransformNode') @@ -124,7 +124,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { } addIfCondition(root, { exp: element.elseif, - block: element, + block: element }) } else if (process.env.NODE_ENV !== 'production') { warnOnce( @@ -155,7 +155,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { // final children cleanup // filter out scoped slots - element.children = element.children.filter((c) => !c.slotScope) + element.children = element.children.filter(c => !c.slotScope) // remove trailing whitespace node again trimEndingWhitespace(element) @@ -238,14 +238,14 @@ export function parse(template: string, options: CompilerOptions): ASTElement { return cumulated }, {}) } - attrs.forEach((attr) => { + attrs.forEach(attr => { if (invalidAttributeRE.test(attr.name)) { warn( `Invalid dynamic argument expression: attribute names cannot contain ` + `spaces, quotes, <, >, / or =.`, { start: attr.start + attr.name.indexOf(`[`), - end: attr.start + attr.name.length, + end: attr.start + attr.name.length } ) } @@ -323,7 +323,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { ) } else if ((text = text.trim())) { warnOnce(`text "${text}" outside root element will be ignored.`, { - start, + start }) } } @@ -340,7 +340,9 @@ export function parse(template: string, options: CompilerOptions): ASTElement { } const children = currentParent.children if (inPre || text.trim()) { - text = isTextTag(currentParent) ? text : decodeHTMLCached(text) as string + text = isTextTag(currentParent) + ? text + : (decodeHTMLCached(text) as string) } else if (!children.length) { // remove the whitespace-only node right after an opening tag text = '' @@ -367,7 +369,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { type: 2, expression: res.expression, tokens: res.tokens, - text, + text } } else if ( text !== ' ' || @@ -376,7 +378,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { ) { child = { type: 3, - text, + text } } if (child) { @@ -398,7 +400,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { const child: ASTText = { type: 3, text, - isComment: true, + isComment: true } if ( process.env.NODE_ENV !== 'production' && @@ -409,7 +411,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement { } currentParent.children.push(child) } - }, + } }) return root } @@ -428,7 +430,7 @@ function processRawAttrs(el) { for (let i = 0; i < len; i++) { attrs[i] = { name: list[i].name, - value: JSON.stringify(list[i].value), + value: JSON.stringify(list[i].value) } if (list[i].start != null) { attrs[i].start = list[i].start @@ -544,7 +546,7 @@ function processIf(el) { el.if = exp addIfCondition(el, { exp: exp, - block: el, + block: el }) } else { if (getAndRemoveAttr(el, 'v-else') != null) { @@ -562,7 +564,7 @@ function processIfConditions(el, parent) { if (prev && prev.if) { addIfCondition(prev, { exp: el.elseif, - block: el, + block: el }) } else if (process.env.NODE_ENV !== 'production') { warn( @@ -776,7 +778,7 @@ function processAttrs(el) { modifiers = parseModifiers(name.replace(dirRE, '')) // support .foo shorthand syntax for the .prop modifier if (process.env.VBIND_PROP_SHORTHAND && propBindRE.test(name)) { - (modifiers || (modifiers = {})).prop = true + ;(modifiers || (modifiers = {})).prop = true name = `.` + name.slice(1).replace(modifierRE, '') } else if (modifiers) { name = name.replace(modifierRE, '') @@ -930,7 +932,7 @@ function parseModifiers(name: string): Object | void { const match = name.match(modifierRE) if (match) { const ret = {} - match.forEach((m) => { + match.forEach(m => { ret[m.slice(1)] = true }) return ret diff --git a/src/compiler/parser/text-parser.ts b/src/compiler/parser/text-parser.ts index a1e569a16df..ea7387ffff8 100644 --- a/src/compiler/parser/text-parser.ts +++ b/src/compiler/parser/text-parser.ts @@ -1,11 +1,10 @@ - import { cached } from 'shared/util' import { parseFilters } from './filter-parser' const defaultTagRE = /\{\{((?:.|\r?\n)+?)\}\}/g const regexEscapeRE = /[-.*+?^${}()|[\]\/\\]/g -const buildRegex = cached((delimiters) => { +const buildRegex = cached(delimiters => { const open = delimiters[0].replace(regexEscapeRE, '\\$&') const close = delimiters[1].replace(regexEscapeRE, '\\$&') return new RegExp(open + '((?:.|\\n)+?)' + close, 'g') @@ -48,6 +47,6 @@ export function parseText( } return { expression: tokens.join('+'), - tokens: rawTokens, + tokens: rawTokens } } diff --git a/src/compiler/to-function.ts b/src/compiler/to-function.ts index 8a384b5d07c..3165d3cc0ed 100644 --- a/src/compiler/to-function.ts +++ b/src/compiler/to-function.ts @@ -1,4 +1,3 @@ - import { noop, extend } from 'shared/util' import { warn as baseWarn, tip } from 'core/util/debug' import { generateCodeFrame } from './codeframe' @@ -35,7 +34,7 @@ export function createCompileToFunctionFn(compile: Function): Function { // detect possible CSP restriction try { new Function('return 1') - } catch (e:any) { + } catch (e: any) { if (e.toString().match(/unsafe-eval|CSP/)) { warn( 'It seems you are using the standalone build of Vue.js in an ' + @@ -63,7 +62,7 @@ export function createCompileToFunctionFn(compile: Function): Function { if (process.env.NODE_ENV !== 'production') { if (compiled.errors && compiled.errors.length) { if (options.outputSourceRange) { - compiled.errors.forEach((e) => { + compiled.errors.forEach(e => { warn( `Error compiling template:\n\n${e.msg}\n\n` + generateCodeFrame(template, e.start, e.end), @@ -73,7 +72,7 @@ export function createCompileToFunctionFn(compile: Function): Function { } else { warn( `Error compiling template:\n\n${template}\n\n` + - compiled.errors.map((e) => `- ${e}`).join('\n') + + compiled.errors.map(e => `- ${e}`).join('\n') + '\n', vm ) @@ -81,9 +80,9 @@ export function createCompileToFunctionFn(compile: Function): Function { } if (compiled.tips && compiled.tips.length) { if (options.outputSourceRange) { - compiled.tips.forEach((e) => tip(e.msg, vm)) + compiled.tips.forEach(e => tip(e.msg, vm)) } else { - compiled.tips.forEach((msg) => tip(msg, vm)) + compiled.tips.forEach(msg => tip(msg, vm)) } } } @@ -92,7 +91,7 @@ export function createCompileToFunctionFn(compile: Function): Function { const res: any = {} const fnGenErrors: any[] = [] res.render = createFunction(compiled.render, fnGenErrors) - res.staticRenderFns = compiled.staticRenderFns.map((code) => { + res.staticRenderFns = compiled.staticRenderFns.map(code => { return createFunction(code, fnGenErrors) }) diff --git a/src/core/components/index.ts b/src/core/components/index.ts index 3c681dae261..5461c763841 100644 --- a/src/core/components/index.ts +++ b/src/core/components/index.ts @@ -1,5 +1,5 @@ import KeepAlive from './keep-alive' export default { - KeepAlive, + KeepAlive } diff --git a/src/core/components/keep-alive.ts b/src/core/components/keep-alive.ts index 6e03c1e990a..605167f1522 100644 --- a/src/core/components/keep-alive.ts +++ b/src/core/components/keep-alive.ts @@ -1,19 +1,19 @@ -import { isRegExp, remove } from "shared/util"; -import { getFirstComponentChild } from "core/vdom/helpers/index"; -import type VNode from "core/vdom/vnode"; -import type { VNodeComponentOptions } from "typescript/vnode"; -import type { Component } from "typescript/component"; +import { isRegExp, remove } from 'shared/util' +import { getFirstComponentChild } from 'core/vdom/helpers/index' +import type VNode from 'core/vdom/vnode' +import type { VNodeComponentOptions } from 'typescript/vnode' +import type { Component } from 'typescript/component' type CacheEntry = { - name?: string; - tag?: string; - componentInstance?: Component; -}; + name?: string + tag?: string + componentInstance?: Component +} -type CacheEntryMap = Record; +type CacheEntryMap = Record function getComponentName(opts?: VNodeComponentOptions): string | null { - return opts && (opts.Ctor.options.name || opts.tag); + return opts && (opts.Ctor.options.name || opts.tag) } function matches( @@ -21,27 +21,27 @@ function matches( name: string ): boolean { if (Array.isArray(pattern)) { - return pattern.indexOf(name) > -1; - } else if (typeof pattern === "string") { - return pattern.split(",").indexOf(name) > -1; + return pattern.indexOf(name) > -1 + } else if (typeof pattern === 'string') { + return pattern.split(',').indexOf(name) > -1 } else if (isRegExp(pattern)) { - return pattern.test(name); + return pattern.test(name) } /* istanbul ignore next */ - return false; + return false } function pruneCache( keepAliveInstance: { cache: CacheEntryMap; keys: string[]; _vnode: VNode }, filter: Function ) { - const { cache, keys, _vnode } = keepAliveInstance; + const { cache, keys, _vnode } = keepAliveInstance for (const key in cache) { - const entry = cache[key]; + const entry = cache[key] if (entry) { - const name = entry.name; + const name = entry.name if (name && !filter(name)) { - pruneCacheEntry(cache, key, keys, _vnode); + pruneCacheEntry(cache, key, keys, _vnode) } } } @@ -53,112 +53,112 @@ function pruneCacheEntry( keys: Array, current?: VNode ) { - const entry = cache[key]; + const entry = cache[key] if (entry && (!current || entry.tag !== current.tag)) { // @ts-expect-error can be undefined - entry.componentInstance.$destroy(); + entry.componentInstance.$destroy() } - cache[key] = null; - remove(keys, key); + cache[key] = null + remove(keys, key) } -const patternTypes: Array = [String, RegExp, Array]; +const patternTypes: Array = [String, RegExp, Array] // TODO defineComponent export default { - name: "keep-alive", + name: 'keep-alive', abstract: true, props: { include: patternTypes, exclude: patternTypes, - max: [String, Number], + max: [String, Number] }, methods: { cacheVNode() { - const { cache, keys, vnodeToCache, keyToCache } = this; + const { cache, keys, vnodeToCache, keyToCache } = this if (vnodeToCache) { - const { tag, componentInstance, componentOptions } = vnodeToCache; + const { tag, componentInstance, componentOptions } = vnodeToCache cache[keyToCache] = { name: getComponentName(componentOptions), tag, - componentInstance, - }; - keys.push(keyToCache); + componentInstance + } + keys.push(keyToCache) // prune oldest entry if (this.max && keys.length > parseInt(this.max)) { - pruneCacheEntry(cache, keys[0], keys, this._vnode); + pruneCacheEntry(cache, keys[0], keys, this._vnode) } - this.vnodeToCache = null; + this.vnodeToCache = null } - }, + } }, created() { - this.cache = Object.create(null); - this.keys = []; + this.cache = Object.create(null) + this.keys = [] }, destroyed() { for (const key in this.cache) { - pruneCacheEntry(this.cache, key, this.keys); + pruneCacheEntry(this.cache, key, this.keys) } }, mounted() { - this.cacheVNode(); - this.$watch("include", (val) => { - pruneCache(this, (name) => matches(val, name)); - }); - this.$watch("exclude", (val) => { - pruneCache(this, (name) => !matches(val, name)); - }); + this.cacheVNode() + this.$watch('include', val => { + pruneCache(this, name => matches(val, name)) + }) + this.$watch('exclude', val => { + pruneCache(this, name => !matches(val, name)) + }) }, updated() { - this.cacheVNode(); + this.cacheVNode() }, render() { - const slot = this.$slots.default; - const vnode = getFirstComponentChild(slot); - const componentOptions = vnode && vnode.componentOptions; + const slot = this.$slots.default + const vnode = getFirstComponentChild(slot) + const componentOptions = vnode && vnode.componentOptions if (componentOptions) { // check pattern - const name = getComponentName(componentOptions); - const { include, exclude } = this; + const name = getComponentName(componentOptions) + const { include, exclude } = this if ( // not included (include && (!name || !matches(include, name))) || // excluded (exclude && name && matches(exclude, name)) ) { - return vnode; + return vnode } - const { cache, keys } = this; + const { cache, keys } = this const key = vnode.key == null ? // same constructor may get registered as different local components // so cid alone is not enough (#3269) componentOptions.Ctor.cid + - (componentOptions.tag ? `::${componentOptions.tag}` : "") - : vnode.key; + (componentOptions.tag ? `::${componentOptions.tag}` : '') + : vnode.key if (cache[key]) { - vnode.componentInstance = cache[key].componentInstance; + vnode.componentInstance = cache[key].componentInstance // make current key freshest - remove(keys, key); - keys.push(key); + remove(keys, key) + keys.push(key) } else { // delay setting the cache until update - this.vnodeToCache = vnode; - this.keyToCache = key; + this.vnodeToCache = vnode + this.keyToCache = key } // @ts-expect-error can vnode.data can be undefined - vnode.data.keepAlive = true; + vnode.data.keepAlive = true } - return vnode || (slot && slot[0]); - }, -}; + return vnode || (slot && slot[0]) + } +} diff --git a/src/core/config.ts b/src/core/config.ts index 20ef40c234f..f125f9052b0 100644 --- a/src/core/config.ts +++ b/src/core/config.ts @@ -1,4 +1,3 @@ - import { no, noop, identity } from 'shared/util' import { LIFECYCLE_HOOKS } from 'shared/constants' @@ -31,7 +30,7 @@ export interface Config { _lifecycleHooks: Array } -export default ({ +export default { /** * Option merge strategies (used in core/util/options) */ @@ -122,5 +121,5 @@ export default ({ /** * Exposed for legacy reasons */ - _lifecycleHooks: LIFECYCLE_HOOKS, -} as unknown) as Config + _lifecycleHooks: LIFECYCLE_HOOKS +} as unknown as Config diff --git a/src/core/global-api/assets.ts b/src/core/global-api/assets.ts index 82f02a30597..6b09170a1f4 100644 --- a/src/core/global-api/assets.ts +++ b/src/core/global-api/assets.ts @@ -1,4 +1,3 @@ - import { ASSET_TYPES } from 'shared/constants' import type { GlobalAPI } from 'typescript/global-api' import { isPlainObject, validateComponentName } from '../util/index' @@ -7,7 +6,7 @@ export function initAssetRegisters(Vue: GlobalAPI) { /** * Create asset registration methods. */ - ASSET_TYPES.forEach((type) => { + ASSET_TYPES.forEach(type => { // @ts-expect-error function is not exact same type Vue[type] = function ( id: string, diff --git a/src/core/global-api/extend.ts b/src/core/global-api/extend.ts index f1ca45aedd7..afabe769891 100644 --- a/src/core/global-api/extend.ts +++ b/src/core/global-api/extend.ts @@ -1,4 +1,3 @@ - import { ASSET_TYPES } from 'shared/constants' import type { Component } from 'typescript/component' import type { GlobalAPI } from 'typescript/global-api' @@ -31,9 +30,9 @@ export function initExtend(Vue: GlobalAPI) { validateComponentName(name) } - const Sub = (function VueComponent(this: any, options: any) { + const Sub = function VueComponent(this: any, options: any) { this._init(options) - } as unknown) as typeof Component + } as unknown as typeof Component Sub.prototype = Object.create(Super.prototype) Sub.prototype.constructor = Sub Sub.cid = cid++ diff --git a/src/core/global-api/index.ts b/src/core/global-api/index.ts index 008dea41077..69bdc6ee3a1 100644 --- a/src/core/global-api/index.ts +++ b/src/core/global-api/index.ts @@ -1,4 +1,3 @@ - import config from '../config' import { initUse } from './use' import { initMixin } from './mixin' @@ -14,7 +13,7 @@ import { extend, nextTick, mergeOptions, - defineReactive, + defineReactive } from '../util/index' import type { GlobalAPI } from 'typescript/global-api' @@ -38,7 +37,7 @@ export function initGlobalAPI(Vue: GlobalAPI) { warn, extend, mergeOptions, - defineReactive, + defineReactive } Vue.set = set @@ -52,7 +51,7 @@ export function initGlobalAPI(Vue: GlobalAPI) { } Vue.options = Object.create(null) - ASSET_TYPES.forEach((type) => { + ASSET_TYPES.forEach(type => { Vue.options[type + 's'] = Object.create(null) }) diff --git a/src/core/global-api/mixin.ts b/src/core/global-api/mixin.ts index 7b53b510f66..6bc7b8f245a 100644 --- a/src/core/global-api/mixin.ts +++ b/src/core/global-api/mixin.ts @@ -1,4 +1,3 @@ - import type { GlobalAPI } from 'typescript/global-api' import { mergeOptions } from '../util/index' diff --git a/src/core/global-api/use.ts b/src/core/global-api/use.ts index a0f8eace629..d3bad623d1e 100644 --- a/src/core/global-api/use.ts +++ b/src/core/global-api/use.ts @@ -1,4 +1,3 @@ - import type { GlobalAPI } from 'typescript/global-api' import { toArray } from '../util/index' diff --git a/src/core/index.ts b/src/core/index.ts index b50240e4a81..2ce6c9d604a 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -6,19 +6,19 @@ import { FunctionalRenderContext } from 'core/vdom/create-functional-component' initGlobalAPI(Vue) Object.defineProperty(Vue.prototype, '$isServer', { - get: isServerRendering, + get: isServerRendering }) Object.defineProperty(Vue.prototype, '$ssrContext', { get() { /* istanbul ignore next */ return this.$vnode && this.$vnode.ssrContext - }, + } }) // expose FunctionalRenderContext for ssr runtime helper installation Object.defineProperty(Vue, 'FunctionalRenderContext', { - value: FunctionalRenderContext, + value: FunctionalRenderContext }) Vue.version = '__VERSION__' diff --git a/src/core/instance/events.ts b/src/core/instance/events.ts index 24fa7aa6c7a..7420d06b8f0 100644 --- a/src/core/instance/events.ts +++ b/src/core/instance/events.ts @@ -1,11 +1,10 @@ - import type { Component } from 'typescript/component' import { tip, toArray, hyphenate, formatComponentName, - invokeWithErrorHandling, + invokeWithErrorHandling } from '../util/index' import { updateListeners } from '../vdom/helpers/index' @@ -68,7 +67,7 @@ export function eventsMixin(Vue: Component) { vm.$on(event[i], fn) } } else { - (vm._events[event] || (vm._events[event] = [])).push(fn) + ;(vm._events[event] || (vm._events[event] = [])).push(fn) // optimize hook:event cost by using a boolean flag marked at registration // instead of a hash lookup if (hookRE.test(event)) { diff --git a/src/core/instance/index.ts b/src/core/instance/index.ts index 03151ae5880..afe64c18c7b 100644 --- a/src/core/instance/index.ts +++ b/src/core/instance/index.ts @@ -1,27 +1,27 @@ -import { initMixin } from "./init"; -import { stateMixin } from "./state"; -import { renderMixin } from "./render"; -import { eventsMixin } from "./events"; -import { lifecycleMixin } from "./lifecycle"; -import { warn } from "../util/index"; -import type { GlobalAPI } from "typescript/global-api"; +import { initMixin } from './init' +import { stateMixin } from './state' +import { renderMixin } from './render' +import { eventsMixin } from './events' +import { lifecycleMixin } from './lifecycle' +import { warn } from '../util/index' +import type { GlobalAPI } from 'typescript/global-api' function Vue(options) { - if (process.env.NODE_ENV !== "production" && !(this instanceof Vue)) { - warn("Vue is a constructor and should be called with the `new` keyword"); + if (process.env.NODE_ENV !== 'production' && !(this instanceof Vue)) { + warn('Vue is a constructor and should be called with the `new` keyword') } - this._init(options); + this._init(options) } //@ts-expect-error Vue has function type -initMixin(Vue); +initMixin(Vue) //@ts-expect-error Vue has function type -stateMixin(Vue); +stateMixin(Vue) //@ts-expect-error Vue has function type -eventsMixin(Vue); +eventsMixin(Vue) //@ts-expect-error Vue has function type -lifecycleMixin(Vue); +lifecycleMixin(Vue) //@ts-expect-error Vue has function type -renderMixin(Vue); +renderMixin(Vue) -export default (Vue as unknown) as GlobalAPI; +export default Vue as unknown as GlobalAPI diff --git a/src/core/instance/init.ts b/src/core/instance/init.ts index e1a314cf741..16c72dd7a50 100644 --- a/src/core/instance/init.ts +++ b/src/core/instance/init.ts @@ -1,4 +1,3 @@ - import config from '../config' import { initProxy } from './proxy' import { initState } from './state' diff --git a/src/core/instance/inject.ts b/src/core/instance/inject.ts index 8ade3154bd3..58e43ed56ac 100644 --- a/src/core/instance/inject.ts +++ b/src/core/instance/inject.ts @@ -1,4 +1,3 @@ - import { hasOwn } from 'shared/util' import { warn, hasSymbol } from '../util/index' import { defineReactive, toggleObserving } from '../observer/index' @@ -19,7 +18,7 @@ export function initInjections(vm: Component) { const result = resolveInject(vm.$options.inject, vm) if (result) { toggleObserving(false) - Object.keys(result).forEach((key) => { + Object.keys(result).forEach(key => { /* istanbul ignore else */ if (process.env.NODE_ENV !== 'production') { defineReactive(vm, key, result[key], () => { diff --git a/src/core/instance/lifecycle.ts b/src/core/instance/lifecycle.ts index b5deefebbb4..f5915fe193c 100644 --- a/src/core/instance/lifecycle.ts +++ b/src/core/instance/lifecycle.ts @@ -1,13 +1,13 @@ -import config from "../config"; -import Watcher from "../observer/watcher"; -import { mark, measure } from "../util/perf"; -import VNode, { createEmptyVNode } from "../vdom/vnode"; -import { updateComponentListeners } from "./events"; -import { resolveSlots } from "./render-helpers/resolve-slots"; -import { toggleObserving } from "../observer/index"; -import { pushTarget, popTarget } from "../observer/dep"; -import type { Component } from "../../../typescript/component"; -import type { MountedComponentVNode } from "../../../typescript/vnode"; +import config from '../config' +import Watcher from '../observer/watcher' +import { mark, measure } from '../util/perf' +import VNode, { createEmptyVNode } from '../vdom/vnode' +import { updateComponentListeners } from './events' +import { resolveSlots } from './render-helpers/resolve-slots' +import { toggleObserving } from '../observer/index' +import { pushTarget, popTarget } from '../observer/dep' +import type { Component } from '../../../typescript/component' +import type { MountedComponentVNode } from '../../../typescript/vnode' import { warn, @@ -15,127 +15,127 @@ import { remove, emptyObject, validateProp, - invokeWithErrorHandling, -} from "../util/index"; + invokeWithErrorHandling +} from '../util/index' -export let activeInstance: any = null; -export let isUpdatingChildComponent: boolean = false; +export let activeInstance: any = null +export let isUpdatingChildComponent: boolean = false export function setActiveInstance(vm: Component) { - const prevActiveInstance = activeInstance; - activeInstance = vm; + const prevActiveInstance = activeInstance + activeInstance = vm return () => { - activeInstance = prevActiveInstance; - }; + activeInstance = prevActiveInstance + } } export function initLifecycle(vm: Component) { - const options = vm.$options; + const options = vm.$options // locate first non-abstract parent - let parent = options.parent; + let parent = options.parent if (parent && !options.abstract) { while (parent.$options.abstract && parent.$parent) { - parent = parent.$parent; + parent = parent.$parent } - parent.$children.push(vm); + parent.$children.push(vm) } - vm.$parent = parent; - vm.$root = parent ? parent.$root : vm; + vm.$parent = parent + vm.$root = parent ? parent.$root : vm - vm.$children = []; - vm.$refs = {}; + vm.$children = [] + vm.$refs = {} - vm._watcher = null; - vm._inactive = null; - vm._directInactive = false; - vm._isMounted = false; - vm._isDestroyed = false; - vm._isBeingDestroyed = false; + vm._watcher = null + vm._inactive = null + vm._directInactive = false + vm._isMounted = false + vm._isDestroyed = false + vm._isBeingDestroyed = false } export function lifecycleMixin(Vue: Component) { Vue.prototype._update = function (vnode: VNode, hydrating?: boolean) { - const vm: Component = this; - const prevEl = vm.$el; - const prevVnode = vm._vnode; - const restoreActiveInstance = setActiveInstance(vm); - vm._vnode = vnode; + const vm: Component = this + const prevEl = vm.$el + const prevVnode = vm._vnode + const restoreActiveInstance = setActiveInstance(vm) + vm._vnode = vnode // Vue.prototype.__patch__ is injected in entry points // based on the rendering backend used. if (!prevVnode) { // initial render - vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */); + vm.$el = vm.__patch__(vm.$el, vnode, hydrating, false /* removeOnly */) } else { // updates - vm.$el = vm.__patch__(prevVnode, vnode); + vm.$el = vm.__patch__(prevVnode, vnode) } - restoreActiveInstance(); + restoreActiveInstance() // update __vue__ reference if (prevEl) { - prevEl.__vue__ = null; + prevEl.__vue__ = null } if (vm.$el) { - vm.$el.__vue__ = vm; + vm.$el.__vue__ = vm } // if parent is an HOC, update its $el as well if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { - vm.$parent.$el = vm.$el; + vm.$parent.$el = vm.$el } // updated hook is called by the scheduler to ensure that children are // updated in a parent's updated hook. - }; + } Vue.prototype.$forceUpdate = function () { - const vm: Component = this; + const vm: Component = this if (vm._watcher) { - vm._watcher.update(); + vm._watcher.update() } - }; + } Vue.prototype.$destroy = function () { - const vm: Component = this; + const vm: Component = this if (vm._isBeingDestroyed) { - return; + return } - callHook(vm, "beforeDestroy"); - vm._isBeingDestroyed = true; + callHook(vm, 'beforeDestroy') + vm._isBeingDestroyed = true // remove self from parent - const parent = vm.$parent; + const parent = vm.$parent if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { - remove(parent.$children, vm); + remove(parent.$children, vm) } // teardown watchers if (vm._watcher) { - vm._watcher.teardown(); + vm._watcher.teardown() } - let i = vm._watchers.length; + let i = vm._watchers.length while (i--) { - vm._watchers[i].teardown(); + vm._watchers[i].teardown() } // remove reference from data ob // frozen object may not have observer. if (vm._data.__ob__) { - vm._data.__ob__.vmCount--; + vm._data.__ob__.vmCount-- } // call the last hook... - vm._isDestroyed = true; + vm._isDestroyed = true // invoke destroy hooks on current rendered tree - vm.__patch__(vm._vnode, null); + vm.__patch__(vm._vnode, null) // fire destroyed hook - callHook(vm, "destroyed"); + callHook(vm, 'destroyed') // turn off all instance listeners. - vm.$off(); + vm.$off() // remove __vue__ reference if (vm.$el) { - vm.$el.__vue__ = null; + vm.$el.__vue__ = null } // release circular reference (#6759) if (vm.$vnode) { - vm.$vnode.parent = null; + vm.$vnode.parent = null } - }; + } } export function mountComponent( @@ -143,56 +143,56 @@ export function mountComponent( el: Element | null | undefined, hydrating?: boolean ): Component { - vm.$el = el; + vm.$el = el if (!vm.$options.render) { // @ts-expect-error invalid type - vm.$options.render = createEmptyVNode; - if (process.env.NODE_ENV !== "production") { + vm.$options.render = createEmptyVNode + if (process.env.NODE_ENV !== 'production') { /* istanbul ignore if */ if ( - (vm.$options.template && vm.$options.template.charAt(0) !== "#") || + (vm.$options.template && vm.$options.template.charAt(0) !== '#') || vm.$options.el || el ) { warn( - "You are using the runtime-only build of Vue where the template " + - "compiler is not available. Either pre-compile the templates into " + - "render functions, or use the compiler-included build.", + 'You are using the runtime-only build of Vue where the template ' + + 'compiler is not available. Either pre-compile the templates into ' + + 'render functions, or use the compiler-included build.', vm - ); + ) } else { warn( - "Failed to mount component: template or render function not defined.", + 'Failed to mount component: template or render function not defined.', vm - ); + ) } } } - callHook(vm, "beforeMount"); + callHook(vm, 'beforeMount') - let updateComponent; + let updateComponent /* istanbul ignore if */ - if (process.env.NODE_ENV !== "production" && config.performance && mark) { + if (process.env.NODE_ENV !== 'production' && config.performance && mark) { updateComponent = () => { - const name = vm._name; - const id = vm._uid; - const startTag = `vue-perf-start:${id}`; - const endTag = `vue-perf-end:${id}`; - - mark(startTag); - const vnode = vm._render(); - mark(endTag); - measure(`vue ${name} render`, startTag, endTag); - - mark(startTag); - vm._update(vnode, hydrating); - mark(endTag); - measure(`vue ${name} patch`, startTag, endTag); - }; + const name = vm._name + const id = vm._uid + const startTag = `vue-perf-start:${id}` + const endTag = `vue-perf-end:${id}` + + mark(startTag) + const vnode = vm._render() + mark(endTag) + measure(`vue ${name} render`, startTag, endTag) + + mark(startTag) + vm._update(vnode, hydrating) + mark(endTag) + measure(`vue ${name} patch`, startTag, endTag) + } } else { updateComponent = () => { - vm._update(vm._render(), hydrating); - }; + vm._update(vm._render(), hydrating) + } } // we set this to vm._watcher inside the watcher's constructor @@ -205,21 +205,21 @@ export function mountComponent( { before() { if (vm._isMounted && !vm._isDestroyed) { - callHook(vm, "beforeUpdate"); + callHook(vm, 'beforeUpdate') } - }, + } }, true /* isRenderWatcher */ - ); - hydrating = false; + ) + hydrating = false // manually mounted instance, call mounted on self // mounted is called for render-created child components in its inserted hook if (vm.$vnode == null) { - vm._isMounted = true; - callHook(vm, "mounted"); + vm._isMounted = true + callHook(vm, 'mounted') } - return vm; + return vm } export function updateChildComponent( @@ -229,8 +229,8 @@ export function updateChildComponent( parentVnode: MountedComponentVNode, renderChildren?: Array | null ) { - if (process.env.NODE_ENV !== "production") { - isUpdatingChildComponent = true; + if (process.env.NODE_ENV !== 'production') { + isUpdatingChildComponent = true } // determine whether component has slot children @@ -239,14 +239,14 @@ export function updateChildComponent( // check if there are dynamic scopedSlots (hand-written or compiled but with // dynamic slot names). Static scoped slots compiled from template has the // "$stable" marker. - const newScopedSlots = parentVnode.data.scopedSlots; - const oldScopedSlots = vm.$scopedSlots; + const newScopedSlots = parentVnode.data.scopedSlots + const oldScopedSlots = vm.$scopedSlots const hasDynamicScopedSlot = !!( (newScopedSlots && !newScopedSlots.$stable) || (oldScopedSlots !== emptyObject && !oldScopedSlots.$stable) || (newScopedSlots && vm.$scopedSlots.$key !== newScopedSlots.$key) || (!newScopedSlots && vm.$scopedSlots.$key) - ); + ) // Any static slot children from the parent may have changed during parent's // update. Dynamic scoped slots may also have changed. In such cases, a forced @@ -255,108 +255,108 @@ export function updateChildComponent( renderChildren || // has new static slots vm.$options._renderChildren || // has old static slots hasDynamicScopedSlot - ); + ) - vm.$options._parentVnode = parentVnode; - vm.$vnode = parentVnode; // update vm's placeholder node without re-render + vm.$options._parentVnode = parentVnode + vm.$vnode = parentVnode // update vm's placeholder node without re-render if (vm._vnode) { // update child tree's parent - vm._vnode.parent = parentVnode; + vm._vnode.parent = parentVnode } - vm.$options._renderChildren = renderChildren; + vm.$options._renderChildren = renderChildren // update $attrs and $listeners hash // these are also reactive so they may trigger child update if the child // used them during render - vm.$attrs = parentVnode.data.attrs || emptyObject; - vm.$listeners = listeners || emptyObject; + vm.$attrs = parentVnode.data.attrs || emptyObject + vm.$listeners = listeners || emptyObject // update props if (propsData && vm.$options.props) { - toggleObserving(false); - const props = vm._props; - const propKeys = vm.$options._propKeys || []; + toggleObserving(false) + const props = vm._props + const propKeys = vm.$options._propKeys || [] for (let i = 0; i < propKeys.length; i++) { - const key = propKeys[i]; - const propOptions: any = vm.$options.props; // wtf flow? - props[key] = validateProp(key, propOptions, propsData, vm); + const key = propKeys[i] + const propOptions: any = vm.$options.props // wtf flow? + props[key] = validateProp(key, propOptions, propsData, vm) } - toggleObserving(true); + toggleObserving(true) // keep a copy of raw propsData - vm.$options.propsData = propsData; + vm.$options.propsData = propsData } // update listeners - listeners = listeners || emptyObject; - const oldListeners = vm.$options._parentListeners; - vm.$options._parentListeners = listeners; - updateComponentListeners(vm, listeners, oldListeners); + listeners = listeners || emptyObject + const oldListeners = vm.$options._parentListeners + vm.$options._parentListeners = listeners + updateComponentListeners(vm, listeners, oldListeners) // resolve slots + force update if has children if (needsForceUpdate) { - vm.$slots = resolveSlots(renderChildren, parentVnode.context); - vm.$forceUpdate(); + vm.$slots = resolveSlots(renderChildren, parentVnode.context) + vm.$forceUpdate() } - if (process.env.NODE_ENV !== "production") { - isUpdatingChildComponent = false; + if (process.env.NODE_ENV !== 'production') { + isUpdatingChildComponent = false } } function isInInactiveTree(vm) { while (vm && (vm = vm.$parent)) { - if (vm._inactive) return true; + if (vm._inactive) return true } - return false; + return false } export function activateChildComponent(vm: Component, direct?: boolean) { if (direct) { - vm._directInactive = false; + vm._directInactive = false if (isInInactiveTree(vm)) { - return; + return } } else if (vm._directInactive) { - return; + return } if (vm._inactive || vm._inactive === null) { - vm._inactive = false; + vm._inactive = false for (let i = 0; i < vm.$children.length; i++) { - activateChildComponent(vm.$children[i]); + activateChildComponent(vm.$children[i]) } - callHook(vm, "activated"); + callHook(vm, 'activated') } } export function deactivateChildComponent(vm: Component, direct?: boolean) { if (direct) { - vm._directInactive = true; + vm._directInactive = true if (isInInactiveTree(vm)) { - return; + return } } if (!vm._inactive) { - vm._inactive = true; + vm._inactive = true for (let i = 0; i < vm.$children.length; i++) { - deactivateChildComponent(vm.$children[i]); + deactivateChildComponent(vm.$children[i]) } - callHook(vm, "deactivated"); + callHook(vm, 'deactivated') } } export function callHook(vm: Component, hook: string) { // #7573 disable dep collection when invoking lifecycle hooks - pushTarget(); - const handlers = vm.$options[hook]; - const info = `${hook} hook`; + pushTarget() + const handlers = vm.$options[hook] + const info = `${hook} hook` if (handlers) { for (let i = 0, j = handlers.length; i < j; i++) { - invokeWithErrorHandling(handlers[i], vm, null, vm, info); + invokeWithErrorHandling(handlers[i], vm, null, vm, info) } } if (vm._hasHookEvent) { - vm.$emit("hook:" + hook); + vm.$emit('hook:' + hook) } - popTarget(); + popTarget() } diff --git a/src/core/instance/proxy.ts b/src/core/instance/proxy.ts index 33bc30a0312..cba02619984 100644 --- a/src/core/instance/proxy.ts +++ b/src/core/instance/proxy.ts @@ -51,7 +51,7 @@ if (process.env.NODE_ENV !== 'production') { target[key] = value return true } - }, + } }) } @@ -68,7 +68,7 @@ if (process.env.NODE_ENV !== 'production') { else warnNonPresent(target, key) } return has || !isAllowed - }, + } } const getHandler = { @@ -78,7 +78,7 @@ if (process.env.NODE_ENV !== 'production') { else warnNonPresent(target, key) } return target[key] - }, + } } initProxy = function initProxy(vm) { diff --git a/src/core/instance/render-helpers/bind-dynamic-keys.ts b/src/core/instance/render-helpers/bind-dynamic-keys.ts index 455b9647588..2f1de7e76ed 100644 --- a/src/core/instance/render-helpers/bind-dynamic-keys.ts +++ b/src/core/instance/render-helpers/bind-dynamic-keys.ts @@ -1,4 +1,3 @@ - // helper to process dynamic keys for dynamic arguments in v-bind and v-on. // For example, the following template: // diff --git a/src/core/instance/render-helpers/bind-object-listeners.ts b/src/core/instance/render-helpers/bind-object-listeners.ts index 648f01b6d76..b4d2417f620 100644 --- a/src/core/instance/render-helpers/bind-object-listeners.ts +++ b/src/core/instance/render-helpers/bind-object-listeners.ts @@ -1,4 +1,3 @@ - import { warn, extend, isPlainObject } from 'core/util/index' import type { VNodeData } from 'typescript/vnode' diff --git a/src/core/instance/render-helpers/bind-object-props.ts b/src/core/instance/render-helpers/bind-object-props.ts index eaf4219a932..9050cd8c694 100644 --- a/src/core/instance/render-helpers/bind-object-props.ts +++ b/src/core/instance/render-helpers/bind-object-props.ts @@ -1,4 +1,3 @@ - import config from 'core/config' import { @@ -7,7 +6,7 @@ import { toObject, isReservedAttribute, camelize, - hyphenate, + hyphenate } from 'core/util/index' import type { VNodeData } from 'typescript/vnode' diff --git a/src/core/instance/render-helpers/check-keycodes.ts b/src/core/instance/render-helpers/check-keycodes.ts index 92ddec6c832..0f58b54d55b 100644 --- a/src/core/instance/render-helpers/check-keycodes.ts +++ b/src/core/instance/render-helpers/check-keycodes.ts @@ -1,4 +1,3 @@ - import config from 'core/config' import { hyphenate } from 'shared/util' diff --git a/src/core/instance/render-helpers/index.ts b/src/core/instance/render-helpers/index.ts index 480e8d9a00f..27ea60e9c8e 100644 --- a/src/core/instance/render-helpers/index.ts +++ b/src/core/instance/render-helpers/index.ts @@ -1,4 +1,3 @@ - import { toNumber, toString, looseEqual, looseIndexOf } from 'shared/util' import { createTextVNode, createEmptyVNode } from 'core/vdom/vnode' import { renderList } from './render-list' diff --git a/src/core/instance/render-helpers/render-list.ts b/src/core/instance/render-helpers/render-list.ts index cc8a800eb3a..8f7f6ed9e28 100644 --- a/src/core/instance/render-helpers/render-list.ts +++ b/src/core/instance/render-helpers/render-list.ts @@ -44,6 +44,6 @@ export function renderList( if (!isDef(ret)) { ret = [] } - (ret as any)._isVList = true + ;(ret as any)._isVList = true return ret } diff --git a/src/core/instance/render-helpers/render-slot.ts b/src/core/instance/render-helpers/render-slot.ts index 439ae0aafc7..f2c82a7a744 100644 --- a/src/core/instance/render-helpers/render-slot.ts +++ b/src/core/instance/render-helpers/render-slot.ts @@ -1,5 +1,5 @@ -import { extend, warn, isObject } from "core/util/index"; -import VNode from "core/vdom/vnode"; +import { extend, warn, isObject } from 'core/util/index' +import VNode from 'core/vdom/vnode' /** * Runtime helper for rendering @@ -10,34 +10,30 @@ export function renderSlot( props: Record | null, bindObject: object | null ): Array | null { - const scopedSlotFn = this.$scopedSlots[name]; - let nodes; + const scopedSlotFn = this.$scopedSlots[name] + let nodes if (scopedSlotFn) { // scoped slot - props = props || {}; + props = props || {} if (bindObject) { - if (process.env.NODE_ENV !== "production" && !isObject(bindObject)) { - warn("slot v-bind without argument expects an Object", this); + if (process.env.NODE_ENV !== 'production' && !isObject(bindObject)) { + warn('slot v-bind without argument expects an Object', this) } - props = extend(extend({}, bindObject), props); + props = extend(extend({}, bindObject), props) } nodes = scopedSlotFn(props) || - (typeof fallbackRender === "function" - ? fallbackRender() - : fallbackRender); + (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender) } else { nodes = this.$slots[name] || - (typeof fallbackRender === "function" - ? fallbackRender() - : fallbackRender); + (typeof fallbackRender === 'function' ? fallbackRender() : fallbackRender) } - const target = props && props.slot; + const target = props && props.slot if (target) { - return this.$createElement("template", { slot: target }, nodes); + return this.$createElement('template', { slot: target }, nodes) } else { - return nodes; + return nodes } } diff --git a/src/core/instance/render-helpers/resolve-scoped-slots.ts b/src/core/instance/render-helpers/resolve-scoped-slots.ts index 0b7869546ae..c5bd2903316 100644 --- a/src/core/instance/render-helpers/resolve-scoped-slots.ts +++ b/src/core/instance/render-helpers/resolve-scoped-slots.ts @@ -23,7 +23,7 @@ export function resolveScopedSlots( } } if (contentHashKey) { - (res as any).$key = contentHashKey + ;(res as any).$key = contentHashKey } return res as any } diff --git a/src/core/instance/render-helpers/resolve-slots.ts b/src/core/instance/render-helpers/resolve-slots.ts index 17f79c158c4..e664004f94b 100644 --- a/src/core/instance/render-helpers/resolve-slots.ts +++ b/src/core/instance/render-helpers/resolve-slots.ts @@ -1,4 +1,3 @@ - import type VNode from 'core/vdom/vnode' import type { Component } from 'typescript/component' @@ -35,7 +34,7 @@ export function resolveSlots( slot.push(child) } } else { - (slots.default || (slots.default = [])).push(child) + ;(slots.default || (slots.default = [])).push(child) } } // ignore slots that contains only whitespace diff --git a/src/core/instance/render.ts b/src/core/instance/render.ts index 39c3b359206..4696399d57e 100644 --- a/src/core/instance/render.ts +++ b/src/core/instance/render.ts @@ -1,10 +1,9 @@ - import { warn, nextTick, emptyObject, handleError, - defineReactive, + defineReactive } from '../util/index' import { createElement } from '../vdom/create-element' @@ -21,7 +20,7 @@ export function initRender(vm: Component) { vm._staticTrees = null // v-once cached trees const options = vm.$options const parentVnode = (vm.$vnode = options._parentVnode!) // the placeholder node in parent tree - const renderContext = parentVnode && parentVnode.context as Component + const renderContext = parentVnode && (parentVnode.context as Component) vm.$slots = resolveSlots(options._renderChildren, renderContext) vm.$scopedSlots = emptyObject // bind the createElement fn to this instance @@ -127,7 +126,7 @@ export function renderMixin(Vue: Component) { vm.$createElement, e ) - } catch (e:any) { + } catch (e: any) { handleError(e, vm, `renderError`) vnode = vm._vnode } diff --git a/src/core/instance/state.ts b/src/core/instance/state.ts index 22b8bda1ae6..2f91f1bf2c9 100644 --- a/src/core/instance/state.ts +++ b/src/core/instance/state.ts @@ -1,15 +1,15 @@ -import config from "../config"; -import Watcher from "../observer/watcher"; -import Dep, { pushTarget, popTarget } from "../observer/dep"; -import { isUpdatingChildComponent } from "./lifecycle"; +import config from '../config' +import Watcher from '../observer/watcher' +import Dep, { pushTarget, popTarget } from '../observer/dep' +import { isUpdatingChildComponent } from './lifecycle' import { set, del, observe, defineReactive, - toggleObserving, -} from "../observer/index"; + toggleObserving +} from '../observer/index' import { warn, @@ -24,60 +24,60 @@ import { isPlainObject, isServerRendering, isReservedAttribute, - invokeWithErrorHandling, -} from "../util/index"; -import type { Component } from "../../../typescript/component"; + invokeWithErrorHandling +} from '../util/index' +import type { Component } from '../../../typescript/component' const sharedPropertyDefinition = { enumerable: true, configurable: true, get: noop, - set: noop, -}; + set: noop +} export function proxy(target: Object, sourceKey: string, key: string) { sharedPropertyDefinition.get = function proxyGetter() { - return this[sourceKey][key]; - }; + return this[sourceKey][key] + } sharedPropertyDefinition.set = function proxySetter(val) { - this[sourceKey][key] = val; - }; - Object.defineProperty(target, key, sharedPropertyDefinition); + this[sourceKey][key] = val + } + Object.defineProperty(target, key, sharedPropertyDefinition) } export function initState(vm: Component) { - vm._watchers = []; - const opts = vm.$options; - if (opts.props) initProps(vm, opts.props); - if (opts.methods) initMethods(vm, opts.methods); + vm._watchers = [] + const opts = vm.$options + if (opts.props) initProps(vm, opts.props) + if (opts.methods) initMethods(vm, opts.methods) if (opts.data) { - initData(vm); + initData(vm) } else { - observe((vm._data = {}), true /* asRootData */); + observe((vm._data = {}), true /* asRootData */) } - if (opts.computed) initComputed(vm, opts.computed); + if (opts.computed) initComputed(vm, opts.computed) if (opts.watch && opts.watch !== nativeWatch) { - initWatch(vm, opts.watch); + initWatch(vm, opts.watch) } } function initProps(vm: Component, propsOptions: Object) { - const propsData = vm.$options.propsData || {}; - const props = (vm._props = {}); + const propsData = vm.$options.propsData || {} + const props = (vm._props = {}) // cache prop keys so that future props updates can iterate using Array // instead of dynamic object key enumeration. - const keys: string[] = (vm.$options._propKeys = []); - const isRoot = !vm.$parent; + const keys: string[] = (vm.$options._propKeys = []) + const isRoot = !vm.$parent // root instance props should be converted if (!isRoot) { - toggleObserving(false); + toggleObserving(false) } for (const key in propsOptions) { - keys.push(key); - const value = validateProp(key, propsOptions, propsData, vm); + keys.push(key) + const value = validateProp(key, propsOptions, propsData, vm) /* istanbul ignore else */ - if (process.env.NODE_ENV !== "production") { - const hyphenatedKey = hyphenate(key); + if (process.env.NODE_ENV !== 'production') { + const hyphenatedKey = hyphenate(key) if ( isReservedAttribute(hyphenatedKey) || config.isReservedAttr(hyphenatedKey) @@ -85,7 +85,7 @@ function initProps(vm: Component, propsOptions: Object) { warn( `"${hyphenatedKey}" is a reserved attribute and cannot be used as component prop.`, vm - ); + ) } defineReactive(props, key, value, () => { if (!isRoot && !isUpdatingChildComponent) { @@ -95,90 +95,87 @@ function initProps(vm: Component, propsOptions: Object) { `Instead, use a data or computed property based on the prop's ` + `value. Prop being mutated: "${key}"`, vm - ); + ) } - }); + }) } else { - defineReactive(props, key, value); + defineReactive(props, key, value) } // static props are already proxied on the component's prototype // during Vue.extend(). We only need to proxy props defined at // instantiation here. if (!(key in vm)) { - proxy(vm, `_props`, key); + proxy(vm, `_props`, key) } } - toggleObserving(true); + toggleObserving(true) } function initData(vm: Component) { - let data: any = vm.$options.data; - data = vm._data = typeof data === "function" ? getData(data, vm) : data || {}; + let data: any = vm.$options.data + data = vm._data = typeof data === 'function' ? getData(data, vm) : data || {} if (!isPlainObject(data)) { - data = {}; - process.env.NODE_ENV !== "production" && + data = {} + process.env.NODE_ENV !== 'production' && warn( - "data functions should return an object:\n" + - "https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function", + 'data functions should return an object:\n' + + 'https://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function', vm - ); + ) } // proxy data on instance - const keys = Object.keys(data); - const props = vm.$options.props; - const methods = vm.$options.methods; - let i = keys.length; + const keys = Object.keys(data) + const props = vm.$options.props + const methods = vm.$options.methods + let i = keys.length while (i--) { - const key = keys[i]; - if (process.env.NODE_ENV !== "production") { + const key = keys[i] + if (process.env.NODE_ENV !== 'production') { if (methods && hasOwn(methods, key)) { - warn( - `Method "${key}" has already been defined as a data property.`, - vm - ); + warn(`Method "${key}" has already been defined as a data property.`, vm) } } if (props && hasOwn(props, key)) { - process.env.NODE_ENV !== "production" && + process.env.NODE_ENV !== 'production' && warn( `The data property "${key}" is already declared as a prop. ` + `Use prop default value instead.`, vm - ); + ) } else if (!isReserved(key)) { - proxy(vm, `_data`, key); + proxy(vm, `_data`, key) } } // observe data - observe(data, true /* asRootData */); + observe(data, true /* asRootData */) } export function getData(data: Function, vm: Component): any { // #7573 disable dep collection when invoking data getters - pushTarget(); + pushTarget() try { - return data.call(vm, vm); + return data.call(vm, vm) } catch (e: any) { - handleError(e, vm, `data()`); - return {}; + handleError(e, vm, `data()`) + return {} } finally { - popTarget(); + popTarget() } } -const computedWatcherOptions = { lazy: true }; +const computedWatcherOptions = { lazy: true } function initComputed(vm: Component, computed: Object) { // $flow-disable-line - const watchers = (vm._computedWatchers = Object.create(null)); + const watchers = (vm._computedWatchers = Object.create(null)) // computed properties are just getters during SSR - const isSSR = isServerRendering(); + const isSSR = isServerRendering() for (const key in computed) { - const userDef = computed[key]; - const getter = typeof userDef === "function" ? userDef : userDef.get; - if (process.env.NODE_ENV !== "production" && getter == null) { - warn(`Getter is missing for computed property "${key}".`, vm); + const userDef = computed[key] + const getter = typeof userDef === 'function' ? userDef : userDef.get + if (process.env.NODE_ENV !== 'production' && getter == null) { + warn(`Getter is missing for computed property "${key}".`, vm) } if (!isSSR) { @@ -188,27 +185,24 @@ function initComputed(vm: Component, computed: Object) { getter || noop, noop, computedWatcherOptions - ); + ) } // component-defined computed properties are already defined on the // component prototype. We only need to define computed properties defined // at instantiation here. if (!(key in vm)) { - defineComputed(vm, key, userDef); - } else if (process.env.NODE_ENV !== "production") { + defineComputed(vm, key, userDef) + } else if (process.env.NODE_ENV !== 'production') { if (key in vm.$data) { - warn(`The computed property "${key}" is already defined in data.`, vm); + warn(`The computed property "${key}" is already defined in data.`, vm) } else if (vm.$options.props && key in vm.$options.props) { - warn( - `The computed property "${key}" is already defined as a prop.`, - vm - ); + warn(`The computed property "${key}" is already defined as a prop.`, vm) } else if (vm.$options.methods && key in vm.$options.methods) { warn( `The computed property "${key}" is already defined as a method.`, vm - ); + ) } } } @@ -219,92 +213,91 @@ export function defineComputed( key: string, userDef: Record | Function ) { - const shouldCache = !isServerRendering(); - if (typeof userDef === "function") { + const shouldCache = !isServerRendering() + if (typeof userDef === 'function') { sharedPropertyDefinition.get = shouldCache ? createComputedGetter(key) - : createGetterInvoker(userDef); - sharedPropertyDefinition.set = noop; + : createGetterInvoker(userDef) + sharedPropertyDefinition.set = noop } else { sharedPropertyDefinition.get = userDef.get ? shouldCache && userDef.cache !== false ? createComputedGetter(key) : createGetterInvoker(userDef.get) - : noop; - sharedPropertyDefinition.set = userDef.set || noop; + : noop + sharedPropertyDefinition.set = userDef.set || noop } if ( - process.env.NODE_ENV !== "production" && + process.env.NODE_ENV !== 'production' && sharedPropertyDefinition.set === noop ) { sharedPropertyDefinition.set = function () { warn( `Computed property "${key}" was assigned to but it has no setter.`, this - ); - }; + ) + } } - Object.defineProperty(target, key, sharedPropertyDefinition); + Object.defineProperty(target, key, sharedPropertyDefinition) } function createComputedGetter(key) { return function computedGetter() { - const watcher = this._computedWatchers && this._computedWatchers[key]; + const watcher = this._computedWatchers && this._computedWatchers[key] if (watcher) { if (watcher.dirty) { - watcher.evaluate(); + watcher.evaluate() } if (Dep.target) { - watcher.depend(); + watcher.depend() } - return watcher.value; + return watcher.value } - }; + } } function createGetterInvoker(fn) { return function computedGetter() { - return fn.call(this, this); - }; + return fn.call(this, this) + } } function initMethods(vm: Component, methods: Object) { - const props = vm.$options.props; + const props = vm.$options.props for (const key in methods) { - if (process.env.NODE_ENV !== "production") { - if (typeof methods[key] !== "function") { + if (process.env.NODE_ENV !== 'production') { + if (typeof methods[key] !== 'function') { warn( `Method "${key}" has type "${typeof methods[ key ]}" in the component definition. ` + `Did you reference the function correctly?`, vm - ); + ) } if (props && hasOwn(props, key)) { - warn(`Method "${key}" has already been defined as a prop.`, vm); + warn(`Method "${key}" has already been defined as a prop.`, vm) } if (key in vm && isReserved(key)) { warn( `Method "${key}" conflicts with an existing Vue instance method. ` + `Avoid defining component methods that start with _ or $.` - ); + ) } } - vm[key] = - typeof methods[key] !== "function" ? noop : bind(methods[key], vm); + vm[key] = typeof methods[key] !== 'function' ? noop : bind(methods[key], vm) } } function initWatch(vm: Component, watch: Object) { for (const key in watch) { - const handler = watch[key]; + const handler = watch[key] if (Array.isArray(handler)) { for (let i = 0; i < handler.length; i++) { - createWatcher(vm, key, handler[i]); + createWatcher(vm, key, handler[i]) } } else { - createWatcher(vm, key, handler); + createWatcher(vm, key, handler) } } } @@ -316,65 +309,65 @@ function createWatcher( options?: Object ) { if (isPlainObject(handler)) { - options = handler; - handler = handler.handler; + options = handler + handler = handler.handler } - if (typeof handler === "string") { - handler = vm[handler]; + if (typeof handler === 'string') { + handler = vm[handler] } - return vm.$watch(expOrFn, handler, options); + return vm.$watch(expOrFn, handler, options) } export function stateMixin(Vue: Component) { // flow somehow has problems with directly declared definition object // when using Object.defineProperty, so we have to procedurally build up // the object here. - const dataDef: any = {}; + const dataDef: any = {} dataDef.get = function () { - return this._data; - }; - const propsDef: any = {}; + return this._data + } + const propsDef: any = {} propsDef.get = function () { - return this._props; - }; - if (process.env.NODE_ENV !== "production") { + return this._props + } + if (process.env.NODE_ENV !== 'production') { dataDef.set = function () { warn( - "Avoid replacing instance root $data. " + - "Use nested data properties instead.", + 'Avoid replacing instance root $data. ' + + 'Use nested data properties instead.', this - ); - }; + ) + } propsDef.set = function () { - warn(`$props is readonly.`, this); - }; + warn(`$props is readonly.`, this) + } } - Object.defineProperty(Vue.prototype, "$data", dataDef); - Object.defineProperty(Vue.prototype, "$props", propsDef); + Object.defineProperty(Vue.prototype, '$data', dataDef) + Object.defineProperty(Vue.prototype, '$props', propsDef) - Vue.prototype.$set = set; - Vue.prototype.$delete = del; + Vue.prototype.$set = set + Vue.prototype.$delete = del Vue.prototype.$watch = function ( expOrFn: string | Function, cb: any, options?: Record ): Function { - const vm: Component = this; + const vm: Component = this if (isPlainObject(cb)) { - return createWatcher(vm, expOrFn, cb, options); + return createWatcher(vm, expOrFn, cb, options) } - options = options || {}; - options.user = true; - const watcher = new Watcher(vm, expOrFn, cb, options); + options = options || {} + options.user = true + const watcher = new Watcher(vm, expOrFn, cb, options) if (options.immediate) { - const info = `callback for immediate watcher "${watcher.expression}"`; - pushTarget(); - invokeWithErrorHandling(cb, vm, [watcher.value], vm, info); - popTarget(); + const info = `callback for immediate watcher "${watcher.expression}"` + pushTarget() + invokeWithErrorHandling(cb, vm, [watcher.value], vm, info) + popTarget() } return function unwatchFn() { - watcher.teardown(); - }; - }; + watcher.teardown() + } + } } diff --git a/src/core/observer/array.ts b/src/core/observer/array.ts index 1a59b511e24..c043d9dfe76 100644 --- a/src/core/observer/array.ts +++ b/src/core/observer/array.ts @@ -15,7 +15,7 @@ const methodsToPatch = [ 'unshift', 'splice', 'sort', - 'reverse', + 'reverse' ] /** diff --git a/src/core/observer/index.ts b/src/core/observer/index.ts index fca48d1ac74..f8bb1fa62a0 100644 --- a/src/core/observer/index.ts +++ b/src/core/observer/index.ts @@ -11,7 +11,7 @@ import { isPrimitive, isUndef, isValidArrayIndex, - isServerRendering, + isServerRendering } from '../util/index' const arrayKeys = Object.getOwnPropertyNames(arrayMethods) @@ -187,7 +187,7 @@ export function defineReactive( } childOb = !shallow && observe(newVal) dep.notify() - }, + } }) } @@ -196,7 +196,11 @@ export function defineReactive( * triggers change notification if the property doesn't * already exist. */ -export function set(target: Array | Record, key: any, val: any): any { +export function set( + target: Array | Record, + key: any, + val: any +): any { if ( process.env.NODE_ENV !== 'production' && (isUndef(target) || isPrimitive(target)) diff --git a/src/core/observer/scheduler.ts b/src/core/observer/scheduler.ts index efeaec64c0e..3c2d0b7ea4a 100644 --- a/src/core/observer/scheduler.ts +++ b/src/core/observer/scheduler.ts @@ -1,4 +1,3 @@ - import type Watcher from './watcher' import config from '../config' import { callHook, activateChildComponent } from '../instance/lifecycle' diff --git a/src/core/observer/traverse.ts b/src/core/observer/traverse.ts index c52efe0ac89..14eca535bd9 100644 --- a/src/core/observer/traverse.ts +++ b/src/core/observer/traverse.ts @@ -1,4 +1,3 @@ - import { _Set as Set, isObject } from '../util/index' import type { SimpleSet } from '../util/index' import VNode from '../vdom/vnode' diff --git a/src/core/observer/watcher.ts b/src/core/observer/watcher.ts index 5543d6d1e71..f5539372bfe 100644 --- a/src/core/observer/watcher.ts +++ b/src/core/observer/watcher.ts @@ -1,4 +1,3 @@ - import { warn, remove, @@ -79,9 +78,8 @@ export default class Watcher { this.newDeps = [] this.depIds = new Set() this.newDepIds = new Set() - this.expression = process.env.NODE_ENV !== 'production' - ? expOrFn.toString() - : '' + this.expression = + process.env.NODE_ENV !== 'production' ? expOrFn.toString() : '' // parse expression for getter if (typeof expOrFn === 'function') { this.getter = expOrFn @@ -89,17 +87,16 @@ export default class Watcher { this.getter = parsePath(expOrFn) if (!this.getter) { this.getter = noop - process.env.NODE_ENV !== 'production' && warn( - `Failed watching path: "${expOrFn}" ` + - 'Watcher only accepts simple dot-delimited paths. ' + - 'For full control, use a function instead.', - vm - ) + process.env.NODE_ENV !== 'production' && + warn( + `Failed watching path: "${expOrFn}" ` + + 'Watcher only accepts simple dot-delimited paths. ' + + 'For full control, use a function instead.', + vm + ) } } - this.value = this.lazy - ? undefined - : this.get() + this.value = this.lazy ? undefined : this.get() } /** @@ -199,7 +196,13 @@ export default class Watcher { this.value = value if (this.user) { const info = `callback for watcher "${this.expression}"` - invokeWithErrorHandling(this.cb, this.vm, [value, oldValue], this.vm, info) + invokeWithErrorHandling( + this.cb, + this.vm, + [value, oldValue], + this.vm, + info + ) } else { this.cb.call(this.vm, value, oldValue) } diff --git a/src/core/util/debug.ts b/src/core/util/debug.ts index ec42241abd2..f44fe86a277 100644 --- a/src/core/util/debug.ts +++ b/src/core/util/debug.ts @@ -1,4 +1,3 @@ - import config from '../config' import { noop } from 'shared/util' import type { Component } from 'typescript/component' @@ -11,8 +10,8 @@ export let formatComponentName: (vm: Component, includeFile?: false) => string if (process.env.NODE_ENV !== 'production') { const hasConsole = typeof console !== 'undefined' const classifyRE = /(?:^|[-_])(\w)/g - const classify = (str) => - str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, '') + const classify = str => + str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '') warn = (msg, vm) => { const trace = vm ? generateComponentTrace(vm) : '' diff --git a/src/core/util/error.ts b/src/core/util/error.ts index 0aa9f6a8172..093e8731469 100644 --- a/src/core/util/error.ts +++ b/src/core/util/error.ts @@ -42,7 +42,7 @@ export function invokeWithErrorHandling( try { res = args ? handler.apply(context, args) : handler.call(context) if (res && !res._isVue && isPromise(res) && !res._handled) { - res.catch((e) => handleError(e, vm, info + ` (Promise/async)`)) + res.catch(e => handleError(e, vm, info + ` (Promise/async)`)) // issue #9511 // avoid catch triggering multiple times when nested calls res._handled = true diff --git a/src/core/util/index.ts b/src/core/util/index.ts index af73de55cb0..c47b8dbe937 100644 --- a/src/core/util/index.ts +++ b/src/core/util/index.ts @@ -1,4 +1,3 @@ - export * from 'shared/util' export * from './lang' export * from './env' diff --git a/src/core/util/lang.ts b/src/core/util/lang.ts index 2f49594b0b1..1d332f66027 100644 --- a/src/core/util/lang.ts +++ b/src/core/util/lang.ts @@ -1,10 +1,10 @@ - /** * unicode letters used for parsing html tags, component names and property paths. * using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname * skipping \u10000-\uEFFFF due to it freezing up PhantomJS */ -export const unicodeRegExp = /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/ +export const unicodeRegExp = + /a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/ /** * Check if a string starts with $ or _ @@ -22,7 +22,7 @@ export function def(obj: Object, key: string, val: any, enumerable?: boolean) { value: val, enumerable: !!enumerable, writable: true, - configurable: true, + configurable: true }) } diff --git a/src/core/util/next-tick.ts b/src/core/util/next-tick.ts index 0bff7f44ed6..5d4670d2f75 100644 --- a/src/core/util/next-tick.ts +++ b/src/core/util/next-tick.ts @@ -64,7 +64,7 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) { const observer = new MutationObserver(flushCallbacks) const textNode = document.createTextNode(String(counter)) observer.observe(textNode, { - characterData: true, + characterData: true }) timerFunc = () => { counter = (counter + 1) % 2 @@ -104,7 +104,7 @@ export function nextTick(cb?: Function, ctx?: Object) { } // $flow-disable-line if (!cb && typeof Promise !== 'undefined') { - return new Promise((resolve) => { + return new Promise(resolve => { _resolve = resolve }) } diff --git a/src/core/util/options.ts b/src/core/util/options.ts index aeb2eaf2bbe..2850ad26edc 100644 --- a/src/core/util/options.ts +++ b/src/core/util/options.ts @@ -1,4 +1,3 @@ - import config from '../config' import { warn } from './debug' import { set } from '../observer/index' @@ -14,7 +13,7 @@ import { toRawType, capitalize, isBuiltInTag, - isPlainObject, + isPlainObject } from 'shared/util' import type { Component } from 'typescript/component' import type { ComponentOptions } from 'typescript/options' @@ -172,7 +171,7 @@ function dedupeHooks(hooks: any) { return res } -LIFECYCLE_HOOKS.forEach((hook) => { +LIFECYCLE_HOOKS.forEach(hook => { strats[hook] = mergeHook }) @@ -245,21 +244,25 @@ strats.watch = function ( /** * Other object hashes. */ -strats.props = strats.methods = strats.inject = strats.computed = function ( - parentVal: Object | null, - childVal: Object | null, - vm: Component | null, - key: string -): Object | null { - if (childVal && process.env.NODE_ENV !== 'production') { - assertObjectType(key, childVal, vm) - } - if (!parentVal) return childVal - const ret = Object.create(null) - extend(ret, parentVal) - if (childVal) extend(ret, childVal) - return ret -} +strats.props = + strats.methods = + strats.inject = + strats.computed = + function ( + parentVal: Object | null, + childVal: Object | null, + vm: Component | null, + key: string + ): Object | null { + if (childVal && process.env.NODE_ENV !== 'production') { + assertObjectType(key, childVal, vm) + } + if (!parentVal) return childVal + const ret = Object.create(null) + extend(ret, parentVal) + if (childVal) extend(ret, childVal) + return ret + } strats.provide = mergeDataOrFn /** diff --git a/src/core/util/perf.ts b/src/core/util/perf.ts index f8201ddb6ec..c0c8a277633 100644 --- a/src/core/util/perf.ts +++ b/src/core/util/perf.ts @@ -13,7 +13,7 @@ if (process.env.NODE_ENV !== 'production') { perf.clearMarks && perf.clearMeasures ) { - mark = (tag) => perf.mark(tag) + mark = tag => perf.mark(tag) measure = (name, startTag, endTag) => { perf.measure(name, startTag, endTag) perf.clearMarks(startTag) diff --git a/src/core/util/props.ts b/src/core/util/props.ts index e25b47720dc..168d133b76f 100644 --- a/src/core/util/props.ts +++ b/src/core/util/props.ts @@ -128,7 +128,7 @@ function assertProp( } } - const haveExpectedTypes = expectedTypes.some((t) => t) + const haveExpectedTypes = expectedTypes.some(t => t) if (!valid && haveExpectedTypes) { warn(getInvalidTypeMessage(name, value, expectedTypes), vm) return @@ -244,9 +244,9 @@ function styleValue(value, type) { const EXPLICABLE_TYPES = ['string', 'number', 'boolean'] function isExplicable(value) { - return EXPLICABLE_TYPES.some((elem) => value.toLowerCase() === elem) + return EXPLICABLE_TYPES.some(elem => value.toLowerCase() === elem) } function isBoolean(...args) { - return args.some((elem) => elem.toLowerCase() === 'boolean') + return args.some(elem => elem.toLowerCase() === 'boolean') } diff --git a/src/core/vdom/create-component.ts b/src/core/vdom/create-component.ts index 3958217cb0d..d35cd266173 100644 --- a/src/core/vdom/create-component.ts +++ b/src/core/vdom/create-component.ts @@ -1,4 +1,3 @@ - import VNode from './vnode' import { resolveConstructorOptions } from 'core/instance/init' import { queueActivatedComponent } from 'core/observer/scheduler' @@ -9,7 +8,7 @@ import { warn, isDef, isUndef, isTrue, isObject } from '../util/index' import { resolveAsyncComponent, createAsyncPlaceholder, - extractPropsFromVNodeData, + extractPropsFromVNodeData } from './helpers/index' import { @@ -17,13 +16,13 @@ import { activeInstance, updateChildComponent, activateChildComponent, - deactivateChildComponent, + deactivateChildComponent } from '../instance/lifecycle' import type { MountedComponentVNode, VNodeData, - VNodeWithData, + VNodeWithData } from 'typescript/vnode' import type { Component } from 'typescript/component' import type { InternalComponentOptions } from 'typescript/options' @@ -89,7 +88,7 @@ const componentVNodeHooks = { deactivateChildComponent(componentInstance, true /* direct */) } } - }, + } } const hooksToMerge = Object.keys(componentVNodeHooks) @@ -214,7 +213,7 @@ export function createComponentInstanceForVnode( const options: InternalComponentOptions = { _isComponent: true, _parentVnode: vnode, - parent, + parent } // check inline-template render functions const inlineTemplate = vnode.data.inlineTemplate diff --git a/src/core/vdom/create-functional-component.ts b/src/core/vdom/create-functional-component.ts index 99915b764de..b5700949353 100644 --- a/src/core/vdom/create-functional-component.ts +++ b/src/core/vdom/create-functional-component.ts @@ -1,4 +1,3 @@ - import VNode, { cloneVNode } from './vnode' import { createElement } from './create-element' import { resolveInject } from '../instance/inject' @@ -13,7 +12,7 @@ import { hasOwn, camelize, emptyObject, - validateProp, + validateProp } from '../util/index' import type { Component } from 'typescript/component' import type { VNodeData } from 'typescript/vnode' @@ -64,7 +63,7 @@ export function FunctionalRenderContext( enumerable: true, get() { return normalizeScopedSlots(data.scopedSlots, this.slots()) - }, + } } as any) // support for compiled functional template @@ -160,10 +159,11 @@ function cloneAndMarkFunctionalResult( clone.fnContext = contextVm clone.fnOptions = options if (process.env.NODE_ENV !== 'production') { - (clone.devtoolsMeta = clone.devtoolsMeta || {} as any).renderContext = renderContext + ;(clone.devtoolsMeta = clone.devtoolsMeta || ({} as any)).renderContext = + renderContext } if (data.slot) { - (clone.data || (clone.data = {})).slot = data.slot + ;(clone.data || (clone.data = {})).slot = data.slot } return clone } diff --git a/src/core/vdom/helpers/extract-props.ts b/src/core/vdom/helpers/extract-props.ts index 6a03bc4b73c..b68107df5f0 100644 --- a/src/core/vdom/helpers/extract-props.ts +++ b/src/core/vdom/helpers/extract-props.ts @@ -1,11 +1,10 @@ - import { tip, hasOwn, isDef, isUndef, hyphenate, - formatComponentName, + formatComponentName } from 'core/util/index' import type { Component } from 'typescript/component' import type { VNodeData } from 'typescript/vnode' diff --git a/src/core/vdom/helpers/get-first-component-child.ts b/src/core/vdom/helpers/get-first-component-child.ts index 23a8433ed35..ea3c7ec4e37 100644 --- a/src/core/vdom/helpers/get-first-component-child.ts +++ b/src/core/vdom/helpers/get-first-component-child.ts @@ -1,4 +1,3 @@ - import { isDef } from 'shared/util' import VNode from '../vnode' import { isAsyncPlaceholder } from './is-async-placeholder' diff --git a/src/core/vdom/helpers/index.ts b/src/core/vdom/helpers/index.ts index 50d719e8537..12a72ee848b 100644 --- a/src/core/vdom/helpers/index.ts +++ b/src/core/vdom/helpers/index.ts @@ -1,4 +1,3 @@ - export * from './merge-hook' export * from './extract-props' export * from './update-listeners' diff --git a/src/core/vdom/helpers/is-async-placeholder.ts b/src/core/vdom/helpers/is-async-placeholder.ts index fe2e12b8a9f..6e0d602758b 100644 --- a/src/core/vdom/helpers/is-async-placeholder.ts +++ b/src/core/vdom/helpers/is-async-placeholder.ts @@ -1,4 +1,3 @@ - import VNode from '../vnode' export function isAsyncPlaceholder(node: VNode): boolean { diff --git a/src/core/vdom/helpers/merge-hook.ts b/src/core/vdom/helpers/merge-hook.ts index 6c846653126..6881f914170 100644 --- a/src/core/vdom/helpers/merge-hook.ts +++ b/src/core/vdom/helpers/merge-hook.ts @@ -1,4 +1,3 @@ - import VNode from '../vnode' import { createFnInvoker } from './update-listeners' import { remove, isDef, isUndef, isTrue } from 'shared/util' diff --git a/src/core/vdom/helpers/normalize-children.ts b/src/core/vdom/helpers/normalize-children.ts index b9bb12dd8f5..521bb9cc120 100644 --- a/src/core/vdom/helpers/normalize-children.ts +++ b/src/core/vdom/helpers/normalize-children.ts @@ -1,4 +1,3 @@ - import VNode, { createTextVNode } from 'core/vdom/vnode' import { isFalse, isTrue, isDef, isUndef, isPrimitive } from 'shared/util' diff --git a/src/core/vdom/helpers/normalize-scoped-slots.ts b/src/core/vdom/helpers/normalize-scoped-slots.ts index ecba4d691d8..afc5299a342 100644 --- a/src/core/vdom/helpers/normalize-scoped-slots.ts +++ b/src/core/vdom/helpers/normalize-scoped-slots.ts @@ -1,23 +1,23 @@ -import { def } from "core/util/lang"; -import { normalizeChildren } from "core/vdom/helpers/normalize-children"; -import { emptyObject } from "shared/util"; -import { isAsyncPlaceholder } from "./is-async-placeholder"; -import type VNode from "../vnode"; +import { def } from 'core/util/lang' +import { normalizeChildren } from 'core/vdom/helpers/normalize-children' +import { emptyObject } from 'shared/util' +import { isAsyncPlaceholder } from './is-async-placeholder' +import type VNode from '../vnode' export function normalizeScopedSlots( slots: { [key: string]: Function } | void, normalSlots: { [key: string]: Array }, prevSlots?: { [key: string]: Function } | void ): any { - let res; - const hasNormalSlots = Object.keys(normalSlots).length > 0; - const isStable = slots ? !!slots.$stable : !hasNormalSlots; - const key = slots && slots.$key; + let res + const hasNormalSlots = Object.keys(normalSlots).length > 0 + const isStable = slots ? !!slots.$stable : !hasNormalSlots + const key = slots && slots.$key if (!slots) { - res = {}; + res = {} } else if (slots._normalized) { // fast path 1: child component re-render only, parent did not change - return slots._normalized; + return slots._normalized } else if ( isStable && prevSlots && @@ -28,46 +28,46 @@ export function normalizeScopedSlots( ) { // fast path 2: stable scoped slots w/ no normal slots to proxy, // only need to normalize once - return prevSlots; + return prevSlots } else { - res = {}; + res = {} for (const key in slots) { - if (slots[key] && key[0] !== "$") { - res[key] = normalizeScopedSlot(normalSlots, key, slots[key]); + if (slots[key] && key[0] !== '$') { + res[key] = normalizeScopedSlot(normalSlots, key, slots[key]) } } } // expose normal slots on scopedSlots for (const key in normalSlots) { if (!(key in res)) { - res[key] = proxyNormalSlot(normalSlots, key); + res[key] = proxyNormalSlot(normalSlots, key) } } // avoriaz seems to mock a non-extensible $scopedSlots object // and when that is passed down this would cause an error if (slots && Object.isExtensible(slots)) { - slots._normalized = res; + slots._normalized = res } - def(res, "$stable", isStable); - def(res, "$key", key); - def(res, "$hasNormal", hasNormalSlots); - return res; + def(res, '$stable', isStable) + def(res, '$key', key) + def(res, '$hasNormal', hasNormalSlots) + return res } function normalizeScopedSlot(normalSlots, key, fn) { const normalized = function () { - let res = arguments.length ? fn.apply(null, arguments) : fn({}); + let res = arguments.length ? fn.apply(null, arguments) : fn({}) res = - res && typeof res === "object" && !Array.isArray(res) + res && typeof res === 'object' && !Array.isArray(res) ? [res] // single vnode - : normalizeChildren(res); - const vnode: VNode | null = res && res[0]; + : normalizeChildren(res) + const vnode: VNode | null = res && res[0] return res && (!vnode || (res.length === 1 && vnode.isComment && !isAsyncPlaceholder(vnode))) // #9658, #10391 ? undefined - : res; - }; + : res + } // this is a slot using the new v-slot syntax without scope. although it is // compiled as a scoped slot, render fn users would expect it to be present // on this.$slots because the usage is semantically a normal slot. @@ -75,12 +75,12 @@ function normalizeScopedSlot(normalSlots, key, fn) { Object.defineProperty(normalSlots, key, { get: normalized, enumerable: true, - configurable: true, - }); + configurable: true + }) } - return normalized; + return normalized } function proxyNormalSlot(slots, key) { - return () => slots[key]; + return () => slots[key] } diff --git a/src/core/vdom/helpers/resolve-async-component.ts b/src/core/vdom/helpers/resolve-async-component.ts index c3d7c61c34f..4b965b3cfde 100644 --- a/src/core/vdom/helpers/resolve-async-component.ts +++ b/src/core/vdom/helpers/resolve-async-component.ts @@ -1,4 +1,3 @@ - import { warn, once, @@ -8,7 +7,7 @@ import { isObject, hasSymbol, isPromise, - remove, + remove } from 'core/util/index' import VNode, { createEmptyVNode } from 'core/vdom/vnode' @@ -96,7 +95,7 @@ export function resolveAsyncComponent( } }) - const reject = once((reason) => { + const reject = once(reason => { process.env.NODE_ENV !== 'production' && warn( `Failed to resolve async component: ${String(factory)}` + diff --git a/src/core/vdom/helpers/update-listeners.ts b/src/core/vdom/helpers/update-listeners.ts index 4bc2dbbaf5e..801cbe9a6ec 100644 --- a/src/core/vdom/helpers/update-listeners.ts +++ b/src/core/vdom/helpers/update-listeners.ts @@ -2,27 +2,31 @@ import { warn, invokeWithErrorHandling } from 'core/util/index' import { cached, isUndef, isTrue } from 'shared/util' import type { Component } from 'typescript/component' -const normalizeEvent = cached((name: string): { - name: string - once: boolean - capture: boolean - passive: boolean - handler?: Function - params?: Array -} => { - const passive = name.charAt(0) === '&' - name = passive ? name.slice(1) : name - const once = name.charAt(0) === '~' // Prefixed last, checked first - name = once ? name.slice(1) : name - const capture = name.charAt(0) === '!' - name = capture ? name.slice(1) : name - return { - name, - once, - capture, - passive, +const normalizeEvent = cached( + ( + name: string + ): { + name: string + once: boolean + capture: boolean + passive: boolean + handler?: Function + params?: Array + } => { + const passive = name.charAt(0) === '&' + name = passive ? name.slice(1) : name + const once = name.charAt(0) === '~' // Prefixed last, checked first + name = once ? name.slice(1) : name + const capture = name.charAt(0) === '!' + name = capture ? name.slice(1) : name + return { + name, + once, + capture, + passive + } } -}) +) export function createFnInvoker( fns: Function | Array, diff --git a/src/core/vdom/modules/directives.ts b/src/core/vdom/modules/directives.ts index 302f1746d0f..0ba2d9d0e0e 100644 --- a/src/core/vdom/modules/directives.ts +++ b/src/core/vdom/modules/directives.ts @@ -1,4 +1,3 @@ - import { emptyNode } from 'core/vdom/patch' import { resolveAsset, handleError } from 'core/util/index' import { mergeVNodeHook } from 'core/vdom/helpers/index' @@ -11,7 +10,7 @@ export default { destroy: function unbindDirectives(vnode: VNodeWithData) { // @ts-expect-error emptyNode is not VNodeWithData updateDirectives(vnode, emptyNode) - }, + } } function updateDirectives(oldVnode: VNodeWithData, vnode: VNodeWithData) { diff --git a/src/core/vdom/modules/ref.ts b/src/core/vdom/modules/ref.ts index f6651b905fc..a161b727915 100644 --- a/src/core/vdom/modules/ref.ts +++ b/src/core/vdom/modules/ref.ts @@ -1,44 +1,44 @@ -import { remove, isDef } from "shared/util"; -import type { VNodeWithData } from "typescript/vnode"; +import { remove, isDef } from 'shared/util' +import type { VNodeWithData } from 'typescript/vnode' export default { create(_: any, vnode: VNodeWithData) { - registerRef(vnode); + registerRef(vnode) }, update(oldVnode: VNodeWithData, vnode: VNodeWithData) { if (oldVnode.data.ref !== vnode.data.ref) { - registerRef(oldVnode, true); - registerRef(vnode); + registerRef(oldVnode, true) + registerRef(vnode) } }, destroy(vnode: VNodeWithData) { - registerRef(vnode, true); - }, -}; + registerRef(vnode, true) + } +} export function registerRef(vnode: VNodeWithData, isRemoval?: boolean) { - const key = vnode.data.ref; - if (!isDef(key)) return; + const key = vnode.data.ref + if (!isDef(key)) return - const vm = vnode.context; - const ref = vnode.componentInstance || vnode.elm; - const refs = vm.$refs; - const obj = refs[key]; + const vm = vnode.context + const ref = vnode.componentInstance || vnode.elm + const refs = vm.$refs + const obj = refs[key] if (isRemoval) { if (Array.isArray(obj)) { - remove(obj, ref); + remove(obj, ref) } else if (obj === ref) { - refs[key] = undefined; + refs[key] = undefined } } else { if (vnode.data.refInFor) { if (!Array.isArray(obj)) { - refs[key] = [ref]; + refs[key] = [ref] } else if (obj.indexOf(ref) < 0) { - obj.push(ref); + obj.push(ref) } } else { - refs[key] = ref; + refs[key] = ref } } } diff --git a/src/core/vdom/patch.ts b/src/core/vdom/patch.ts index 4c5fd4acd42..ec47e2c36a1 100644 --- a/src/core/vdom/patch.ts +++ b/src/core/vdom/patch.ts @@ -25,7 +25,7 @@ import { isTrue, makeMap, isRegExp, - isPrimitive, + isPrimitive } from '../util/index' export const emptyNode = new VNode('', {}, []) @@ -35,17 +35,12 @@ const hooks = ['create', 'activate', 'update', 'remove', 'destroy'] function sameVnode(a, b) { return ( a.key === b.key && - a.asyncFactory === b.asyncFactory && ( - ( - a.tag === b.tag && - a.isComment === b.isComment && - isDef(a.data) === isDef(b.data) && - sameInputType(a, b) - ) || ( - isTrue(a.isAsyncPlaceholder) && - isUndef(b.asyncFactory.error) - ) - ) + a.asyncFactory === b.asyncFactory && + ((a.tag === b.tag && + a.isComment === b.isComment && + isDef(a.data) === isDef(b.data) && + sameInputType(a, b)) || + (isTrue(a.isAsyncPlaceholder) && isUndef(b.asyncFactory.error))) ) } @@ -110,7 +105,7 @@ export function createPatchFunction(backend) { !vnode.ns && !( config.ignoredElements.length && - config.ignoredElements.some((ignore) => { + config.ignoredElements.some(ignore => { return isRegExp(ignore) ? ignore.test(vnode.tag) : ignore === vnode.tag diff --git a/src/core/vdom/vnode.ts b/src/core/vdom/vnode.ts index 93bab1012fa..39fa2833315 100644 --- a/src/core/vdom/vnode.ts +++ b/src/core/vdom/vnode.ts @@ -1,35 +1,35 @@ -import type { Component } from "typescript/component"; -import type { ComponentOptions } from "typescript/options"; -import type { VNodeComponentOptions, VNodeData } from "typescript/vnode"; +import type { Component } from 'typescript/component' +import type { ComponentOptions } from 'typescript/options' +import type { VNodeComponentOptions, VNodeData } from 'typescript/vnode' export default class VNode { - tag?: string; - data: VNodeData | undefined; - children?: Array | null; - text?: string; - elm: Node | undefined; - ns?: string; - context?: Component; // rendered in this component's scope - key: string | number | undefined; - componentOptions?: VNodeComponentOptions; - componentInstance?: Component; // component instance - parent: VNode | undefined | null; // component placeholder node + tag?: string + data: VNodeData | undefined + children?: Array | null + text?: string + elm: Node | undefined + ns?: string + context?: Component // rendered in this component's scope + key: string | number | undefined + componentOptions?: VNodeComponentOptions + componentInstance?: Component // component instance + parent: VNode | undefined | null // component placeholder node // strictly internal - raw: boolean; // contains raw HTML? (server only) - isStatic: boolean; // hoisted static node - isRootInsert: boolean; // necessary for enter transition check - isComment: boolean; // empty comment placeholder? - isCloned: boolean; // is a cloned node? - isOnce: boolean; // is a v-once node? - asyncFactory?: Function; // async component factory function - asyncMeta: Object | void; - isAsyncPlaceholder: boolean; - ssrContext?: Object | void; - fnContext: Component | void; // real context vm for functional nodes - fnOptions?: ComponentOptions | null; // for SSR caching - devtoolsMeta?: Object | null; // used to store functional render context for devtools - fnScopeId?: string | null; // functional scope id support + raw: boolean // contains raw HTML? (server only) + isStatic: boolean // hoisted static node + isRootInsert: boolean // necessary for enter transition check + isComment: boolean // empty comment placeholder? + isCloned: boolean // is a cloned node? + isOnce: boolean // is a v-once node? + asyncFactory?: Function // async component factory function + asyncMeta: Object | void + isAsyncPlaceholder: boolean + ssrContext?: Object | void + fnContext: Component | void // real context vm for functional nodes + fnOptions?: ComponentOptions | null // for SSR caching + devtoolsMeta?: Object | null // used to store functional render context for devtools + fnScopeId?: string | null // functional scope id support constructor( tag?: string, @@ -41,47 +41,47 @@ export default class VNode { componentOptions?: VNodeComponentOptions, asyncFactory?: Function ) { - this.tag = tag; - this.data = data; - this.children = children; - this.text = text; - this.elm = elm; - this.ns = undefined; - this.context = context; - this.fnContext = undefined; - this.fnOptions = undefined; - this.fnScopeId = undefined; - this.key = data && data.key; - this.componentOptions = componentOptions; - this.componentInstance = undefined; - this.parent = undefined; - this.raw = false; - this.isStatic = false; - this.isRootInsert = true; - this.isComment = false; - this.isCloned = false; - this.isOnce = false; - this.asyncFactory = asyncFactory; - this.asyncMeta = undefined; - this.isAsyncPlaceholder = false; + this.tag = tag + this.data = data + this.children = children + this.text = text + this.elm = elm + this.ns = undefined + this.context = context + this.fnContext = undefined + this.fnOptions = undefined + this.fnScopeId = undefined + this.key = data && data.key + this.componentOptions = componentOptions + this.componentInstance = undefined + this.parent = undefined + this.raw = false + this.isStatic = false + this.isRootInsert = true + this.isComment = false + this.isCloned = false + this.isOnce = false + this.asyncFactory = asyncFactory + this.asyncMeta = undefined + this.isAsyncPlaceholder = false } // DEPRECATED: alias for componentInstance for backwards compat. /* istanbul ignore next */ get child(): Component | void { - return this.componentInstance; + return this.componentInstance } } -export const createEmptyVNode = (text: string = "") => { - const node = new VNode(); - node.text = text; - node.isComment = true; - return node; -}; +export const createEmptyVNode = (text: string = '') => { + const node = new VNode() + node.text = text + node.isComment = true + return node +} export function createTextVNode(val: string | number) { - return new VNode(undefined, undefined, undefined, String(val)); + return new VNode(undefined, undefined, undefined, String(val)) } // optimized shallow clone @@ -101,15 +101,15 @@ export function cloneVNode(vnode: VNode): VNode { vnode.context, vnode.componentOptions, vnode.asyncFactory - ); - cloned.ns = vnode.ns; - cloned.isStatic = vnode.isStatic; - cloned.key = vnode.key; - cloned.isComment = vnode.isComment; - cloned.fnContext = vnode.fnContext; - cloned.fnOptions = vnode.fnOptions; - cloned.fnScopeId = vnode.fnScopeId; - cloned.asyncMeta = vnode.asyncMeta; - cloned.isCloned = true; - return cloned; + ) + cloned.ns = vnode.ns + cloned.isStatic = vnode.isStatic + cloned.key = vnode.key + cloned.isComment = vnode.isComment + cloned.fnContext = vnode.fnContext + cloned.fnOptions = vnode.fnOptions + cloned.fnScopeId = vnode.fnScopeId + cloned.asyncMeta = vnode.asyncMeta + cloned.isCloned = true + return cloned } diff --git a/src/global.d.ts b/src/global.d.ts index 1bdbeafea43..0fabe95c676 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -1,5 +1,5 @@ interface Window { - __VUE_DEVTOOLS_GLOBAL_HOOK__: DevtoolsHook; + __VUE_DEVTOOLS_GLOBAL_HOOK__: DevtoolsHook } // from https://github.com/vuejs/vue-devtools/blob/bc719c95a744614f5c3693460b64dc21dfa339a8/packages/app-backend-api/src/global-hook.ts#L3 diff --git a/src/platforms/web/compiler/directives/html.ts b/src/platforms/web/compiler/directives/html.ts index b12be5e616f..af6dd62dc33 100644 --- a/src/platforms/web/compiler/directives/html.ts +++ b/src/platforms/web/compiler/directives/html.ts @@ -1,4 +1,3 @@ - import { addProp } from 'compiler/helpers' export default function html(el: ASTElement, dir: ASTDirective) { diff --git a/src/platforms/web/compiler/directives/index.ts b/src/platforms/web/compiler/directives/index.ts index 2473ae1a735..0955b51e7aa 100644 --- a/src/platforms/web/compiler/directives/index.ts +++ b/src/platforms/web/compiler/directives/index.ts @@ -5,5 +5,5 @@ import html from './html' export default { model, text, - html, + html } diff --git a/src/platforms/web/compiler/directives/model.ts b/src/platforms/web/compiler/directives/model.ts index 82892dc26e2..8dd3ed4a2b9 100644 --- a/src/platforms/web/compiler/directives/model.ts +++ b/src/platforms/web/compiler/directives/model.ts @@ -1,4 +1,3 @@ - import config from 'core/config' import { addHandler, addProp, getBindingAttr } from 'compiler/helpers' import { genComponentModel, genAssignmentCode } from 'compiler/directives/model' diff --git a/src/platforms/web/compiler/directives/text.ts b/src/platforms/web/compiler/directives/text.ts index 1502797c477..9cb39d1180c 100644 --- a/src/platforms/web/compiler/directives/text.ts +++ b/src/platforms/web/compiler/directives/text.ts @@ -1,4 +1,3 @@ - import { addProp } from 'compiler/helpers' export default function text(el: ASTElement, dir: ASTDirective) { diff --git a/src/platforms/web/compiler/index.ts b/src/platforms/web/compiler/index.ts index 5e50ce90c86..857351f15f5 100644 --- a/src/platforms/web/compiler/index.ts +++ b/src/platforms/web/compiler/index.ts @@ -1,4 +1,3 @@ - import { baseOptions } from './options' import { createCompiler } from 'compiler/index' diff --git a/src/platforms/web/compiler/modules/class.ts b/src/platforms/web/compiler/modules/class.ts index 347b386ef8e..4789c3d09b5 100644 --- a/src/platforms/web/compiler/modules/class.ts +++ b/src/platforms/web/compiler/modules/class.ts @@ -1,4 +1,3 @@ - import { parseText } from 'compiler/parser/text-parser' import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers' @@ -40,5 +39,5 @@ function genData(el: ASTElement): string { export default { staticKeys: ['staticClass'], transformNode, - genData, + genData } as ModuleOptions diff --git a/src/platforms/web/compiler/modules/model.ts b/src/platforms/web/compiler/modules/model.ts index d55d08b5fcc..63c6f83fcfd 100644 --- a/src/platforms/web/compiler/modules/model.ts +++ b/src/platforms/web/compiler/modules/model.ts @@ -1,4 +1,3 @@ - /** * Expand input[v-model] with dynamic type bindings into v-if-else chains * Turn this: @@ -15,7 +14,7 @@ import { processFor, processElement, addIfCondition, - createASTElement, + createASTElement } from 'compiler/parser/index' function preTransformNode(el: ASTElement, options: CompilerOptions) { @@ -48,7 +47,7 @@ function preTransformNode(el: ASTElement, options: CompilerOptions) { branch0.if = `(${typeBinding})==='checkbox'` + ifConditionExtra addIfCondition(branch0, { exp: branch0.if, - block: branch0, + block: branch0 }) // 2. add radio else-if condition const branch1 = cloneASTElement(el) @@ -57,7 +56,7 @@ function preTransformNode(el: ASTElement, options: CompilerOptions) { processElement(branch1, options) addIfCondition(branch0, { exp: `(${typeBinding})==='radio'` + ifConditionExtra, - block: branch1, + block: branch1 }) // 3. other const branch2 = cloneASTElement(el) @@ -66,7 +65,7 @@ function preTransformNode(el: ASTElement, options: CompilerOptions) { processElement(branch2, options) addIfCondition(branch0, { exp: ifCondition!, - block: branch2, + block: branch2 }) if (hasElse) { @@ -85,5 +84,5 @@ function cloneASTElement(el) { } export default { - preTransformNode, + preTransformNode } as ModuleOptions diff --git a/src/platforms/web/compiler/modules/style.ts b/src/platforms/web/compiler/modules/style.ts index 833a40d3d5c..8daf3b66df9 100644 --- a/src/platforms/web/compiler/modules/style.ts +++ b/src/platforms/web/compiler/modules/style.ts @@ -1,4 +1,3 @@ - import { parseText } from 'compiler/parser/text-parser' import { parseStyleText } from 'web/util/style' import { getAndRemoveAttr, getBindingAttr, baseWarn } from 'compiler/helpers' @@ -43,5 +42,5 @@ function genData(el: ASTElement): string { export default { staticKeys: ['staticStyle'], transformNode, - genData, + genData } as ModuleOptions diff --git a/src/platforms/web/compiler/options.ts b/src/platforms/web/compiler/options.ts index edbc1fdac34..86653884800 100644 --- a/src/platforms/web/compiler/options.ts +++ b/src/platforms/web/compiler/options.ts @@ -2,13 +2,13 @@ import { isPreTag, mustUseProp, isReservedTag, - getTagNamespace, -} from "../util/index"; + getTagNamespace +} from '../util/index' -import modules from "./modules/index"; -import directives from "./directives/index"; -import { genStaticKeys } from "shared/util"; -import { isUnaryTag, canBeLeftOpenTag } from "./util"; +import modules from './modules/index' +import directives from './directives/index' +import { genStaticKeys } from 'shared/util' +import { isUnaryTag, canBeLeftOpenTag } from './util' export const baseOptions: CompilerOptions = { expectHTML: true, @@ -20,5 +20,5 @@ export const baseOptions: CompilerOptions = { canBeLeftOpenTag, isReservedTag, getTagNamespace, - staticKeys: genStaticKeys(modules), -}; + staticKeys: genStaticKeys(modules) +} diff --git a/src/platforms/web/compiler/util.ts b/src/platforms/web/compiler/util.ts index b1412c07475..097e0a47c97 100644 --- a/src/platforms/web/compiler/util.ts +++ b/src/platforms/web/compiler/util.ts @@ -1,4 +1,3 @@ - import { makeMap } from 'shared/util' export const isUnaryTag = makeMap( diff --git a/src/platforms/web/entry-compiler.ts b/src/platforms/web/entry-compiler.ts index b14a1f699fe..f1f6aec4052 100644 --- a/src/platforms/web/entry-compiler.ts +++ b/src/platforms/web/entry-compiler.ts @@ -1,4 +1,3 @@ - export { parseComponent } from 'sfc/parser' export { compile, compileToFunctions } from './compiler/index' export { ssrCompile, ssrCompileToFunctions } from './server/compiler' diff --git a/src/platforms/web/entry-runtime-with-compiler.ts b/src/platforms/web/entry-runtime-with-compiler.ts index 8ac91a4e1bd..7d11b79fb96 100644 --- a/src/platforms/web/entry-runtime-with-compiler.ts +++ b/src/platforms/web/entry-runtime-with-compiler.ts @@ -7,12 +7,12 @@ import { query } from './util/index' import { compileToFunctions } from './compiler/index' import { shouldDecodeNewlines, - shouldDecodeNewlinesForHref, + shouldDecodeNewlinesForHref } from './util/compat' import type { Component } from 'typescript/component' import type { GlobalAPI } from 'typescript/global-api' -const idToTemplate = cached((id) => { +const idToTemplate = cached(id => { const el = query(id) return el && el.innerHTML }) @@ -74,7 +74,7 @@ Vue.prototype.$mount = function ( shouldDecodeNewlines, shouldDecodeNewlinesForHref, delimiters: options.delimiters, - comments: options.comments, + comments: options.comments }, this ) diff --git a/src/platforms/web/entry-runtime.ts b/src/platforms/web/entry-runtime.ts index 0ce6019264f..0251259b0bd 100644 --- a/src/platforms/web/entry-runtime.ts +++ b/src/platforms/web/entry-runtime.ts @@ -1,4 +1,3 @@ - import Vue from './runtime/index' export default Vue diff --git a/src/platforms/web/entry-server-basic-renderer.ts b/src/platforms/web/entry-server-basic-renderer.ts index 9c6d3175f5d..2f965eb66cc 100644 --- a/src/platforms/web/entry-server-basic-renderer.ts +++ b/src/platforms/web/entry-server-basic-renderer.ts @@ -1,4 +1,3 @@ - import modules from './server/modules/index' import directives from './server/directives/index' import { isUnaryTag, canBeLeftOpenTag } from './compiler/util' @@ -9,5 +8,5 @@ export default createBasicRenderer({ modules, directives, isUnaryTag, - canBeLeftOpenTag, + canBeLeftOpenTag }) diff --git a/src/platforms/web/entry-server-renderer.ts b/src/platforms/web/entry-server-renderer.ts index d0e7f8fb00c..10d09d3680b 100644 --- a/src/platforms/web/entry-server-renderer.ts +++ b/src/platforms/web/entry-server-renderer.ts @@ -1,4 +1,3 @@ - process.env.VUE_ENV = 'server' import { extend } from 'shared/util' @@ -9,7 +8,7 @@ import { isUnaryTag, canBeLeftOpenTag } from './compiler/util' import { createRenderer as _createRenderer, Renderer, - RenderOptions, + RenderOptions } from 'server/create-renderer' import { createBundleRendererCreator } from 'server/bundle-renderer/create-bundle-renderer' @@ -23,7 +22,7 @@ export function createRenderer( modules, // user can provide server-side implementations for custom directives // when creating the renderer. - directives: extend(baseDirectives, options.directives), + directives: extend(baseDirectives, options.directives) }) ) } diff --git a/src/platforms/web/runtime/class-util.ts b/src/platforms/web/runtime/class-util.ts index b24cce0d9b2..e66ffae5878 100644 --- a/src/platforms/web/runtime/class-util.ts +++ b/src/platforms/web/runtime/class-util.ts @@ -1,4 +1,3 @@ - const whitespaceRE = /\s+/ /** @@ -14,7 +13,7 @@ export function addClass(el: HTMLElement, cls?: string) { /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { - cls.split(whitespaceRE).forEach((c) => el.classList.add(c)) + cls.split(whitespaceRE).forEach(c => el.classList.add(c)) } else { el.classList.add(cls) } @@ -39,7 +38,7 @@ export function removeClass(el: HTMLElement, cls?: string) { /* istanbul ignore else */ if (el.classList) { if (cls.indexOf(' ') > -1) { - cls.split(whitespaceRE).forEach((c) => el.classList.remove(c)) + cls.split(whitespaceRE).forEach(c => el.classList.remove(c)) } else { el.classList.remove(cls) } diff --git a/src/platforms/web/runtime/components/index.ts b/src/platforms/web/runtime/components/index.ts index cbbaa132aaa..6bfe5780a5a 100644 --- a/src/platforms/web/runtime/components/index.ts +++ b/src/platforms/web/runtime/components/index.ts @@ -3,5 +3,5 @@ import TransitionGroup from './transition-group' export default { Transition, - TransitionGroup, + TransitionGroup } diff --git a/src/platforms/web/runtime/components/transition-group.ts b/src/platforms/web/runtime/components/transition-group.ts index d62318ed2fb..664d3c4599d 100644 --- a/src/platforms/web/runtime/components/transition-group.ts +++ b/src/platforms/web/runtime/components/transition-group.ts @@ -9,195 +9,195 @@ // into the final desired state. This way in the second pass removed // nodes will remain where they should be. -import { warn, extend } from "core/util/index"; -import { addClass, removeClass } from "web/runtime/class-util"; -import { transitionProps, extractTransitionData } from "./transition"; -import { setActiveInstance } from "core/instance/lifecycle"; +import { warn, extend } from 'core/util/index' +import { addClass, removeClass } from 'web/runtime/class-util' +import { transitionProps, extractTransitionData } from './transition' +import { setActiveInstance } from 'core/instance/lifecycle' import { hasTransition, getTransitionInfo, transitionEndEvent, addTransitionClass, - removeTransitionClass, -} from "web/runtime/transition-util"; -import VNode from "core/vdom/vnode"; -import { VNodeWithData } from "typescript/vnode"; + removeTransitionClass +} from 'web/runtime/transition-util' +import VNode from 'core/vdom/vnode' +import { VNodeWithData } from 'typescript/vnode' const props = extend( { tag: String, - moveClass: String, + moveClass: String }, transitionProps -); +) -delete props.mode; +delete props.mode export default { props, beforeMount() { - const update = this._update; + const update = this._update this._update = (vnode, hydrating) => { - const restoreActiveInstance = setActiveInstance(this); + const restoreActiveInstance = setActiveInstance(this) // force removing pass this.__patch__( this._vnode, this.kept, false, // hydrating true // removeOnly (!important, avoids unnecessary moves) - ); - this._vnode = this.kept; - restoreActiveInstance(); - update.call(this, vnode, hydrating); - }; + ) + this._vnode = this.kept + restoreActiveInstance() + update.call(this, vnode, hydrating) + } }, render(h: Function) { - const tag: string = this.tag || this.$vnode.data.tag || "span"; - const map: Record = Object.create(null); - const prevChildren: Array = (this.prevChildren = this.children); - const rawChildren: Array = this.$slots.default || []; - const children: Array = (this.children = []); - const transitionData = extractTransitionData(this); + const tag: string = this.tag || this.$vnode.data.tag || 'span' + const map: Record = Object.create(null) + const prevChildren: Array = (this.prevChildren = this.children) + const rawChildren: Array = this.$slots.default || [] + const children: Array = (this.children = []) + const transitionData = extractTransitionData(this) for (let i = 0; i < rawChildren.length; i++) { - const c: VNode = rawChildren[i]; + const c: VNode = rawChildren[i] if (c.tag) { - if (c.key != null && String(c.key).indexOf("__vlist") !== 0) { - children.push(c); - map[c.key] = c; - (c.data || (c.data = {})).transition = transitionData; - } else if (process.env.NODE_ENV !== "production") { - const opts = c.componentOptions; + if (c.key != null && String(c.key).indexOf('__vlist') !== 0) { + children.push(c) + map[c.key] = c + ;(c.data || (c.data = {})).transition = transitionData + } else if (process.env.NODE_ENV !== 'production') { + const opts = c.componentOptions const name: string = opts - ? opts.Ctor.options.name || opts.tag || "" - : c.tag; - warn(` children must be keyed: <${name}>`); + ? opts.Ctor.options.name || opts.tag || '' + : c.tag + warn(` children must be keyed: <${name}>`) } } } if (prevChildren) { - const kept: Array = []; - const removed: Array = []; + const kept: Array = [] + const removed: Array = [] for (let i = 0; i < prevChildren.length; i++) { - const c: VNode = prevChildren[i]; - c.data!.transition = transitionData; + const c: VNode = prevChildren[i] + c.data!.transition = transitionData // @ts-expect-error .getBoundingClientRect is not typed in Node - c.data!.pos = c.elm.getBoundingClientRect(); + c.data!.pos = c.elm.getBoundingClientRect() if (map[c.key!]) { - kept.push(c); + kept.push(c) } else { - removed.push(c); + removed.push(c) } } - this.kept = h(tag, null, kept); - this.removed = removed; + this.kept = h(tag, null, kept) + this.removed = removed } - return h(tag, null, children); + return h(tag, null, children) }, updated() { - const children: Array = this.prevChildren; - const moveClass: string = this.moveClass || (this.name || "v") + "-move"; + const children: Array = this.prevChildren + const moveClass: string = this.moveClass || (this.name || 'v') + '-move' if (!children.length || !this.hasMove(children[0].elm, moveClass)) { - return; + return } // we divide the work into three loops to avoid mixing DOM reads and writes // in each iteration - which helps prevent layout thrashing. - children.forEach(callPendingCbs); - children.forEach(recordPosition); - children.forEach(applyTranslation); + children.forEach(callPendingCbs) + children.forEach(recordPosition) + children.forEach(applyTranslation) // force reflow to put everything in position // assign to this to avoid being removed in tree-shaking // $flow-disable-line - this._reflow = document.body.offsetHeight; + this._reflow = document.body.offsetHeight children.forEach((c: VNode) => { if (c.data!.moved) { - const el: any = c.elm; - const s: any = el.style; - addTransitionClass(el, moveClass); - s.transform = s.WebkitTransform = s.transitionDuration = ""; + const el: any = c.elm + const s: any = el.style + addTransitionClass(el, moveClass) + s.transform = s.WebkitTransform = s.transitionDuration = '' el.addEventListener( transitionEndEvent, (el._moveCb = function cb(e) { if (e && e.target !== el) { - return; + return } if (!e || /transform$/.test(e.propertyName)) { - el.removeEventListener(transitionEndEvent, cb); - el._moveCb = null; - removeTransitionClass(el, moveClass); + el.removeEventListener(transitionEndEvent, cb) + el._moveCb = null + removeTransitionClass(el, moveClass) } }) - ); + ) } - }); + }) }, methods: { hasMove(el: any, moveClass: string): boolean { /* istanbul ignore if */ if (!hasTransition) { - return false; + return false } /* istanbul ignore if */ if (this._hasMove) { - return this._hasMove; + return this._hasMove } // Detect whether an element with the move class applied has // CSS transitions. Since the element may be inside an entering // transition at this very moment, we make a clone of it and remove // all other transition classes applied to ensure only the move class // is applied. - const clone: HTMLElement = el.cloneNode(); + const clone: HTMLElement = el.cloneNode() if (el._transitionClasses) { el._transitionClasses.forEach((cls: string) => { - removeClass(clone, cls); - }); + removeClass(clone, cls) + }) } - addClass(clone, moveClass); - clone.style.display = "none"; - this.$el.appendChild(clone); - const info: any = getTransitionInfo(clone); - this.$el.removeChild(clone); - return (this._hasMove = info.hasTransform); - }, - }, -}; + addClass(clone, moveClass) + clone.style.display = 'none' + this.$el.appendChild(clone) + const info: any = getTransitionInfo(clone) + this.$el.removeChild(clone) + return (this._hasMove = info.hasTransform) + } + } +} function callPendingCbs( c: VNodeWithData & { elm?: { _moveCb?: Function; _enterCb?: Function } } ) { /* istanbul ignore if */ if (c.elm!._moveCb) { - c.elm!._moveCb(); + c.elm!._moveCb() } /* istanbul ignore if */ if (c.elm!._enterCb) { - c.elm!._enterCb(); + c.elm!._enterCb() } } function recordPosition(c: VNodeWithData) { - c.data!.newPos = c.elm.getBoundingClientRect(); + c.data!.newPos = c.elm.getBoundingClientRect() } function applyTranslation(c: VNodeWithData) { - const oldPos = c.data.pos; - const newPos = c.data.newPos; - const dx = oldPos.left - newPos.left; - const dy = oldPos.top - newPos.top; + const oldPos = c.data.pos + const newPos = c.data.newPos + const dx = oldPos.left - newPos.left + const dy = oldPos.top - newPos.top if (dx || dy) { - c.data.moved = true; - const s = c.elm.style; - s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)`; - s.transitionDuration = "0s"; + c.data.moved = true + const s = c.elm.style + s.transform = s.WebkitTransform = `translate(${dx}px,${dy}px)` + s.transitionDuration = '0s' } } diff --git a/src/platforms/web/runtime/components/transition.ts b/src/platforms/web/runtime/components/transition.ts index a1f82e3c1dc..782c0b6d300 100644 --- a/src/platforms/web/runtime/components/transition.ts +++ b/src/platforms/web/runtime/components/transition.ts @@ -1,4 +1,3 @@ - // Provides transition support for a single element/component. // supports transition mode (out-in / in-out) @@ -7,7 +6,7 @@ import { camelize, extend, isPrimitive } from 'shared/util' import { mergeVNodeHook, isAsyncPlaceholder, - getFirstComponentChild, + getFirstComponentChild } from 'core/vdom/helpers/index' import VNode from 'core/vdom/vnode' import type { Component } from 'typescript/component' @@ -27,7 +26,7 @@ export const transitionProps = { appearClass: String, appearActiveClass: String, appearToClass: String, - duration: [Number, String, Object], + duration: [Number, String, Object] } // in case the child is also an abstract component, e.g. @@ -61,7 +60,7 @@ function placeholder(h: Function, rawChild: VNode): VNode | undefined { // @ts-expect-error if (/\d-keep-alive$/.test(rawChild.tag)) { return h('keep-alive', { - props: rawChild.componentOptions!.propsData, + props: rawChild.componentOptions!.propsData }) } } @@ -80,7 +79,7 @@ function isSameChild(child: VNode, oldChild: VNode): boolean { const isNotTextNode = (c: VNode) => c.tag || isAsyncPlaceholder(c) -const isVShowDirective = (d) => d.name === 'show' +const isVShowDirective = d => d.name === 'show' export default { name: 'transition', @@ -156,9 +155,8 @@ export default { : id + child.key : child.key - const data: Object = (( - child.data || (child.data = {}) - ).transition = extractTransitionData(this)) + const data: Object = ((child.data || (child.data = {})).transition = + extractTransitionData(this)) const oldRawChild: VNode = this._vnode const oldChild = getRealChild(oldRawChild) @@ -201,12 +199,12 @@ export default { } mergeVNodeHook(data, 'afterEnter', performLeave) mergeVNodeHook(data, 'enterCancelled', performLeave) - mergeVNodeHook(oldData, 'delayLeave', (leave) => { + mergeVNodeHook(oldData, 'delayLeave', leave => { delayedLeave = leave }) } } return rawChild - }, + } } diff --git a/src/platforms/web/runtime/directives/index.ts b/src/platforms/web/runtime/directives/index.ts index 6409229c35d..b673f11aa61 100644 --- a/src/platforms/web/runtime/directives/index.ts +++ b/src/platforms/web/runtime/directives/index.ts @@ -3,5 +3,5 @@ import show from './show' export default { model, - show, + show } diff --git a/src/platforms/web/runtime/directives/model.ts b/src/platforms/web/runtime/directives/model.ts index 91f250b0b92..799113ca816 100644 --- a/src/platforms/web/runtime/directives/model.ts +++ b/src/platforms/web/runtime/directives/model.ts @@ -63,7 +63,7 @@ const directive = { // trigger change event if // no matching option found for at least one value const needReset = el.multiple - ? binding.value.some((v) => hasNoMatchingOption(v, curOptions)) + ? binding.value.some(v => hasNoMatchingOption(v, curOptions)) : binding.value !== binding.oldValue && hasNoMatchingOption(binding.value, curOptions) if (needReset) { @@ -71,7 +71,7 @@ const directive = { } } } - }, + } } function setSelected(el, binding, vm) { @@ -121,7 +121,7 @@ function actuallySetSelected(el, binding, vm) { } function hasNoMatchingOption(value, options) { - return options.every((o) => !looseEqual(o, value)) + return options.every(o => !looseEqual(o, value)) } function getValue(option) { diff --git a/src/platforms/web/runtime/directives/show.ts b/src/platforms/web/runtime/directives/show.ts index bd59c79ee8c..230725e708d 100644 --- a/src/platforms/web/runtime/directives/show.ts +++ b/src/platforms/web/runtime/directives/show.ts @@ -1,9 +1,7 @@ - import VNode from 'core/vdom/vnode' import type { VNodeDirective, VNodeWithData } from 'typescript/vnode' import { enter, leave } from 'web/runtime/modules/transition' - // recursively search for possible transition defined inside the component root function locateNode(vnode: VNode | VNodeWithData): VNodeWithData { // @ts-expect-error @@ -59,5 +57,5 @@ export default { if (!isDestroy) { el.style.display = el.__vOriginalDisplay } - }, + } } diff --git a/src/platforms/web/runtime/modules/attrs.ts b/src/platforms/web/runtime/modules/attrs.ts index 780e283b6cf..cda1d3e2446 100644 --- a/src/platforms/web/runtime/modules/attrs.ts +++ b/src/platforms/web/runtime/modules/attrs.ts @@ -1,4 +1,3 @@ - import { isIE, isIE9, isEdge } from 'core/util/env' import { extend, isDef, isUndef } from 'shared/util' @@ -11,7 +10,7 @@ import { isBooleanAttr, isEnumeratedAttr, isFalsyAttrValue, - convertEnumeratedValue, + convertEnumeratedValue } from 'web/util/index' function updateAttrs(oldVnode: VNodeWithData, vnode: VNodeWithData) { @@ -98,7 +97,7 @@ function baseSetAttr(el, key, value) { value !== '' && !el.__ieph ) { - const blocker = (e) => { + const blocker = e => { e.stopImmediatePropagation() el.removeEventListener('input', blocker) } @@ -112,5 +111,5 @@ function baseSetAttr(el, key, value) { export default { create: updateAttrs, - update: updateAttrs, + update: updateAttrs } diff --git a/src/platforms/web/runtime/modules/class.ts b/src/platforms/web/runtime/modules/class.ts index 3f183098360..3be15a1ab4c 100644 --- a/src/platforms/web/runtime/modules/class.ts +++ b/src/platforms/web/runtime/modules/class.ts @@ -1,4 +1,3 @@ - import { isDef, isUndef } from 'shared/util' import type { VNodeData } from 'typescript/vnode' @@ -34,5 +33,5 @@ function updateClass(oldVnode: any, vnode: any) { export default { create: updateClass, - update: updateClass, + update: updateClass } diff --git a/src/platforms/web/runtime/modules/dom-props.ts b/src/platforms/web/runtime/modules/dom-props.ts index c666504d5b8..6cf736566b6 100644 --- a/src/platforms/web/runtime/modules/dom-props.ts +++ b/src/platforms/web/runtime/modules/dom-props.ts @@ -1,4 +1,3 @@ - import { isDef, isUndef, extend, toNumber } from 'shared/util' import type { VNodeWithData } from 'typescript/vnode' import { isSVG } from 'web/util/index' @@ -120,5 +119,5 @@ function isDirtyWithModifiers(elm: any, newVal: string): boolean { export default { create: updateDOMProps, - update: updateDOMProps, + update: updateDOMProps } diff --git a/src/platforms/web/runtime/modules/events.ts b/src/platforms/web/runtime/modules/events.ts index 85cc6efcfbd..31b220ff92f 100644 --- a/src/platforms/web/runtime/modules/events.ts +++ b/src/platforms/web/runtime/modules/events.ts @@ -1,10 +1,9 @@ - import { isDef, isUndef } from 'shared/util' import { updateListeners } from 'core/vdom/helpers/index' import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index' import { RANGE_TOKEN, - CHECKBOX_RADIO_TOKEN, + CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model' import { currentFlushTimestamp } from 'core/observer/scheduler' import { emptyNode } from 'core/vdom/patch' @@ -63,7 +62,7 @@ function add( if (useMicrotaskFix) { const attachedTimestamp = currentFlushTimestamp const original = handler - //@ts-expect-error + //@ts-expect-error handler = original._wrapper = function (e) { if ( // no bubbling, should always fire. @@ -98,7 +97,7 @@ function remove( capture: boolean, _target?: HTMLElement ) { - (_target || target).removeEventListener( + ;(_target || target).removeEventListener( name, //@ts-expect-error handler._wrapper || handler, diff --git a/src/platforms/web/runtime/modules/style.ts b/src/platforms/web/runtime/modules/style.ts index c40c9f50fb8..b8412bdae6c 100644 --- a/src/platforms/web/runtime/modules/style.ts +++ b/src/platforms/web/runtime/modules/style.ts @@ -1,4 +1,3 @@ - import { getStyle, normalizeStyleBinding } from 'web/util/style' import { cached, @@ -6,7 +5,7 @@ import { extend, isDef, isUndef, - hyphenate, + hyphenate } from 'shared/util' import type { VNodeWithData } from 'typescript/vnode' @@ -101,5 +100,5 @@ function updateStyle(oldVnode: VNodeWithData, vnode: VNodeWithData) { export default { create: updateStyle, - update: updateStyle, + update: updateStyle } diff --git a/src/platforms/web/runtime/modules/transition.ts b/src/platforms/web/runtime/modules/transition.ts index ebed6480666..69f03fd150b 100644 --- a/src/platforms/web/runtime/modules/transition.ts +++ b/src/platforms/web/runtime/modules/transition.ts @@ -1,16 +1,16 @@ - import { inBrowser, isIE9, warn } from 'core/util/index' import { mergeVNodeHook } from 'core/vdom/helpers/index' import { activeInstance } from 'core/instance/lifecycle' import { once, isDef, isUndef, isObject, toNumber } from 'shared/util' -import { +import { nextFrame, resolveTransition, whenTransitionEnds, addTransitionClass, - removeTransitionClass } from 'web/runtime/transition-util' + removeTransitionClass +} from 'web/runtime/transition-util' import type { VNodeWithData } from 'typescript/vnode' import VNode from 'core/vdom/vnode' @@ -51,7 +51,7 @@ export function enter(vnode: VNodeWithData, toggleDisplay?: () => void) { appear, afterAppear, appearCancelled, - duration, + duration } = data // activeInstance will always be the component managing this @@ -193,7 +193,7 @@ export function leave(vnode: VNodeWithData, rm: Function) { afterLeave, leaveCancelled, delayLeave, - duration, + duration } = data const expectsCSS = css !== false && !isIE9 @@ -242,9 +242,8 @@ export function leave(vnode: VNodeWithData, rm: Function) { } // record leaving element if (!vnode.data.show && el.parentNode) { - (el.parentNode._pending || (el.parentNode._pending = {}))[ - vnode.key! - ] = vnode + ;(el.parentNode._pending || (el.parentNode._pending = {}))[vnode.key!] = + vnode } beforeLeave && beforeLeave(el) if (expectsCSS) { @@ -334,6 +333,6 @@ export default inBrowser } else { rm() } - }, + } } : {} diff --git a/src/platforms/web/runtime/node-ops.ts b/src/platforms/web/runtime/node-ops.ts index 5eca28e3615..fed3abc8cb2 100644 --- a/src/platforms/web/runtime/node-ops.ts +++ b/src/platforms/web/runtime/node-ops.ts @@ -1,4 +1,3 @@ - import VNode from 'core/vdom/vnode' import { namespaceMap } from 'web/util/index' diff --git a/src/platforms/web/runtime/patch.ts b/src/platforms/web/runtime/patch.ts index 76cc4c0cc3f..a56e67f0ce0 100644 --- a/src/platforms/web/runtime/patch.ts +++ b/src/platforms/web/runtime/patch.ts @@ -1,4 +1,3 @@ - import * as nodeOps from 'web/runtime/node-ops' import { createPatchFunction } from 'core/vdom/patch' import baseModules from 'core/vdom/modules/index' diff --git a/src/platforms/web/runtime/transition-util.ts b/src/platforms/web/runtime/transition-util.ts index d327e29b82d..6174c6f37e4 100644 --- a/src/platforms/web/runtime/transition-util.ts +++ b/src/platforms/web/runtime/transition-util.ts @@ -21,14 +21,14 @@ export function resolveTransition( } } -const autoCssTransition: (name: string) => Object = cached((name) => { +const autoCssTransition: (name: string) => Object = cached(name => { return { enterClass: `${name}-enter`, enterToClass: `${name}-enter-to`, enterActiveClass: `${name}-enter-active`, leaveClass: `${name}-leave`, leaveToClass: `${name}-leave-to`, - leaveActiveClass: `${name}-leave-active`, + leaveActiveClass: `${name}-leave-active` } }) @@ -64,7 +64,7 @@ const raf = inBrowser ? window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout - : /* istanbul ignore next */ (fn) => fn() + : /* istanbul ignore next */ fn => fn() export function nextFrame(fn: Function) { raf(() => { @@ -103,7 +103,7 @@ export function whenTransitionEnds( el.removeEventListener(event, onEnd) cb() } - const onEnd = (e) => { + const onEnd = e => { if (e.target === el) { if (++ended >= propCount) { end() @@ -188,7 +188,7 @@ export function getTransitionInfo( type, timeout, propCount, - hasTransform, + hasTransform } } diff --git a/src/platforms/web/server/compiler.ts b/src/platforms/web/server/compiler.ts index 55dc68ec3f9..27831e8e36b 100644 --- a/src/platforms/web/server/compiler.ts +++ b/src/platforms/web/server/compiler.ts @@ -1,4 +1,3 @@ - import { baseOptions } from '../compiler/options' import { createCompiler } from 'server/optimizing-compiler/index' diff --git a/src/platforms/web/server/directives/index.ts b/src/platforms/web/server/directives/index.ts index 7d999b92556..fd7fce0a34c 100644 --- a/src/platforms/web/server/directives/index.ts +++ b/src/platforms/web/server/directives/index.ts @@ -3,5 +3,5 @@ import model from './model' export default { show, - model, + model } diff --git a/src/platforms/web/server/directives/model.ts b/src/platforms/web/server/directives/model.ts index cab659512b7..321727eb28d 100644 --- a/src/platforms/web/server/directives/model.ts +++ b/src/platforms/web/server/directives/model.ts @@ -1,4 +1,3 @@ - import { looseEqual, looseIndexOf } from 'shared/util' import type { VNodeDirective, VNodeWithData } from 'typescript/vnode' diff --git a/src/platforms/web/server/directives/show.ts b/src/platforms/web/server/directives/show.ts index 3ab67bf6266..6811d84654a 100644 --- a/src/platforms/web/server/directives/show.ts +++ b/src/platforms/web/server/directives/show.ts @@ -1,4 +1,3 @@ - import type { VNodeDirective, VNodeWithData } from 'typescript/vnode' export default function show(node: VNodeWithData, dir: VNodeDirective) { diff --git a/src/platforms/web/server/modules/attrs.ts b/src/platforms/web/server/modules/attrs.ts index e64f24dc053..5cb7e3b6140 100644 --- a/src/platforms/web/server/modules/attrs.ts +++ b/src/platforms/web/server/modules/attrs.ts @@ -1,4 +1,3 @@ - import { escape } from '../util' import { isDef, isUndef, extend } from 'shared/util' @@ -7,7 +6,7 @@ import { isBooleanAttr, isEnumeratedAttr, isFalsyAttrValue, - convertEnumeratedValue, + convertEnumeratedValue } from 'web/util/attrs' import { isSSRUnsafeAttr } from 'web/server/util' diff --git a/src/platforms/web/server/modules/class.ts b/src/platforms/web/server/modules/class.ts index f087c7f5d86..c0f674e102d 100644 --- a/src/platforms/web/server/modules/class.ts +++ b/src/platforms/web/server/modules/class.ts @@ -1,4 +1,3 @@ - import { escape } from '../util' import { genClassForVnode } from 'web/util/index' import type { VNodeWithData } from 'typescript/vnode' diff --git a/src/platforms/web/server/modules/dom-props.ts b/src/platforms/web/server/modules/dom-props.ts index e57bf9cab04..1c13030c805 100644 --- a/src/platforms/web/server/modules/dom-props.ts +++ b/src/platforms/web/server/modules/dom-props.ts @@ -1,4 +1,3 @@ - import VNode from 'core/vdom/vnode' import { renderAttr } from './attrs' import { isDef, isUndef, extend, toString } from 'shared/util' diff --git a/src/platforms/web/server/modules/style.ts b/src/platforms/web/server/modules/style.ts index d9ea3901c40..8e165e28243 100644 --- a/src/platforms/web/server/modules/style.ts +++ b/src/platforms/web/server/modules/style.ts @@ -1,4 +1,3 @@ - import { escape, noUnitNumericStyleProps } from '../util' import { hyphenate } from 'shared/util' import { getStyle } from 'web/util/style' diff --git a/src/platforms/web/server/util.ts b/src/platforms/web/server/util.ts index 6ad3a1ed5bf..9fa4e7aa7ed 100644 --- a/src/platforms/web/server/util.ts +++ b/src/platforms/web/server/util.ts @@ -1,4 +1,3 @@ - import { makeMap } from 'shared/util' const isAttr = makeMap( @@ -34,14 +33,14 @@ export const propsToAttrMap = { acceptCharset: 'accept-charset', className: 'class', htmlFor: 'for', - httpEquiv: 'http-equiv', + httpEquiv: 'http-equiv' } const ESC = { '<': '<', '>': '>', '"': '"', - '&': '&', + '&': '&' } export function escape(s: string) { @@ -94,5 +93,5 @@ export const noUnitNumericStyleProps = { 'stroke-dashoffset': true, 'stroke-miterlimit': true, 'stroke-opacity': true, - 'stroke-width': true, + 'stroke-width': true } diff --git a/src/platforms/web/util/attrs.ts b/src/platforms/web/util/attrs.ts index aa3db7aae03..e520c33d09b 100644 --- a/src/platforms/web/util/attrs.ts +++ b/src/platforms/web/util/attrs.ts @@ -1,4 +1,3 @@ - import { makeMap } from 'shared/util' // these are reserved for web because they are directly compiled away diff --git a/src/platforms/web/util/class.ts b/src/platforms/web/util/class.ts index 24255cc7bbf..74323a8770b 100644 --- a/src/platforms/web/util/class.ts +++ b/src/platforms/web/util/class.ts @@ -1,4 +1,3 @@ - import VNode from 'core/vdom/vnode' import { isDef, isObject } from 'shared/util' import type { VNodeData, VNodeWithData } from 'typescript/vnode' @@ -31,7 +30,7 @@ function mergeClassData( } { return { staticClass: concat(child.staticClass, parent.staticClass), - class: isDef(child.class) ? [child.class, parent.class] : parent.class, + class: isDef(child.class) ? [child.class, parent.class] : parent.class } } diff --git a/src/platforms/web/util/compat.ts b/src/platforms/web/util/compat.ts index 08d1d4e0635..eaa0b87aaa9 100644 --- a/src/platforms/web/util/compat.ts +++ b/src/platforms/web/util/compat.ts @@ -1,4 +1,3 @@ - import { inBrowser } from 'core/util/index' // check whether current browser encodes a char inside attribute values diff --git a/src/platforms/web/util/element.ts b/src/platforms/web/util/element.ts index 14fc8a3bacc..e5788c4a029 100644 --- a/src/platforms/web/util/element.ts +++ b/src/platforms/web/util/element.ts @@ -1,10 +1,9 @@ - import { inBrowser } from 'core/util/env' import { makeMap } from 'shared/util' export const namespaceMap = { svg: 'http://www.w3.org/2000/svg', - math: 'http://www.w3.org/1998/Math/MathML', + math: 'http://www.w3.org/1998/Math/MathML' } export const isHTMLTag = makeMap( diff --git a/src/platforms/web/util/index.ts b/src/platforms/web/util/index.ts index d7a53c6bf4e..8bdce82514a 100644 --- a/src/platforms/web/util/index.ts +++ b/src/platforms/web/util/index.ts @@ -1,4 +1,3 @@ - import { warn } from 'core/util/index' export * from './attrs' diff --git a/src/platforms/web/util/style.ts b/src/platforms/web/util/style.ts index 20d2d40fec8..81992af1eaf 100644 --- a/src/platforms/web/util/style.ts +++ b/src/platforms/web/util/style.ts @@ -1,4 +1,3 @@ - import VNode from 'core/vdom/vnode' import { cached, extend, toObject } from 'shared/util' import type { VNodeData, VNodeWithData } from 'typescript/vnode' diff --git a/src/server/bundle-renderer/create-bundle-renderer.ts b/src/server/bundle-renderer/create-bundle-renderer.ts index ba3c730390b..d7587321976 100644 --- a/src/server/bundle-renderer/create-bundle-renderer.ts +++ b/src/server/bundle-renderer/create-bundle-renderer.ts @@ -100,11 +100,11 @@ export function createBundleRendererCreator( } run(context) - .catch((err) => { + .catch(err => { rewriteErrorTrace(err, maps) cb(err) }) - .then((app) => { + .then(app => { if (app) { //@ts-expect-error renderer.renderToString(app, context, (err, res) => { @@ -120,7 +120,7 @@ export function createBundleRendererCreator( renderToStream: (context?: Object) => { const res = new PassThrough() run(context) - .catch((err) => { + .catch(err => { rewriteErrorTrace(err, maps) // avoid emitting synchronously before user can // attach error listener @@ -128,12 +128,12 @@ export function createBundleRendererCreator( res.emit('error', err) }) }) - .then((app) => { + .then(app => { if (app) { //@ts-expect-error const renderStream = renderer.renderToStream(app, context) - renderStream.on('error', (err) => { + renderStream.on('error', err => { rewriteErrorTrace(err, maps) res.emit('error', err) }) diff --git a/src/server/bundle-renderer/create-bundle-runner.ts b/src/server/bundle-renderer/create-bundle-runner.ts index e61fa67f22d..6e9d063693b 100644 --- a/src/server/bundle-renderer/create-bundle-runner.ts +++ b/src/server/bundle-renderer/create-bundle-runner.ts @@ -16,7 +16,7 @@ function createSandbox(context?: any) { clearTimeout, clearInterval, clearImmediate, - __VUE_SSR_CONTEXT__: context, + __VUE_SSR_CONTEXT__: context } // @ts-expect-error @@ -36,7 +36,7 @@ function compileModule(files, basedir, runInNewContext) { const wrapper = NativeModule.wrap(code) const script = new vm.Script(wrapper, { filename, - displayErrors: true, + displayErrors: true }) compiledScripts[filename] = script return script @@ -53,7 +53,7 @@ function compileModule(files, basedir, runInNewContext) { ? script.runInThisContext() : script.runInNewContext(sandbox) const m = { exports: {} } - const r = (file) => { + const r = file => { file = path.posix.join('.', file) if (files[file]) { return evaluateModule(file, sandbox, evaluatedFiles) @@ -97,7 +97,7 @@ export function createBundleRunner(entry, files, basedir, runInNewContext) { // on each render. Ensures entire application state is fresh for each // render, but incurs extra evaluation cost. return (userContext = {}) => - new Promise((resolve) => { + new Promise(resolve => { // @ts-expect-error userContext._registeredComponents = new Set() const res = evaluate(entry, createSandbox(userContext)) @@ -111,7 +111,7 @@ export function createBundleRunner(entry, files, basedir, runInNewContext) { let runner // lazy creation so that errors can be caught by user let initialContext return (userContext = {}) => - new Promise((resolve) => { + new Promise(resolve => { if (!runner) { const sandbox = runInNewContext === 'once' ? createSandbox() : global // the initial context is only used for collecting possible non-component @@ -147,7 +147,7 @@ export function createBundleRunner(entry, files, basedir, runInNewContext) { get() { // @ts-expect-error return renderStyles(userContext._styles) - }, + } }) } } diff --git a/src/server/bundle-renderer/source-map-support.ts b/src/server/bundle-renderer/source-map-support.ts index 27f8a46dcce..6f03ebb131a 100644 --- a/src/server/bundle-renderer/source-map-support.ts +++ b/src/server/bundle-renderer/source-map-support.ts @@ -1,11 +1,10 @@ - const SourceMapConsumer = require('source-map').SourceMapConsumer const filenameRE = /\(([^)]+\.js):(\d+):(\d+)\)$/ export function createSourceMapConsumers(rawMaps: Object) { const maps = {} - Object.keys(rawMaps).forEach((file) => { + Object.keys(rawMaps).forEach(file => { maps[file] = new SourceMapConsumer(rawMaps[file]) }) return maps @@ -20,7 +19,7 @@ export function rewriteErrorTrace( if (e && typeof e.stack === 'string') { e.stack = e.stack .split('\n') - .map((line) => { + .map(line => { return rewriteTraceLine(line, mapConsumers) }) .join('\n') @@ -38,7 +37,7 @@ function rewriteTraceLine( if (m != null && map) { const originalPosition = map.originalPositionFor({ line: Number(m[2]), - column: Number(m[3]), + column: Number(m[3]) }) if (originalPosition.source != null) { const { source, line, column } = originalPosition diff --git a/src/server/create-basic-renderer.ts b/src/server/create-basic-renderer.ts index 733b3e320f1..fc12ec8a73f 100644 --- a/src/server/create-basic-renderer.ts +++ b/src/server/create-basic-renderer.ts @@ -1,4 +1,3 @@ - import { createWriteFunction } from './write' import { createRenderFunction } from './render' import type { RenderOptions } from './create-renderer' @@ -8,7 +7,7 @@ export function createBasicRenderer({ modules = [], directives = {}, isUnaryTag = () => false, - cache, + cache }: RenderOptions = {}) { const render = createRenderFunction(modules, directives, isUnaryTag, cache) @@ -22,7 +21,7 @@ export function createBasicRenderer({ context = {} } let result = '' - const write = createWriteFunction((text) => { + const write = createWriteFunction(text => { result += text return false }, done) diff --git a/src/server/create-renderer.ts b/src/server/create-renderer.ts index 98155488f1b..8005547480a 100644 --- a/src/server/create-renderer.ts +++ b/src/server/create-renderer.ts @@ -85,13 +85,13 @@ export function createRenderer({ } let result = '' - const write = createWriteFunction((text) => { + const write = createWriteFunction(text => { result += text return false }, cb) try { // @ts-expect-error TODO improve - render(component, write, context, (err) => { + render(component, write, context, err => { if (err) { return cb(err) } @@ -103,7 +103,7 @@ export function createRenderer({ const res = templateRenderer.render(result, context) if (typeof res !== 'string') { // function template returning promise - res.then((html) => cb(null, html)).catch(cb) + res.then(html => cb(null, html)).catch(cb) } else { cb(null, res) } @@ -145,7 +145,7 @@ export function createRenderer({ ) } else { const templateStream = templateRenderer.createStream(context) - renderStream.on('error', (err) => { + renderStream.on('error', err => { templateStream.emit('error', err) }) renderStream.pipe(templateStream) diff --git a/src/server/optimizing-compiler/codegen.ts b/src/server/optimizing-compiler/codegen.ts index 1c5dc7bfe65..670a5f6d583 100644 --- a/src/server/optimizing-compiler/codegen.ts +++ b/src/server/optimizing-compiler/codegen.ts @@ -1,4 +1,3 @@ - // The SSR codegen is essentially extending the default codegen to handle // SSR-optimizable nodes and turn them into string render fns. In cases where // a node is not optimizable it simply falls back to the default codegen. @@ -10,7 +9,7 @@ import { genText, genElement, genChildren, - CodegenState, + CodegenState } from 'compiler/codegen/index' import { @@ -18,7 +17,7 @@ import { genDOMPropSegments, genClassSegments, genStyleSegments, - applyModelTransform, + applyModelTransform } from './modules' import { escape } from 'web/server/util' @@ -43,7 +42,7 @@ export function generate( const code = ast ? genSSRElement(ast, state) : '_c("div")' return { render: `with(this){return ${code}}`, - staticRenderFns: state.staticRenderFns, + staticRenderFns: state.staticRenderFns } } @@ -123,16 +122,16 @@ function elementToSegments(el, state): Array { return [ { type: EXPRESSION, - value: genFor(el, state, elementToString, '_ssrList'), - }, + value: genFor(el, state, elementToString, '_ssrList') + } ] } else if (el.if && !el.ifProcessed) { el.ifProcessed = true return [ { type: EXPRESSION, - value: genIf(el, state, elementToString, '""'), - }, + value: genIf(el, state, elementToString, '""') + } ] } else if (el.tag === 'template') { return childrenToSegments(el, state) diff --git a/src/server/optimizing-compiler/index.ts b/src/server/optimizing-compiler/index.ts index a07588d37f3..25b37e419d9 100644 --- a/src/server/optimizing-compiler/index.ts +++ b/src/server/optimizing-compiler/index.ts @@ -1,4 +1,3 @@ - import { parse } from 'compiler/parser/index' import { generate } from './codegen' import { optimize } from './optimizer' @@ -14,6 +13,6 @@ export const createCompiler = createCompilerCreator(function baseCompile( return { ast, render: code.render, - staticRenderFns: code.staticRenderFns, + staticRenderFns: code.staticRenderFns } }) diff --git a/src/server/optimizing-compiler/modules.ts b/src/server/optimizing-compiler/modules.ts index 20c7239718c..9a52768e524 100644 --- a/src/server/optimizing-compiler/modules.ts +++ b/src/server/optimizing-compiler/modules.ts @@ -1,8 +1,7 @@ - import { RAW, // INTERPOLATION, - EXPRESSION, + EXPRESSION } from './codegen' import { propsToAttrMap, isRenderableAttr } from 'web/server/util' @@ -24,7 +23,7 @@ export function applyModelTransform(el: ASTElement, state: CodegenState) { state.directives.model(el, dir, state.warn) // remove value for textarea as its converted to text if (el.tag === 'textarea' && el.props) { - el.props = el.props.filter((p) => p.name !== 'value') + el.props = el.props.filter(p => p.name !== 'value') } break } @@ -45,7 +44,7 @@ export function genDOMPropSegments( name = propsToAttrMap[name] || name.toLowerCase() if ( isRenderableAttr(name) && - !(attrs && attrs.some((a) => a.name === name)) + !(attrs && attrs.some(a => a.name === name)) ) { segments.push(genAttrSegment(name, value)) } @@ -67,12 +66,12 @@ function genAttrSegment(name: string, value: string): StringSegment { ? ` ${name}="${name}"` : value === '""' ? ` ${name}` - : ` ${name}="${JSON.parse(value)}"`, + : ` ${name}="${JSON.parse(value)}"` } } else { return { type: EXPRESSION, - value: `_ssrAttr(${JSON.stringify(name)},${value})`, + value: `_ssrAttr(${JSON.stringify(name)},${value})` } } } @@ -87,8 +86,8 @@ export function genClassSegments( return [ { type: EXPRESSION, - value: `_ssrClass(${staticClass || 'null'},${classBinding || 'null'})`, - }, + value: `_ssrClass(${staticClass || 'null'},${classBinding || 'null'})` + } ] } } @@ -111,8 +110,8 @@ export function genStyleSegments( vShowExpression ? `{ display: (${vShowExpression}) ? '' : 'none' }` : 'null' - })`, - }, + })` + } ] } } diff --git a/src/server/optimizing-compiler/optimizer.ts b/src/server/optimizing-compiler/optimizer.ts index 8e8a70ba176..08afa3d90ab 100644 --- a/src/server/optimizing-compiler/optimizer.ts +++ b/src/server/optimizing-compiler/optimizer.ts @@ -1,4 +1,3 @@ - /** * In SSR, the vdom tree is generated only once and never patched, so * we can optimize most element / trees into plain string render functions. @@ -17,7 +16,7 @@ export const optimizability = { FULL: 1, // whole sub tree optimizable SELF: 2, // self optimizable but has some un-optimizable children CHILDREN: 3, // self un-optimizable but have fully optimizable children - PARTIAL: 4, // self un-optimizable with some un-optimizable children + PARTIAL: 4 // self un-optimizable with some un-optimizable children } let isPlatformReservedTag @@ -35,7 +34,7 @@ function walk(node: ASTNode, isRoot?: boolean) { } // root node or nodes with custom directives should always be a VNode const selfUnoptimizable = isRoot || hasCustomDirective(node) - const check = (child) => { + const check = child => { if (child.ssrOptimizability !== optimizability.FULL) { node.ssrOptimizability = selfUnoptimizable ? optimizability.PARTIAL @@ -86,7 +85,7 @@ function optimizeSiblings(el) { attrsMap: {}, rawAttrsMap: {}, children: currentOptimizableGroup, - ssrOptimizability: optimizability.FULL, + ssrOptimizability: optimizability.FULL }) } currentOptimizableGroup = [] @@ -125,7 +124,7 @@ const isBuiltInDir = makeMap('text,html,show,on,bind,model,pre,cloak,once') function hasCustomDirective(node: ASTNode): boolean { return (node.type === 1 && node.directives && - node.directives.some((d) => !isBuiltInDir(d.name))) as any + node.directives.some(d => !isBuiltInDir(d.name))) as any } // ' + + ' ' + + '
test
' + + 'testAsync' + + '' + ) + done() } - }), (err, result) => { - expect(err).toBeNull() - expect(result).toContain( - '
' + - '

yoyo

' + - '
' + - 'hi ' + - ' ' + - ' ' + - '
test
' + - 'testAsync' + - '
' - ) - done() - }) + ) }) // #5941 it('should work properly when accessing $ssrContext in root component', done => { let ssrContext - renderToString(new Vue({ - template: ` + renderToString( + new Vue({ + template: `
`, - created () { - ssrContext = this.$ssrContext + created() { + ssrContext = this.$ssrContext + } + }), + err => { + expect(err).toBeNull() + expect(ssrContext).toBeUndefined() + done() } - }), (err) => { - expect(err).toBeNull() - expect(ssrContext).toBeUndefined() - done() - }) + ) }) }) diff --git a/test/ssr/ssr-bundle-render.spec.ts b/test/ssr/ssr-bundle-render.spec.ts index fc2161276d8..78ce3301e67 100644 --- a/test/ssr/ssr-bundle-render.spec.ts +++ b/test/ssr/ssr-bundle-render.spec.ts @@ -28,7 +28,7 @@ function createAssertions(runInNewContext) { const res = await new Promise((resolve, reject) => { const stream = renderer.renderToStream(context) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk.toString() }) stream.on('error', reject) @@ -68,7 +68,7 @@ function createAssertions(runInNewContext) { runInNewContext }) - const err = await new Promise((resolve) => { + const err = await new Promise(resolve => { const stream = renderer.renderToStream() stream.on('error', resolve) }) @@ -81,7 +81,7 @@ function createAssertions(runInNewContext) { runInNewContext }) - const err = await new Promise((resolve) => { + const err = await new Promise(resolve => { const stream = renderer.renderToStream() stream.on('error', resolve) }) @@ -141,7 +141,7 @@ function createAssertions(runInNewContext) { cb(!!cache[key]) }, // sync - get: (key) => { + get: key => { get(key) return cache[key] }, @@ -261,7 +261,7 @@ function createAssertions(runInNewContext) { const res = await new Promise((resolve, reject) => { const stream = renderer.renderToStream(context) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk.toString() }) stream.on('error', reject) @@ -295,7 +295,7 @@ function createAssertions(runInNewContext) { asBundle: true }) - const err = await new Promise((resolve) => { + const err = await new Promise(resolve => { const stream = renderer.renderToStream() stream.on('error', resolve) }) @@ -309,7 +309,7 @@ function createAssertions(runInNewContext) { runInNewContext }) const context: any = { url: '/test' } - const res = await new Promise((r) => + const res = await new Promise(r => renderer.renderToString(context, (_err, res) => r(res)) ) expect(res).toBe('
/test
') @@ -320,7 +320,7 @@ function createAssertions(runInNewContext) { const renderer = await createWebpackBundleRenderer('error.js', { runInNewContext }) - const err = await new Promise((r) => renderer.renderToString(r)) + const err = await new Promise(r => renderer.renderToString(r)) expect(err.message).toBe('foo') }) } diff --git a/test/ssr/ssr-stream.spec.ts b/test/ssr/ssr-stream.spec.ts index e4157f03bd2..6d4ed10c1ee 100644 --- a/test/ssr/ssr-stream.spec.ts +++ b/test/ssr/ssr-stream.spec.ts @@ -6,8 +6,9 @@ const { renderToStream } = createRenderer() describe('SSR: renderToStream', () => { it('should render to a stream', done => { - const stream = renderToStream(new Vue({ - template: ` + const stream = renderToStream( + new Vue({ + template: `

yoyo

@@ -17,36 +18,43 @@ describe('SSR: renderToStream', () => {
`, - data: { - test: 'hi', - isRed: true, - testClass: 'a' - }, - components: { - bComp (resolve) { - return resolve({ - render (h) { - return h('test-async-2') - }, - components: { - testAsync2 (resolve) { - return resolve({ - created () { this.$parent.$parent.testClass = 'b' }, - render (h) { - return h('div', { class: [this.$parent.$parent.testClass] }, 'test') - } - }) + data: { + test: 'hi', + isRed: true, + testClass: 'a' + }, + components: { + bComp(resolve) { + return resolve({ + render(h) { + return h('test-async-2') + }, + components: { + testAsync2(resolve) { + return resolve({ + created() { + this.$parent.$parent.testClass = 'b' + }, + render(h) { + return h( + 'div', + { class: [this.$parent.$parent.testClass] }, + 'test' + ) + } + }) + } } + }) + }, + cComp: { + render(h) { + return h('div', { class: [this.$parent.testClass] }, 'test') } - }) - }, - cComp: { - render (h) { - return h('div', { class: [this.$parent.testClass] }, 'test') } } - } - })) + }) + ) let res = '' stream.on('data', chunk => { res += chunk @@ -60,18 +68,20 @@ describe('SSR: renderToStream', () => { ' ' + '
test
' + '
test
' + - '' + '' ) done() }) }) it('should catch error', done => { - const stream = renderToStream(new Vue({ - render () { - throw new Error('oops') - } - })) + const stream = renderToStream( + new Vue({ + render() { + throw new Error('oops') + } + }) + ) stream.on('error', err => { expect(err.toString()).toMatch(/oops/) expect(`oops`).toHaveBeenWarned() @@ -81,7 +91,7 @@ describe('SSR: renderToStream', () => { }) it('should not mingle two components', done => { - const padding = (new Array(20000)).join('x') + const padding = new Array(20000).join('x') const component1 = new Vue({ template: `
${padding}
`, _scopeId: '_component1' @@ -93,7 +103,7 @@ describe('SSR: renderToStream', () => { const stream1 = renderToStream(component1) const stream2 = renderToStream(component2) let res = '' - stream1.on('data', (text) => { + stream1.on('data', text => { res += text.toString('utf-8').replace(/x/g, '') }) stream1.on('end', () => { @@ -106,15 +116,18 @@ describe('SSR: renderToStream', () => { it('should call context.rendered', done => { let a = 0 - const stream = renderToStream(new Vue({ - template: ` + const stream = renderToStream( + new Vue({ + template: `
Hello
` - }), { - rendered: () => { - a = 42 + }), + { + rendered: () => { + a = 42 + } } - }) + ) let res = '' stream.on('data', chunk => { res += chunk diff --git a/test/ssr/ssr-string.spec.ts b/test/ssr/ssr-string.spec.ts index d3d3dc49ea2..9f07a379927 100644 --- a/test/ssr/ssr-string.spec.ts +++ b/test/ssr/ssr-string.spec.ts @@ -7,555 +7,713 @@ const { renderToString } = createRenderer() describe('SSR: renderToString', () => { it('static attributes', done => { - renderVmWithOptions({ - template: '
' - }, result => { - expect(result).toContain('
') - done() - }) + renderVmWithOptions( + { + template: '
' + }, + result => { + expect(result).toContain( + '
' + ) + done() + } + ) }) it('unary tags', done => { - renderVmWithOptions({ - template: '' - }, result => { - expect(result).toContain('') - done() - }) + renderVmWithOptions( + { + template: '' + }, + result => { + expect(result).toContain( + '' + ) + done() + } + ) }) it('dynamic attributes', done => { - renderVmWithOptions({ - template: '
', - data: { - foo: 'hi', - baz: 123 + renderVmWithOptions( + { + template: '
', + data: { + foo: 'hi', + baz: 123 + } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain('
') - done() - }) + ) }) it('static class', done => { - renderVmWithOptions({ - template: '
' - }, result => { - expect(result).toContain('
') - done() - }) + renderVmWithOptions( + { + template: '
' + }, + result => { + expect(result).toContain( + '
' + ) + done() + } + ) }) it('dynamic class', done => { - renderVmWithOptions({ - template: '
', - data: { - a: 'baz', - hasQux: true, - hasQuux: false + renderVmWithOptions( + { + template: + '
', + data: { + a: 'baz', + hasQux: true, + hasQuux: false + } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain('
') - done() - }) + ) }) it('custom component class', done => { - renderVmWithOptions({ - template: '
', - components: { - cmp: { - render: h => h('div', 'test') + renderVmWithOptions( + { + template: '
', + components: { + cmp: { + render: h => h('div', 'test') + } } + }, + result => { + expect(result).toContain( + '
test
' + ) + done() } - }, result => { - expect(result).toContain('
test
') - done() - }) + ) }) it('nested component class', done => { - renderVmWithOptions({ - template: '', - data: { cls: { 'success': 1 }}, - components: { - cmp: { - render: h => h('div', [h('nested', { staticClass: 'nested', 'class': { 'error': 1 }})]), - components: { - nested: { - render: h => h('div', { staticClass: 'inner' }, 'test') + renderVmWithOptions( + { + template: '', + data: { cls: { success: 1 } }, + components: { + cmp: { + render: h => + h('div', [ + h('nested', { staticClass: 'nested', class: { error: 1 } }) + ]), + components: { + nested: { + render: h => h('div', { staticClass: 'inner' }, 'test') + } } } } + }, + result => { + expect(result).toContain( + '
' + + '
test
' + + '
' + ) + done() } - }, result => { - expect(result).toContain('
' + - '
test
' + - '
') - done() - }) + ) }) it('dynamic style', done => { - renderVmWithOptions({ - template: '
', - data: { - fontSize: 14, - color: 'red' - } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + renderVmWithOptions( + { + template: + '
', + data: { + fontSize: 14, + color: 'red' + } + }, + result => { + expect(result).toContain( + '
' + ) + done() + } + ) }) it('dynamic string style', done => { - renderVmWithOptions({ - template: '
', - data: { - style: 'color:red' + renderVmWithOptions( + { + template: '
', + data: { + style: 'color:red' + } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('auto-prefixed style value as array', done => { - renderVmWithOptions({ - template: '
', - data: { - style: { - display: ['-webkit-box', '-ms-flexbox', 'flex'] + renderVmWithOptions( + { + template: '
', + data: { + style: { + display: ['-webkit-box', '-ms-flexbox', 'flex'] + } } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('custom component style', done => { - renderVmWithOptions({ - template: '
', - data: { - style: 'color:red' - }, - components: { - comp: { - template: '
' + renderVmWithOptions( + { + template: '
', + data: { + style: 'color:red' + }, + components: { + comp: { + template: '
' + } } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('nested custom component style', done => { - renderVmWithOptions({ - template: '', - data: { - style: 'color:red' - }, - components: { - comp: { - template: '', - components: { - nested: { - template: '
' + renderVmWithOptions( + { + template: '', + data: { + style: 'color:red' + }, + components: { + comp: { + template: + '', + components: { + nested: { + template: '
' + } } } } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('component style not passed to child', done => { - renderVmWithOptions({ - template: '', - data: { - style: 'color:red' - }, - components: { - comp: { - template: '
' + renderVmWithOptions( + { + template: '', + data: { + style: 'color:red' + }, + components: { + comp: { + template: '
' + } } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('component style not passed to slot', done => { - renderVmWithOptions({ - template: '', - data: { - style: 'color:red' - }, - components: { - comp: { - template: '
' + renderVmWithOptions( + { + template: + '', + data: { + style: 'color:red' + }, + components: { + comp: { + template: '
' + } } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('attrs merging on components', done => { const Test = { - render: h => h('div', { - attrs: { id: 'a' } - }) + render: h => + h('div', { + attrs: { id: 'a' } + }) } - renderVmWithOptions({ - render: h => h(Test, { - attrs: { id: 'b', name: 'c' } - }) - }, res => { - expect(res).toContain( - '
' - ) - done() - }) + renderVmWithOptions( + { + render: h => + h(Test, { + attrs: { id: 'b', name: 'c' } + }) + }, + res => { + expect(res).toContain( + '
' + ) + done() + } + ) }) it('domProps merging on components', done => { const Test = { - render: h => h('div', { - domProps: { innerHTML: 'a' } - }) + render: h => + h('div', { + domProps: { innerHTML: 'a' } + }) } - renderVmWithOptions({ - render: h => h(Test, { - domProps: { innerHTML: 'b', value: 'c' } - }) - }, res => { - expect(res).toContain( - '
b
' - ) - done() - }) + renderVmWithOptions( + { + render: h => + h(Test, { + domProps: { innerHTML: 'b', value: 'c' } + }) + }, + res => { + expect(res).toContain( + '
b
' + ) + done() + } + ) }) it('v-show directive render', done => { - renderVmWithOptions({ - template: '
inner
' - }, res => { - expect(res).toContain( - '
inner
' - ) - done() - }) + renderVmWithOptions( + { + template: '
inner
' + }, + res => { + expect(res).toContain( + '
inner
' + ) + done() + } + ) }) it('v-show directive merge with style', done => { - renderVmWithOptions({ - template: '
inner
' - }, res => { - expect(res).toContain( - '
inner
' - ) - done() - }) + renderVmWithOptions( + { + template: + '
inner
' + }, + res => { + expect(res).toContain( + '
inner
' + ) + done() + } + ) }) it('v-show directive not passed to child', done => { - renderVmWithOptions({ - template: '', - components: { - foo: { - template: '
inner
' + renderVmWithOptions( + { + template: '', + components: { + foo: { + template: '
inner
' + } } + }, + res => { + expect(res).toContain( + '
inner
' + ) + done() } - }, res => { - expect(res).toContain( - '
inner
' - ) - done() - }) + ) }) it('v-show directive not passed to slot', done => { - renderVmWithOptions({ - template: 'inner', - components: { - foo: { - template: '
' + renderVmWithOptions( + { + template: 'inner', + components: { + foo: { + template: '
' + } } + }, + res => { + expect(res).toContain( + '
inner
' + ) + done() } - }, res => { - expect(res).toContain( - '
inner
' - ) - done() - }) + ) }) it('v-show directive merging on components', done => { - renderVmWithOptions({ - template: '', - components: { - foo: { - render: h => h('bar', { - directives: [{ - name: 'show', - value: true - }] - }), - components: { - bar: { - render: h => h('div', 'inner') + renderVmWithOptions( + { + template: '', + components: { + foo: { + render: h => + h('bar', { + directives: [ + { + name: 'show', + value: true + } + ] + }), + components: { + bar: { + render: h => h('div', 'inner') + } } } } + }, + res => { + expect(res).toContain( + '
inner
' + ) + done() } - }, res => { - expect(res).toContain( - '
inner
' - ) - done() - }) + ) }) it('text interpolation', done => { - renderVmWithOptions({ - template: '
{{ foo }} side {{ bar }}
', - data: { - foo: 'server', - bar: 'rendering' + renderVmWithOptions( + { + template: '
{{ foo }} side {{ bar }}
', + data: { + foo: 'server', + bar: 'rendering' + } + }, + result => { + expect(result).toContain( + '
server side <span>rendering</span>
' + ) + done() } - }, result => { - expect(result).toContain('
server side <span>rendering</span>
') - done() - }) + ) }) it('v-html on root', done => { - renderVmWithOptions({ - template: '
', - data: { - text: 'foo' + renderVmWithOptions( + { + template: '
', + data: { + text: 'foo' + } + }, + result => { + expect(result).toContain( + '
foo
' + ) + done() } - }, result => { - expect(result).toContain('
foo
') - done() - }) + ) }) it('v-text on root', done => { - renderVmWithOptions({ - template: '
', - data: { - text: 'foo' + renderVmWithOptions( + { + template: '
', + data: { + text: 'foo' + } + }, + result => { + expect(result).toContain( + '
<span>foo</span>
' + ) + done() } - }, result => { - expect(result).toContain('
<span>foo</span>
') - done() - }) + ) }) it('v-html', done => { - renderVmWithOptions({ - template: '
', - data: { - text: 'foo' + renderVmWithOptions( + { + template: '
', + data: { + text: 'foo' + } + }, + result => { + expect(result).toContain( + '
foo
' + ) + done() } - }, result => { - expect(result).toContain('
foo
') - done() - }) + ) }) it('v-html with null value', done => { - renderVmWithOptions({ - template: '
', - data: { - text: null + renderVmWithOptions( + { + template: '
', + data: { + text: null + } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain('
') - done() - }) + ) }) it('v-text', done => { - renderVmWithOptions({ - template: '
', - data: { - text: 'foo' + renderVmWithOptions( + { + template: '
', + data: { + text: 'foo' + } + }, + result => { + expect(result).toContain( + '
<span>foo</span>
' + ) + done() } - }, result => { - expect(result).toContain('
<span>foo</span>
') - done() - }) + ) }) it('v-text with null value', done => { - renderVmWithOptions({ - template: '
', - data: { - text: null + renderVmWithOptions( + { + template: '
', + data: { + text: null + } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain('
') - done() - }) + ) }) it('child component (hoc)', done => { - renderVmWithOptions({ - template: '', - data: { - msg: 'hello' - }, - components: { - child: { - props: ['msg'], - data () { - return { name: 'bar' } - }, - render () { - const h = this.$createElement - return h('div', { class: ['bar'] }, [`${this.msg} ${this.name}`]) + renderVmWithOptions( + { + template: '', + data: { + msg: 'hello' + }, + components: { + child: { + props: ['msg'], + data() { + return { name: 'bar' } + }, + render() { + const h = this.$createElement + return h('div', { class: ['bar'] }, [`${this.msg} ${this.name}`]) + } } } + }, + result => { + expect(result).toContain( + '
hello bar
' + ) + done() } - }, result => { - expect(result).toContain('
hello bar
') - done() - }) + ) }) it('has correct lifecycle during render', done => { let lifecycleCount = 1 - renderVmWithOptions({ - template: '
{{ val }}
', - data: { - val: 'hi' - }, - beforeCreate () { - expect(lifecycleCount++).toBe(1) - }, - created () { - this.val = 'hello' - expect(this.val).toBe('hello') - expect(lifecycleCount++).toBe(2) - }, - components: { - test: { - beforeCreate () { - expect(lifecycleCount++).toBe(3) - }, - created () { - expect(lifecycleCount++).toBe(4) - }, - render () { - expect(lifecycleCount++).toBeGreaterThan(4) - return this.$createElement('span', { class: ['b'] }, 'testAsync') + renderVmWithOptions( + { + template: '
{{ val }}
', + data: { + val: 'hi' + }, + beforeCreate() { + expect(lifecycleCount++).toBe(1) + }, + created() { + this.val = 'hello' + expect(this.val).toBe('hello') + expect(lifecycleCount++).toBe(2) + }, + components: { + test: { + beforeCreate() { + expect(lifecycleCount++).toBe(3) + }, + created() { + expect(lifecycleCount++).toBe(4) + }, + render() { + expect(lifecycleCount++).toBeGreaterThan(4) + return this.$createElement('span', { class: ['b'] }, 'testAsync') + } } } + }, + result => { + expect(result).toContain( + '
' + + 'hello' + + 'testAsync' + + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' + - 'hello' + - 'testAsync' + - '
' - ) - done() - }) + ) }) it('computed properties', done => { - renderVmWithOptions({ - template: '
{{ b }}
', - data: { - a: { - b: 1 - } - }, - computed: { - b () { - return this.a.b + 1 + renderVmWithOptions( + { + template: '
{{ b }}
', + data: { + a: { + b: 1 + } + }, + computed: { + b() { + return this.a.b + 1 + } + }, + created() { + this.a.b = 2 + expect(this.b).toBe(3) } }, - created () { - this.a.b = 2 - expect(this.b).toBe(3) + result => { + expect(result).toContain('
3
') + done() } - }, result => { - expect(result).toContain('
3
') - done() - }) + ) }) it('renders async component', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
`, - components: { - testAsync (resolve) { - setTimeout(() => resolve({ - render () { - return this.$createElement('span', { class: ['b'] }, 'testAsync') - } - }), 1) + components: { + testAsync(resolve) { + setTimeout( + () => + resolve({ + render() { + return this.$createElement( + 'span', + { class: ['b'] }, + 'testAsync' + ) + } + }), + 1 + ) + } } + }, + result => { + expect(result).toContain( + '
testAsync
' + ) + done() } - }, result => { - expect(result).toContain('
testAsync
') - done() - }) + ) }) it('renders async component (Promise, nested)', done => { - const Foo = () => Promise.resolve({ - render: h => h('div', [h('span', 'foo'), h(Bar)]) - }) + const Foo = () => + Promise.resolve({ + render: h => h('div', [h('span', 'foo'), h(Bar)]) + }) const Bar = () => ({ component: Promise.resolve({ render: h => h('span', 'bar') }) }) - renderVmWithOptions({ - render: h => h(Foo) - }, res => { - expect(res).toContain(`
foobar
`) - done() - }) + renderVmWithOptions( + { + render: h => h(Foo) + }, + res => { + expect(res).toContain( + `
foobar
` + ) + done() + } + ) }) it('renders async component (ES module)', done => { - const Foo = () => Promise.resolve({ - __esModule: true, - default: { - render: h => h('div', [h('span', 'foo'), h(Bar)]) - } - }) + const Foo = () => + Promise.resolve({ + __esModule: true, + default: { + render: h => h('div', [h('span', 'foo'), h(Bar)]) + } + }) const Bar = () => ({ component: Promise.resolve({ __esModule: true, @@ -564,135 +722,181 @@ describe('SSR: renderToString', () => { } }) }) - renderVmWithOptions({ - render: h => h(Foo) - }, res => { - expect(res).toContain(`
foobar
`) - done() - }) + renderVmWithOptions( + { + render: h => h(Foo) + }, + res => { + expect(res).toContain( + `
foobar
` + ) + done() + } + ) }) it('renders async component (hoc)', done => { - renderVmWithOptions({ - template: '', - components: { - testAsync: () => Promise.resolve({ - render () { - return this.$createElement('span', { class: ['b'] }, 'testAsync') - } - }) + renderVmWithOptions( + { + template: '', + components: { + testAsync: () => + Promise.resolve({ + render() { + return this.$createElement( + 'span', + { class: ['b'] }, + 'testAsync' + ) + } + }) + } + }, + result => { + expect(result).toContain( + 'testAsync' + ) + done() } - }, result => { - expect(result).toContain('testAsync') - done() - }) + ) }) it('renders async component (functional, single node)', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
`, - components: { - testAsync (resolve) { - setTimeout(() => resolve({ - functional: true, - render (h) { - return h('span', { class: ['b'] }, 'testAsync') - } - }), 1) + components: { + testAsync(resolve) { + setTimeout( + () => + resolve({ + functional: true, + render(h) { + return h('span', { class: ['b'] }, 'testAsync') + } + }), + 1 + ) + } } + }, + result => { + expect(result).toContain( + '
testAsync
' + ) + done() } - }, result => { - expect(result).toContain('
testAsync
') - done() - }) + ) }) it('renders async component (functional, multiple nodes)', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
`, - components: { - testAsync (resolve) { - setTimeout(() => resolve({ - functional: true, - render (h) { - return [ - h('span', { class: ['a'] }, 'foo'), - h('span', { class: ['b'] }, 'bar') - ] - } - }), 1) + components: { + testAsync(resolve) { + setTimeout( + () => + resolve({ + functional: true, + render(h) { + return [ + h('span', { class: ['a'] }, 'foo'), + h('span', { class: ['b'] }, 'bar') + ] + } + }), + 1 + ) + } } + }, + result => { + expect(result).toContain( + '
' + + 'foo' + + 'bar' + + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' + - 'foo' + - 'bar' + - '
' - ) - done() - }) + ) }) it('renders nested async functional component', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
`, - components: { - outerAsync (resolve) { - setTimeout(() => resolve({ - functional: true, - render (h) { - return h('innerAsync') - } - }), 1) - }, - innerAsync (resolve) { - setTimeout(() => resolve({ - functional: true, - render (h) { - return h('span', { class: ['a'] }, 'inner') - }, - }), 1) + components: { + outerAsync(resolve) { + setTimeout( + () => + resolve({ + functional: true, + render(h) { + return h('innerAsync') + } + }), + 1 + ) + }, + innerAsync(resolve) { + setTimeout( + () => + resolve({ + functional: true, + render(h) { + return h('span', { class: ['a'] }, 'inner') + } + }), + 1 + ) + } } + }, + result => { + expect(result).toContain( + '
' + + 'inner' + + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' + - 'inner' + - '
' - ) - done() - }) + ) }) it('should catch async component error', done => { - renderToString(new Vue({ - template: '', - components: { - testAsync: () => Promise.resolve({ - render () { - throw new Error('foo') - } - }) + renderToString( + new Vue({ + template: '', + components: { + testAsync: () => + Promise.resolve({ + render() { + throw new Error('foo') + } + }) + } + }), + (err, result) => { + expect(err).toBeTruthy() + expect(result).toBeUndefined() + expect('foo').toHaveBeenWarned() + done() } - }), (err, result) => { - expect(err).toBeTruthy() - expect(result).toBeUndefined() - expect('foo').toHaveBeenWarned() - done() - }) + ) }) // #11963, #10391 @@ -703,29 +907,33 @@ describe('SSR: renderToString', () => { const Child = { template: `

child

` } - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: ` `, - components: { - Parent, - Child: () => Promise.resolve(Child) - } - }, result => { - expect(result).toContain( - `

child

` - ) - done() - }) + components: { + Parent, + Child: () => Promise.resolve(Child) + } + }, + result => { + expect(result).toContain( + `

child

` + ) + done() + } + ) }) it('everything together', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `

yoyo

@@ -736,44 +944,51 @@ describe('SSR: renderToString', () => {
`, - data: { - test: 'hi', - isRed: true, - imageUrl: 'https://vuejs.org/images/logo.png' - }, - components: { - test: { - render () { - return this.$createElement('div', { class: ['a'] }, 'test') - } + data: { + test: 'hi', + isRed: true, + imageUrl: 'https://vuejs.org/images/logo.png' }, - testAsync (resolve) { - resolve({ - render () { - return this.$createElement('span', { class: ['b'] }, 'testAsync') + components: { + test: { + render() { + return this.$createElement('div', { class: ['a'] }, 'test') } - }) + }, + testAsync(resolve) { + resolve({ + render() { + return this.$createElement( + 'span', + { class: ['b'] }, + 'testAsync' + ) + } + }) + } } + }, + result => { + expect(result).toContain( + '
' + + '

yoyo

' + + '
' + + 'hi ' + + ' ' + + ' ' + + '
test
' + + 'testAsync' + + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' + - '

yoyo

' + - '
' + - 'hi ' + - ' ' + - ' ' + - '
test
' + - 'testAsync' + - '
' - ) - done() - }) + ) }) it('normal attr', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
hello hello @@ -782,23 +997,26 @@ describe('SSR: renderToString', () => { hello
` - }, result => { - expect(result).toContain( - '
' + - 'hello ' + - 'hello ' + - 'hello ' + - 'hello ' + - 'hello' + - '
' - ) - done() - }) + }, + result => { + expect(result).toContain( + '
' + + 'hello ' + + 'hello ' + + 'hello ' + + 'hello ' + + 'hello' + + '
' + ) + done() + } + ) }) it('enumerated attr', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
hello hello @@ -808,24 +1026,27 @@ describe('SSR: renderToString', () => { hello
` - }, result => { - expect(result).toContain( - '
' + - 'hello ' + - 'hello ' + - 'hello ' + - 'hello ' + - 'hello ' + - 'hello' + - '
' - ) - done() - }) + }, + result => { + expect(result).toContain( + '
' + + 'hello ' + + 'hello ' + + 'hello ' + + 'hello ' + + 'hello ' + + 'hello' + + '
' + ) + done() + } + ) }) it('boolean attr', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
hello hello @@ -833,29 +1054,36 @@ describe('SSR: renderToString', () => { hello
` - }, result => { - expect(result).toContain( - '
' + - 'hello ' + - 'hello ' + - 'hello ' + - 'hello' + - '
' - ) - done() - }) + }, + result => { + expect(result).toContain( + '
' + + 'hello ' + + 'hello ' + + 'hello ' + + 'hello' + + '
' + ) + done() + } + ) }) it('v-bind object', done => { - renderVmWithOptions({ - data: { - test: { id: 'a', class: ['a', 'b'], value: 'c' } + renderVmWithOptions( + { + data: { + test: { id: 'a', class: ['a', 'b'], value: 'c' } + }, + template: '' }, - template: '' - }, result => { - expect(result).toContain('') - done() - }) + result => { + expect(result).toContain( + '' + ) + done() + } + ) }) it('custom directives', done => { @@ -871,108 +1099,136 @@ describe('SSR: renderToString', () => { } } }) - renderer.renderToString(new Vue({ - render () { - const h = this.$createElement - return h('p', { - class: 'class1', - staticClass: 'class2', - directives: [{ - name: 'class-prefixer', - value: 'my' - }] - }, ['hello world']) - } - }), (err, result) => { - expect(err).toBeNull() - expect(result).toContain('

hello world

') - done() - }) + renderer.renderToString( + new Vue({ + render() { + const h = this.$createElement + return h( + 'p', + { + class: 'class1', + staticClass: 'class2', + directives: [ + { + name: 'class-prefixer', + value: 'my' + } + ] + }, + ['hello world'] + ) + } + }), + (err, result) => { + expect(err).toBeNull() + expect(result).toContain( + '

hello world

' + ) + done() + } + ) }) it('should not warn for custom directives that do not have server-side implementation', done => { - renderToString(new Vue({ - directives: { - test: { - bind() { - // noop + renderToString( + new Vue({ + directives: { + test: { + bind() { + // noop + } } - } - }, - template: '
', - }), () => { - expect('Failed to resolve directive: test').not.toHaveBeenWarned() - done() - }) + }, + template: '
' + }), + () => { + expect('Failed to resolve directive: test').not.toHaveBeenWarned() + done() + } + ) }) it('_scopeId', done => { - renderVmWithOptions({ - _scopeId: '_v-parent', - template: '

', - components: { - child: { - _scopeId: '_v-child', - render () { - const h = this.$createElement - return h('div', null, [h('span', null, ['foo'])]) + renderVmWithOptions( + { + _scopeId: '_v-parent', + template: '

', + components: { + child: { + _scopeId: '_v-child', + render() { + const h = this.$createElement + return h('div', null, [h('span', null, ['foo'])]) + } } } - } - }, result => { - expect(result).toContain( - '
' + - '

' + + }, + result => { + expect(result).toContain( + '

' + + '

' + '

foo
' + - '

' + - '
' - ) - done() - }) + '

' + + '
' + ) + done() + } + ) }) it('_scopeId on slot content', done => { - renderVmWithOptions({ - _scopeId: '_v-parent', - template: '

foo

', - components: { - child: { - _scopeId: '_v-child', - render () { - const h = this.$createElement - return h('div', null, this.$slots.default) + renderVmWithOptions( + { + _scopeId: '_v-parent', + template: '

foo

', + components: { + child: { + _scopeId: '_v-child', + render() { + const h = this.$createElement + return h('div', null, this.$slots.default) + } } } + }, + result => { + expect(result).toContain( + '
' + + '

foo

' + + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' + - '

foo

' + - '
' - ) - done() - }) + ) }) it('comment nodes', done => { - renderVmWithOptions({ - template: '
' - }, result => { - expect(result).toContain(`
`) - done() - }) + renderVmWithOptions( + { + template: '
' + }, + result => { + expect(result).toContain( + `
` + ) + done() + } + ) }) it('should catch error', done => { - renderToString(new Vue({ - render () { - throw new Error('oops') - } - }), err => { - expect(err instanceof Error).toBe(true) - expect(`oops`).toHaveBeenWarned() - done() - }) + renderToString( + new Vue({ + render() { + throw new Error('oops') + } + }), + err => { + expect(err instanceof Error).toBe(true) + expect(`oops`).toHaveBeenWarned() + done() + } + ) }) it('default value Foreign Function', () => { @@ -993,98 +1249,121 @@ describe('SSR: renderToString', () => { }) it('should prevent xss in attributes', done => { - renderVmWithOptions({ - data: { - xss: '">' - }, - template: ` + renderVmWithOptions( + { + data: { + xss: '">' + }, + template: `
foo
` - }, res => { - expect(res).not.toContain(``) - done() - }) + }, + res => { + expect(res).not.toContain(``) + done() + } + ) }) it('should prevent xss in attribute names', done => { - renderVmWithOptions({ - data: { - xss: { - 'foo="bar">': '' - } - }, - template: ` + renderVmWithOptions( + { + data: { + xss: { + 'foo="bar">': '' + } + }, + template: `
` - }, res => { - expect(res).not.toContain(``) - done() - }) + }, + res => { + expect(res).not.toContain(``) + done() + } + ) }) it('should prevent xss in attribute names (optimized)', done => { - renderVmWithOptions({ - data: { - xss: { - 'foo="bar">': '' - } - }, - template: ` + renderVmWithOptions( + { + data: { + xss: { + 'foo="bar">': '' + } + }, + template: `
foo
` - }, res => { - expect(res).not.toContain(``) - done() - }) + }, + res => { + expect(res).not.toContain(``) + done() + } + ) }) it('should prevent script xss with v-bind object syntax + array value', done => { - renderVmWithOptions({ - data: { - test: ['">`) - done() - }) + }, + res => { + expect(res).toContain( + `
foo
` + ) + done() + } + ) }) it('v-for', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
foo {{ i }}
` - }, res => { - expect(res).toContain(`
foo 12
`) - done() - }) + }, + res => { + expect(res).toContain( + `
foo 12
` + ) + done() + } + ) }) it('template v-if', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
foo
` - }, res => { - expect(res).toContain(`
foo foo bar baz
`) - done() - }) + }, + res => { + expect(res).toContain( + `
foo foo bar baz
` + ) + done() + } + ) }) it('template v-for', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
foo
` - }, res => { - expect(res).toContain(`
foo 1bar2bar
`) - done() - }) + }, + res => { + expect(res).toContain( + `
foo 1bar2bar
` + ) + done() + } + ) }) it('with inheritAttrs: false + $attrs', done => { - renderVmWithOptions({ - template: ``, - components: { - foo: { - inheritAttrs: false, - template: `
` + renderVmWithOptions( + { + template: ``, + components: { + foo: { + inheritAttrs: false, + template: `
` + } } + }, + res => { + expect(res).toBe( + `
` + ) + done() } - }, res => { - expect(res).toBe(`
`) - done() - }) + ) }) it('should escape static strings', done => { - renderVmWithOptions({ - template: `
<foo>
` - }, res => { - expect(res).toBe(`
<foo>
`) - done() - }) + renderVmWithOptions( + { + template: `
<foo>
` + }, + res => { + expect(res).toBe(`
<foo>
`) + done() + } + ) }) it('should not cache computed properties', done => { - renderVmWithOptions({ - template: `
{{ foo }}
`, - data: () => ({ bar: 1 }), - computed: { - foo () { return this.bar + 1 } - }, - created () { - this.foo // access - this.bar++ // trigger change - } - }, res => { - expect(res).toBe(`
3
`) - done() - }) + renderVmWithOptions( + { + template: `
{{ foo }}
`, + data: () => ({ bar: 1 }), + computed: { + foo() { + return this.bar + 1 + } + }, + created() { + this.foo // access + this.bar++ // trigger change + } + }, + res => { + expect(res).toBe(`
3
`) + done() + } + ) }) // #8977 it('should call computed properties with vm as first argument', done => { - renderToString(new Vue({ - data: { - firstName: 'Evan', - lastName: 'You' - }, - computed: { - fullName: ({ firstName, lastName }) => `${firstName} ${lastName}`, - }, - template: '
{{ fullName }}
', - }), (err, result) => { - expect(err).toBeNull() - expect(result).toContain('
Evan You
') - done() - }) + renderToString( + new Vue({ + data: { + firstName: 'Evan', + lastName: 'You' + }, + computed: { + fullName: ({ firstName, lastName }) => `${firstName} ${lastName}` + }, + template: '
{{ fullName }}
' + }), + (err, result) => { + expect(err).toBeNull() + expect(result).toContain( + '
Evan You
' + ) + done() + } + ) }) it('return Promise', async () => { - await renderToString(new Vue({ - template: `
{{ foo }}
`, - data: { foo: 'bar' } - }))!.then(res => { + await renderToString( + new Vue({ + template: `
{{ foo }}
`, + data: { foo: 'bar' } + }) + )!.then(res => { expect(res).toBe(`
bar
`) }) }) it('return Promise (error)', async () => { - await renderToString(new Vue({ - render () { - throw new Error('foobar') - } - }))!.catch(err => { + await renderToString( + new Vue({ + render() { + throw new Error('foobar') + } + }) + )!.catch(err => { expect('foobar').toHaveBeenWarned() expect(err.toString()).toContain(`foobar`) }) }) it('should catch template compilation error', done => { - renderToString(new Vue({ - template: `
` - }), (err) => { - expect(err.toString()).toContain('Component template should contain exactly one root element') - done() - }) + renderToString( + new Vue({ + template: `
` + }), + err => { + expect(err.toString()).toContain( + 'Component template should contain exactly one root element' + ) + done() + } + ) }) // #6907 it('should not optimize root if conditions', done => { - renderVmWithOptions({ - data: { foo: 123 }, - template: `` - }, res => { - expect(res).toBe(``) - done() - }) + renderVmWithOptions( + { + data: { foo: 123 }, + template: `` + }, + res => { + expect(res).toBe( + `` + ) + done() + } + ) }) it('render muted properly', done => { - renderVmWithOptions({ - template: '' - }, result => { - expect(result).toContain('') - done() - }) + renderVmWithOptions( + { + template: '' + }, + result => { + expect(result).toContain( + '' + ) + done() + } + ) }) it('render v-model with textarea', done => { - renderVmWithOptions({ - data: { foo: 'bar' }, - template: '
' - }, result => { - expect(result).toContain('') - done() - }) + renderVmWithOptions( + { + data: { foo: 'bar' }, + template: '
' + }, + result => { + expect(result).toContain('') + done() + } + ) }) it('render v-model with textarea (non-optimized)', done => { - renderVmWithOptions({ - render (h) { - return h('textarea', { - domProps: { - value: 'foo' - } - }) + renderVmWithOptions( + { + render(h) { + return h('textarea', { + domProps: { + value: 'foo' + } + }) + } + }, + result => { + expect(result).toContain( + '' + ) + done() } - }, result => { - expect(result).toContain('') - done() - }) + ) }) it('render v-model with ` - }, result => { - expect(result).toContain( - '' - ) - done() - }) + }, + result => { + expect(result).toContain( + '' + ) + done() + } + ) }) it('render v-model with @@ -1287,203 +1624,230 @@ describe('SSR: renderToString', () => { ` - }, result => { - expect(result).toContain( - '' - ) - done() - }) + }, + result => { + expect(result).toContain( + '' + ) + done() + } + ) }) it('render v-model with ` - }, result => { - expect(result).toContain( - '' - ) - done() - }) + }, + result => { + expect(result).toContain( + '' + ) + done() + } + ) }) // #7223 it('should not double escape attribute values', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
` - }, result => { - expect(result).toContain(`
`) - done() - }) + }, + result => { + expect(result).toContain(`
`) + done() + } + ) }) // #7859 it('should not double escape class values', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
` - }, result => { - expect(result).toContain(`
`) - done() - }) + }, + result => { + expect(result).toContain(`
`) + done() + } + ) }) it('should expose ssr helpers on functional context', done => { let called = false - renderVmWithOptions({ - template: `
`, - components: { - foo: { - functional: true, - render (h, ctx) { - expect(ctx._ssrNode).toBeTruthy() - called = true + renderVmWithOptions( + { + template: `
`, + components: { + foo: { + functional: true, + render(h, ctx) { + expect(ctx._ssrNode).toBeTruthy() + called = true + } } } + }, + () => { + expect(called).toBe(true) + done() } - }, () => { - expect(called).toBe(true) - done() - }) + ) }) it('should support serverPrefetch option', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
{{ count }}
`, - data: { - count: 0 + data: { + count: 0 + }, + serverPrefetch() { + return new Promise(resolve => { + setTimeout(() => { + this.count = 42 + resolve() + }, 1) + }) + } }, - serverPrefetch () { - return new Promise((resolve) => { - setTimeout(() => { - this.count = 42 - resolve() - }, 1) - }) + result => { + expect(result).toContain('
42
') + done() } - }, result => { - expect(result).toContain('
42
') - done() - }) + ) }) it('should support serverPrefetch option (nested)', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
{{ count }}
`, - data: { - count: 0 - }, - serverPrefetch () { - return new Promise((resolve) => { - setTimeout(() => { - this.count = 42 - resolve() - }, 1) - }) - }, - components: { - nestedPrefetch: { - template: ` + data: { + count: 0 + }, + serverPrefetch() { + return new Promise(resolve => { + setTimeout(() => { + this.count = 42 + resolve() + }, 1) + }) + }, + components: { + nestedPrefetch: { + template: `
{{ message }}
`, - data () { - return { - message: '' + data() { + return { + message: '' + } + }, + serverPrefetch() { + return new Promise(resolve => { + setTimeout(() => { + this.message = 'vue.js' + resolve() + }, 1) + }) } - }, - serverPrefetch () { - return new Promise((resolve) => { - setTimeout(() => { - this.message = 'vue.js' - resolve() - }, 1) - }) } } + }, + result => { + expect(result).toContain( + '
42
vue.js
' + ) + done() } - }, result => { - expect(result).toContain('
42
vue.js
') - done() - }) + ) }) it('should support serverPrefetch option (nested async)', done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
{{ count }}
`, - data: { - count: 0 - }, - serverPrefetch () { - return new Promise((resolve) => { - setTimeout(() => { - this.count = 42 - resolve() - }, 1) - }) - }, - components: { - nestedPrefetch (resolve) { - resolve({ - template: ` + data: { + count: 0 + }, + serverPrefetch() { + return new Promise(resolve => { + setTimeout(() => { + this.count = 42 + resolve() + }, 1) + }) + }, + components: { + nestedPrefetch(resolve) { + resolve({ + template: `
{{ message }}
`, - data () { - return { - message: '' + data() { + return { + message: '' + } + }, + serverPrefetch() { + return new Promise(resolve => { + setTimeout(() => { + this.message = 'vue.js' + resolve() + }, 1) + }) } - }, - serverPrefetch () { - return new Promise((resolve) => { - setTimeout(() => { - this.message = 'vue.js' - resolve() - }, 1) - }) - } - }) + }) + } } + }, + result => { + expect(result).toContain( + '
42
vue.js
' + ) + done() } - }, result => { - expect(result).toContain('
42
vue.js
') - done() - }) + ) }) it('should merge serverPrefetch option', done => { @@ -1491,8 +1855,8 @@ describe('SSR: renderToString', () => { data: { message: '' }, - serverPrefetch () { - return new Promise((resolve) => { + serverPrefetch() { + return new Promise(resolve => { setTimeout(() => { this.message = 'vue.js' resolve() @@ -1500,106 +1864,124 @@ describe('SSR: renderToString', () => { }) } } - renderVmWithOptions({ - mixins: [mixin], - template: ` + renderVmWithOptions( + { + mixins: [mixin], + template: `
{{ count }}
{{ message }}
`, - data: { - count: 0 + data: { + count: 0 + }, + serverPrefetch() { + return new Promise(resolve => { + setTimeout(() => { + this.count = 42 + resolve() + }, 1) + }) + } }, - serverPrefetch () { - return new Promise((resolve) => { - setTimeout(() => { - this.count = 42 - resolve() - }, 1) - }) + result => { + expect(result).toContain( + '
42
vue.js
' + ) + done() } - }, result => { - expect(result).toContain('
42
vue.js
') - done() - }) + ) }) it(`should skip serverPrefetch option that doesn't return a promise`, done => { - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
{{ count }}
`, - data: { - count: 0 + data: { + count: 0 + }, + serverPrefetch() { + setTimeout(() => { + this.count = 42 + }, 1) + } }, - serverPrefetch () { - setTimeout(() => { - this.count = 42 - }, 1) + result => { + expect(result).toContain('
0
') + done() } - }, result => { - expect(result).toContain('
0
') - done() - }) + ) }) it('should call context.rendered', done => { let a = 0 - renderToString(new Vue({ - template: '
Hello
' - }), { - rendered: () => { - a = 42 - } - }, (err, res) => { - expect(err).toBeNull() - expect(res).toContain('
Hello
') - expect(a).toBe(42) - done() - }) + renderToString( + new Vue({ + template: '
Hello
' + }), + { + rendered: () => { + a = 42 + } + }, + (err, res) => { + expect(err).toBeNull() + expect(res).toContain('
Hello
') + expect(a).toBe(42) + done() + } + ) }) it('invalid style value', done => { - renderVmWithOptions({ - template: '

', - data: { - // all invalid, should not even have "style" attribute - style: { - opacity: {}, - color: null - }, - // mix of valid and invalid - style2: { - opacity: 0, - color: null + renderVmWithOptions( + { + template: '

', + data: { + // all invalid, should not even have "style" attribute + style: { + opacity: {}, + color: null + }, + // mix of valid and invalid + style2: { + opacity: 0, + color: null + } } + }, + result => { + expect(result).toContain( + '

' + ) + done() } - }, result => { - expect(result).toContain( - '

' - ) - done() - }) + ) }) it('numeric style value', done => { - renderVmWithOptions({ - template: '
', - data: { - style: { - opacity: 0, // valid, opacity is unit-less - top: 0, // valid, top requires unit but 0 is allowed - left: 10, // invalid, left requires a unit - marginTop: '10px' // valid + renderVmWithOptions( + { + template: '
', + data: { + style: { + opacity: 0, // valid, opacity is unit-less + top: 0, // valid, top requires unit but 0 is allowed + left: 10, // invalid, left requires a unit + marginTop: '10px' // valid + } } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('handling max stack size limit', done => { @@ -1621,22 +2003,25 @@ describe('SSR: renderToString', () => { }) it('undefined v-model with textarea', done => { - renderVmWithOptions({ - render (h) { - return h('div', [ - h('textarea', { - domProps: { - value: null - } - }) - ]) + renderVmWithOptions( + { + render(h) { + return h('div', [ + h('textarea', { + domProps: { + value: null + } + }) + ]) + } + }, + result => { + expect(result).toContain( + '
' + ) + done() } - }, result => { - expect(result).toContain( - '
' - ) - done() - }) + ) }) it('Options inheritAttrs in parent component', done => { @@ -1644,28 +2029,33 @@ describe('SSR: renderToString', () => { template: `
{{ someProp }}
`, props: { someProp: {} - }, + } } const parentComponent = { template: ``, components: { childComponent }, inheritAttrs: false } - renderVmWithOptions({ - template: ` + renderVmWithOptions( + { + template: `
`, - components: { parentComponent } - }, result => { - expect(result).toContain('
some-val
') - done() - }) + components: { parentComponent } + }, + result => { + expect(result).toContain( + '
some-val
' + ) + done() + } + ) }) }) -function renderVmWithOptions (options, cb) { +function renderVmWithOptions(options, cb) { renderToString(new Vue(options), (err, res) => { expect(err).toBeNull() cb(res) diff --git a/test/ssr/ssr-template.spec.ts b/test/ssr/ssr-template.spec.ts index 8c77c89d4bc..ba716f4ea7b 100644 --- a/test/ssr/ssr-template.spec.ts +++ b/test/ssr/ssr-template.spec.ts @@ -118,7 +118,7 @@ describe('SSR: template option', () => { head: '', styles: '', state: { a: 0 }, - rendered: (context) => { + rendered: context => { context.state.a = 1 } } @@ -167,7 +167,7 @@ describe('SSR: template option', () => { it('renderToString w/ template function returning Promise', async () => { const renderer = createRenderer({ template: (content, context) => - new Promise((resolve) => { + new Promise(resolve => { setTimeout(() => { resolve(`${context.head}${content}`) }, 0) @@ -236,7 +236,7 @@ describe('SSR: template option', () => { ) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk }) stream.on('error', reject) @@ -275,7 +275,7 @@ describe('SSR: template option', () => { ) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk }) stream.on('error', reject) @@ -308,7 +308,7 @@ describe('SSR: template option', () => { head: '', styles: '', state: { a: 0 }, - rendered: (context) => { + rendered: context => { context.state.a = 1 } } @@ -322,7 +322,7 @@ describe('SSR: template option', () => { ) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk }) stream.on('error', reject) @@ -377,10 +377,10 @@ describe('SSR: template option', () => { url: '/test' } - const res = await new Promise((resolve) => { + const res = await new Promise(resolve => { const stream = renderer.renderToStream(context) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk.toString() }) stream.on('end', () => { @@ -454,10 +454,10 @@ describe('SSR: template option', () => { } } }) - const res = await new Promise((resolve) => { + const res = await new Promise(resolve => { const stream = renderer.renderToStream({ state: { a: 1 } }) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk.toString() }) stream.on('end', () => { @@ -482,10 +482,10 @@ describe('SSR: template option', () => { } }) - const res = await new Promise((resolve) => { + const res = await new Promise(resolve => { const stream = renderer.renderToStream({ state: { a: 1 } }) let res = '' - stream.on('data', (chunk) => { + stream.on('data', chunk => { res += chunk.toString() }) stream.on('end', () => { diff --git a/test/transition/helpers.ts b/test/transition/helpers.ts index f6a405f0cf7..a47fd01cb55 100644 --- a/test/transition/helpers.ts +++ b/test/transition/helpers.ts @@ -18,7 +18,7 @@ console.info = noop let asserted function createCompareFn(spy) { - const hasWarned = (msg) => { + const hasWarned = msg => { let count = spy.calls.count() let args while (count--) { @@ -34,7 +34,7 @@ function createCompareFn(spy) { } return { - compare: (msg) => { + compare: msg => { asserted = asserted.concat(msg) const warned = Array.isArray(msg) ? msg.some(hasWarned) : hasWarned(msg) return { @@ -60,9 +60,9 @@ beforeEach(() => { }) }) -afterEach((done) => { - const warned = (msg) => - asserted.some((assertedMsg) => msg.toString().indexOf(assertedMsg) > -1) +afterEach(done => { + const warned = msg => + asserted.some(assertedMsg => msg.toString().indexOf(assertedMsg) > -1) // @ts-ignore let count = console.error.calls.count() let args diff --git a/test/transition/transition-group.spec.ts b/test/transition/transition-group.spec.ts index a9c1ab62ffe..2c1905dbb7e 100644 --- a/test/transition/transition-group.spec.ts +++ b/test/transition/transition-group.spec.ts @@ -30,20 +30,20 @@ describe('Transition group', () => { if (!appear) { expect(vm.$el.innerHTML).toBe( `` + - vm.items.map((i) => `
${i}
`).join('') + + vm.items.map(i => `
${i}
`).join('') + `
` ) } return vm } - it('enter', (done) => { + it('enter', done => { const vm = createBasicVM() vm.items.push('d', 'e') waitForUpdate(() => { expect(vm.$el.innerHTML).toBe( `` + - ['a', 'b', 'c'].map((i) => `
${i}
`).join('') + + ['a', 'b', 'c'].map(i => `
${i}
`).join('') + `
d
` + `
e
` + `
` @@ -53,9 +53,7 @@ describe('Transition group', () => { .then(() => { expect(vm.$el.innerHTML).toBe( `` + - ['a', 'b', 'c'] - .map((i) => `
${i}
`) - .join('') + + ['a', 'b', 'c'].map(i => `
${i}
`).join('') + `
d
` + `
e
` + `
` @@ -65,14 +63,14 @@ describe('Transition group', () => { .then(() => { expect(vm.$el.innerHTML).toBe( `` + - vm.items.map((i) => `
${i}
`).join('') + + vm.items.map(i => `
${i}
`).join('') + `
` ) }) .then(done) }) - it('leave', (done) => { + it('leave', done => { const vm = createBasicVM() vm.items = ['b'] waitForUpdate(() => { @@ -98,14 +96,14 @@ describe('Transition group', () => { .then(() => { expect(vm.$el.innerHTML).toBe( `` + - vm.items.map((i) => `
${i}
`).join('') + + vm.items.map(i => `
${i}
`).join('') + `
` ) }) .then(done) }) - it('enter + leave', (done) => { + it('enter + leave', done => { const vm = createBasicVM() vm.items = ['b', 'c', 'd'] waitForUpdate(() => { @@ -133,14 +131,14 @@ describe('Transition group', () => { .then(() => { expect(vm.$el.innerHTML).toBe( `` + - vm.items.map((i) => `
${i}
`).join('') + + vm.items.map(i => `
${i}
`).join('') + `
` ) }) .then(done) }) - it('use with "is" attribute', (done) => { + it('use with "is" attribute', done => { const vm = createBasicVM(true) vm.items = ['b', 'c', 'd'] waitForUpdate(() => { @@ -168,20 +166,20 @@ describe('Transition group', () => { .then(() => { expect(vm.$el.innerHTML).toBe( `` + - vm.items.map((i) => `
${i}
`).join('') + + vm.items.map(i => `
${i}
`).join('') + `
` ) }) .then(done) }) - it('appear', (done) => { + it('appear', done => { const vm = createBasicVM(false, true /* appear */) waitForUpdate(() => { expect(vm.$el.innerHTML).toBe( `` + vm.items - .map((i) => `
${i}
`) + .map(i => `
${i}
`) .join('') + `
` ) @@ -192,7 +190,7 @@ describe('Transition group', () => { `` + vm.items .map( - (i) => `
${i}
` + i => `
${i}
` ) .join('') + `
` @@ -202,14 +200,14 @@ describe('Transition group', () => { .then(() => { expect(vm.$el.innerHTML).toBe( `` + - vm.items.map((i) => `
${i}
`).join('') + + vm.items.map(i => `
${i}
`).join('') + `
` ) }) .then(done) }) - it('events', (done) => { + it('events', done => { let next const beforeEnterSpy = jasmine.createSpy() const afterEnterSpy = jasmine.createSpy() @@ -255,7 +253,7 @@ describe('Transition group', () => { ) expect(beforeEnterSpy.calls.count()).toBe(1) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -270,7 +268,7 @@ describe('Transition group', () => { expect(afterEnterSpy.calls.count()).toBe(1) vm.items.shift() }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -286,7 +284,7 @@ describe('Transition group', () => { .then(done) }) - it('move', (done) => { + it('move', done => { const vm = new Vue({ template: `
@@ -345,7 +343,7 @@ describe('Transition group', () => { }) // GitHub issue #6006 - it('should work with dynamic name', (done) => { + it('should work with dynamic name', done => { const vm = new Vue({ template: `
diff --git a/test/transition/transition-mode.spec.ts b/test/transition/transition-mode.spec.ts index eba58ecbef5..779dd33f7e2 100644 --- a/test/transition/transition-mode.spec.ts +++ b/test/transition/transition-mode.spec.ts @@ -14,7 +14,7 @@ describe('Transition mode', () => { document.body.appendChild(el) }) - it('dynamic components, simultaneous', (done) => { + it('dynamic components, simultaneous', done => { const vm = new Vue({ template: `
@@ -47,7 +47,7 @@ describe('Transition mode', () => { .then(done) }) - it('dynamic components, out-in', (done) => { + it('dynamic components, out-in', done => { let next const vm = new Vue({ template: `
@@ -77,7 +77,7 @@ describe('Transition mode', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -103,7 +103,7 @@ describe('Transition mode', () => { }) // #3440 - it('dynamic components, out-in (with extra re-render)', (done) => { + it('dynamic components, out-in (with extra re-render)', done => { let next const vm = new Vue({ template: `
@@ -136,7 +136,7 @@ describe('Transition mode', () => { // this should not cause the incoming element to enter early vm.$forceUpdate() }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -161,7 +161,7 @@ describe('Transition mode', () => { .then(done) }) - it('dynamic components, in-out', (done) => { + it('dynamic components, in-out', done => { let next const vm = new Vue({ template: `
@@ -193,7 +193,7 @@ describe('Transition mode', () => { '
two
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -221,7 +221,7 @@ describe('Transition mode', () => { .then(done) }) - it('dynamic components, in-out with early cancel', (done) => { + it('dynamic components, in-out with early cancel', done => { let next const vm = new Vue({ template: `
@@ -271,7 +271,7 @@ describe('Transition mode', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -299,7 +299,7 @@ describe('Transition mode', () => { .then(done) }) - it('normal elements with different keys, simultaneous', (done) => { + it('normal elements with different keys, simultaneous', done => { const vm = new Vue({ template: `
@@ -331,7 +331,7 @@ describe('Transition mode', () => { .then(done) }) - it('normal elements with different keys, out-in', (done) => { + it('normal elements with different keys, out-in', done => { let next const vm = new Vue({ template: `
@@ -360,7 +360,7 @@ describe('Transition mode', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -385,7 +385,7 @@ describe('Transition mode', () => { .then(done) }) - it('normal elements with different keys, in-out', (done) => { + it('normal elements with different keys, in-out', done => { let next const vm = new Vue({ template: `
@@ -416,7 +416,7 @@ describe('Transition mode', () => { '
two
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -444,7 +444,7 @@ describe('Transition mode', () => { .then(done) }) - it('transition out-in on async component (resolve before leave complete)', (done) => { + it('transition out-in on async component (resolve before leave complete)', done => { const vm = new Vue({ template: `
@@ -455,13 +455,13 @@ describe('Transition mode', () => {
`, components: { - componentA: (resolve) => { + componentA: resolve => { setTimeout(() => { resolve({ template: '

component A

' }) next1() }, duration / 2) }, - componentB: (resolve) => { + componentB: resolve => { setTimeout(() => { resolve({ template: '

component B

' }) }, duration / 2) @@ -522,7 +522,7 @@ describe('Transition mode', () => { } }) - it('transition out-in on async component (resolve after leave complete)', (done) => { + it('transition out-in on async component (resolve after leave complete)', done => { const vm = new Vue({ template: `
@@ -534,7 +534,7 @@ describe('Transition mode', () => { `, components: { componentA: { template: '

component A

' }, - componentB: (resolve) => { + componentB: resolve => { setTimeout(() => { resolve({ template: '

component B

' }) Vue.nextTick(next) @@ -569,7 +569,7 @@ describe('Transition mode', () => { expect(vm.$el.children.length).toBe(0) expect(vm.$el.innerHTML).toBe('') }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -594,7 +594,7 @@ describe('Transition mode', () => { .then(done) }) - it('transition in-out on async component', (done) => { + it('transition in-out on async component', done => { const vm = new Vue({ template: `
@@ -605,13 +605,13 @@ describe('Transition mode', () => {
`, components: { - componentA: (resolve) => { + componentA: resolve => { setTimeout(() => { resolve({ template: '

component A

' }) next1() }, duration / 2) }, - componentB: (resolve) => { + componentB: resolve => { setTimeout(() => { resolve({ template: '

component B

' }) next2() diff --git a/test/transition/transition-with-keep-alive.spec.ts b/test/transition/transition-with-keep-alive.spec.ts index 09c6613046a..128255e0981 100644 --- a/test/transition/transition-with-keep-alive.spec.ts +++ b/test/transition/transition-with-keep-alive.spec.ts @@ -40,7 +40,7 @@ describe('Transition w/ KeepAlive', () => { ]).toEqual(callCounts) } - it('with transition-mode out-in', (done) => { + it('with transition-mode out-in', done => { let next const vm = new Vue({ template: `
@@ -77,7 +77,7 @@ describe('Transition w/ KeepAlive', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -119,7 +119,7 @@ describe('Transition w/ KeepAlive', () => { '
two
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -148,7 +148,7 @@ describe('Transition w/ KeepAlive', () => { .then(done) }) - it('with transition-mode out-in + include', (done) => { + it('with transition-mode out-in + include', done => { let next const vm = new Vue({ template: `
@@ -185,7 +185,7 @@ describe('Transition w/ KeepAlive', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -227,7 +227,7 @@ describe('Transition w/ KeepAlive', () => { '
two
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -256,7 +256,7 @@ describe('Transition w/ KeepAlive', () => { .then(done) }) - it('with transition-mode in-out', (done) => { + it('with transition-mode in-out', done => { let next const vm = new Vue({ template: `
@@ -295,7 +295,7 @@ describe('Transition w/ KeepAlive', () => { '
two
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -340,7 +340,7 @@ describe('Transition w/ KeepAlive', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -370,7 +370,7 @@ describe('Transition w/ KeepAlive', () => { .then(done) }) - it('dynamic components, in-out with early cancel', (done) => { + it('dynamic components, in-out with early cancel', done => { let next const vm = new Vue({ template: `
@@ -422,7 +422,7 @@ describe('Transition w/ KeepAlive', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -451,7 +451,7 @@ describe('Transition w/ KeepAlive', () => { }) // #4339 - it('component with inner transition', (done) => { + it('component with inner transition', done => { const vm = new Vue({ template: `
@@ -513,16 +513,16 @@ describe('Transition w/ KeepAlive', () => { .then(done) }) - it('async components with transition-mode out-in', (done) => { + it('async components with transition-mode out-in', done => { const barResolve = jasmine.createSpy() let next - const foo = (resolve) => { + const foo = resolve => { setTimeout(() => { resolve(one) Vue.nextTick(next) }, duration / 2) } - const bar = (resolve) => { + const bar = resolve => { setTimeout(() => { resolve(two) barResolve() @@ -568,7 +568,7 @@ describe('Transition w/ KeepAlive', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -584,7 +584,7 @@ describe('Transition w/ KeepAlive', () => { '
one
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -607,7 +607,7 @@ describe('Transition w/ KeepAlive', () => { '
two
' ) }) - .thenWaitFor((_next) => { + .thenWaitFor(_next => { next = _next }) .then(() => { @@ -619,7 +619,7 @@ describe('Transition w/ KeepAlive', () => { }) // #10083 - it('should not attach event handler repeatedly', (done) => { + it('should not attach event handler repeatedly', done => { const vm = new Vue({ template: ` diff --git a/test/transition/transition.spec.ts b/test/transition/transition.spec.ts index e84a3cfa563..bff2e0fefd7 100644 --- a/test/transition/transition.spec.ts +++ b/test/transition/transition.spec.ts @@ -14,7 +14,7 @@ describe('Transition basic', () => { document.body.appendChild(el) }) - it('basic transition', (done) => { + it('basic transition', done => { const vm = new Vue({ template: '
foo
', @@ -54,7 +54,7 @@ describe('Transition basic', () => { .then(done) }) - it('named transition', (done) => { + it('named transition', done => { const vm = new Vue({ template: '
foo
', @@ -98,7 +98,7 @@ describe('Transition basic', () => { .then(done) }) - it('custom transition classes', (done) => { + it('custom transition classes', done => { const vm = new Vue({ template: `
@@ -147,7 +147,7 @@ describe('Transition basic', () => { .then(done) }) - it('dynamic transition', (done) => { + it('dynamic transition', done => { const vm = new Vue({ template: `
@@ -200,7 +200,7 @@ describe('Transition basic', () => { .then(done) }) - it('inline transition object', (done) => { + it('inline transition object', done => { const enter = jasmine.createSpy() const leave = jasmine.createSpy() const vm = new Vue({ @@ -261,7 +261,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition events', (done) => { + it('transition events', done => { const onLeaveSpy = jasmine.createSpy() const onEnterSpy = jasmine.createSpy() const beforeLeaveSpy = jasmine.createSpy() @@ -286,23 +286,23 @@ describe('Transition basic', () => { `, data: { ok: true }, methods: { - beforeLeave: (el) => { + beforeLeave: el => { expect(el).toBe(vm.$el.children[0]) expect(el.className).toBe('test') beforeLeaveSpy(el) }, - leave: (el) => onLeaveSpy(el), - afterLeave: (el) => afterLeaveSpy(el), - beforeEnter: (el) => { + leave: el => onLeaveSpy(el), + afterLeave: el => afterLeaveSpy(el), + beforeEnter: el => { expect(vm.$el.contains(el)).toBe(false) expect(el.className).toBe('test') beforeEnterSpy(el) }, - enter: (el) => { + enter: el => { expect(vm.$el.contains(el)).toBe(true) onEnterSpy(el) }, - afterEnter: (el) => afterEnterSpy(el) + afterEnter: el => afterEnterSpy(el) } }).$mount(el) @@ -354,7 +354,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition events (v-show)', (done) => { + it('transition events (v-show)', done => { const onLeaveSpy = jasmine.createSpy() const onEnterSpy = jasmine.createSpy() const beforeLeaveSpy = jasmine.createSpy() @@ -379,30 +379,30 @@ describe('Transition basic', () => { `, data: { ok: true }, methods: { - beforeLeave: (el) => { + beforeLeave: el => { expect(el.style.display).toBe('') expect(el).toBe(vm.$el.children[0]) expect(el.className).toBe('test') beforeLeaveSpy(el) }, - leave: (el) => { + leave: el => { expect(el.style.display).toBe('') onLeaveSpy(el) }, - afterLeave: (el) => { + afterLeave: el => { expect(el.style.display).toBe('none') afterLeaveSpy(el) }, - beforeEnter: (el) => { + beforeEnter: el => { expect(el.className).toBe('test') expect(el.style.display).toBe('none') beforeEnterSpy(el) }, - enter: (el) => { + enter: el => { expect(el.style.display).toBe('') onEnterSpy(el) }, - afterEnter: (el) => { + afterEnter: el => { expect(el.style.display).toBe('') afterEnterSpy(el) } @@ -457,7 +457,7 @@ describe('Transition basic', () => { .then(done) }) - it('explicit user callback in JavaScript hooks', (done) => { + it('explicit user callback in JavaScript hooks', done => { let next const vm = new Vue({ template: `
@@ -522,7 +522,7 @@ describe('Transition basic', () => { .then(done) }) - it('css: false', (done) => { + it('css: false', done => { const enterSpy = jasmine.createSpy() const leaveSpy = jasmine.createSpy() const vm = new Vue({ @@ -553,7 +553,7 @@ describe('Transition basic', () => { .then(done) }) - it('no transition detected', (done) => { + it('no transition detected', done => { const enterSpy = jasmine.createSpy() const leaveSpy = jasmine.createSpy() const vm = new Vue({ @@ -591,7 +591,7 @@ describe('Transition basic', () => { .then(done) }) - it('enterCancelled', (done) => { + it('enterCancelled', done => { const spy = jasmine.createSpy() const vm = new Vue({ template: ` @@ -643,7 +643,7 @@ describe('Transition basic', () => { .then(done) }) - it('should remove stale leaving elements', (done) => { + it('should remove stale leaving elements', done => { const spy = jasmine.createSpy() const vm = new Vue({ template: ` @@ -690,7 +690,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition with v-show', (done) => { + it('transition with v-show', done => { const vm = new Vue({ template: `
@@ -742,7 +742,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition with v-show, inside child component', (done) => { + it('transition with v-show, inside child component', done => { const vm = new Vue({ template: `
@@ -796,7 +796,7 @@ describe('Transition basic', () => { .then(done) }) - it('leaveCancelled (v-show only)', (done) => { + it('leaveCancelled (v-show only)', done => { const spy = jasmine.createSpy() const vm = new Vue({ template: ` @@ -848,7 +848,7 @@ describe('Transition basic', () => { .then(done) }) - it('leave transition with v-show: cancelled on next frame', (done) => { + it('leave transition with v-show: cancelled on next frame', done => { const vm = new Vue({ template: `
@@ -877,7 +877,7 @@ describe('Transition basic', () => { .then(done) }) - it('enter transition with v-show: cancelled on next frame', (done) => { + it('enter transition with v-show: cancelled on next frame', done => { const vm = new Vue({ template: `
@@ -906,7 +906,7 @@ describe('Transition basic', () => { .then(done) }) - it('animations', (done) => { + it('animations', done => { const vm = new Vue({ template: `
@@ -955,7 +955,7 @@ describe('Transition basic', () => { .then(done) }) - it('explicit transition type', (done) => { + it('explicit transition type', done => { const vm = new Vue({ template: `
@@ -1017,7 +1017,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition on appear', (done) => { + it('transition on appear', done => { const vm = new Vue({ template: `
@@ -1051,7 +1051,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition on appear with v-show', (done) => { + it('transition on appear with v-show', done => { const vm = new Vue({ template: `
@@ -1081,7 +1081,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition on SVG elements', (done) => { + it('transition on SVG elements', done => { const vm = new Vue({ template: ` @@ -1132,7 +1132,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition on child components', (done) => { + it('transition on child components', done => { const vm = new Vue({ template: `
@@ -1186,7 +1186,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition inside child component with v-if', (done) => { + it('transition inside child component with v-if', done => { const vm = new Vue({ template: `
@@ -1228,7 +1228,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition with appear inside child component with v-if', (done) => { + it('transition with appear inside child component with v-if', done => { const vm = new Vue({ template: `
@@ -1282,7 +1282,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition inside nested child component with v-if', (done) => { + it('transition inside nested child component with v-if', done => { const vm = new Vue({ template: `
@@ -1325,7 +1325,7 @@ describe('Transition basic', () => { .then(done) }) - it('transition with appear inside nested child component with v-if', (done) => { + it('transition with appear inside nested child component with v-if', done => { const vm = new Vue({ template: `
@@ -1384,7 +1384,7 @@ describe('Transition basic', () => { .then(done) }) - it('custom transition higher-order component', (done) => { + it('custom transition higher-order component', done => { const vm = new Vue({ template: '
foo
', @@ -1447,7 +1447,7 @@ describe('Transition basic', () => { }) describe('explicit durations -', () => { - it('single value', (done) => { + it('single value', done => { const vm = new Vue({ template: `
@@ -1493,7 +1493,7 @@ describe('Transition basic', () => { .then(done) }) - it('enter and auto leave', (done) => { + it('enter and auto leave', done => { const vm = new Vue({ template: `
@@ -1539,7 +1539,7 @@ describe('Transition basic', () => { .then(done) }) - it('leave and auto enter', (done) => { + it('leave and auto enter', done => { const vm = new Vue({ template: `
@@ -1585,7 +1585,7 @@ describe('Transition basic', () => { .then(done) }) - it('separate enter and leave', (done) => { + it('separate enter and leave', done => { const enter = explicitDuration const leave = explicitDuration * 2 @@ -1634,7 +1634,7 @@ describe('Transition basic', () => { .then(done) }) - it('enter and leave + duration change', (done) => { + it('enter and leave + duration change', done => { const enter1 = explicitDuration * 2 const enter2 = explicitDuration const leave1 = explicitDuration * 0.5 @@ -1725,7 +1725,7 @@ describe('Transition basic', () => { .then(done) }, 10000) - it('warn invalid durations', (done) => { + it('warn invalid durations', done => { const vm = new Vue({ template: `
@@ -1759,7 +1759,7 @@ describe('Transition basic', () => { }) // #6687 - it('transition on child components with empty root node', (done) => { + it('transition on child components with empty root node', done => { const vm = new Vue({ template: `
@@ -1819,7 +1819,7 @@ describe('Transition basic', () => { }) // #8199 - it('should not throw error when replaced by v-html contents', (done) => { + it('should not throw error when replaced by v-html contents', done => { const vm = new Vue({ template: `
diff --git a/test/unit/.eslintrc.json b/test/unit/.eslintrc.json deleted file mode 100644 index 5973f4d4b0c..00000000000 --- a/test/unit/.eslintrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "globals": { - "waitForUpdate": true, - "triggerEvent": true, - "createTextVNode": true - } -} diff --git a/test/unit/features/component/component-async.spec.ts b/test/unit/features/component/component-async.spec.ts index 9e08cfa59db..ec1ec2484fe 100644 --- a/test/unit/features/component/component-async.spec.ts +++ b/test/unit/features/component/component-async.spec.ts @@ -46,11 +46,11 @@ describe('Component async', () => { expect(JSON.stringify(timeoutsPending)).toEqual(JSON.stringify({})) }) - it('normal', (done) => { + it('normal', done => { const vm = new Vue({ template: '
', components: { - test: (resolve) => { + test: resolve => { setTimeout(() => { resolve({ template: '
hi
' @@ -71,11 +71,11 @@ describe('Component async', () => { } }) - it('resolve ES module default', (done) => { + it('resolve ES module default', done => { const vm = new Vue({ template: '
', components: { - test: (resolve) => { + test: resolve => { setTimeout(() => { resolve({ __esModule: true, @@ -99,11 +99,11 @@ describe('Component async', () => { } }) - it('as root', (done) => { + it('as root', done => { const vm = new Vue({ template: '', components: { - test: (resolve) => { + test: resolve => { setTimeout(() => { resolve({ template: '
hi
' @@ -125,14 +125,14 @@ describe('Component async', () => { } }) - it('dynamic', (done) => { + it('dynamic', done => { const vm = new Vue({ template: '', data: { view: 'view-a' }, components: { - 'view-a': (resolve) => { + 'view-a': resolve => { setTimeout(() => { resolve({ template: '
A
' @@ -140,7 +140,7 @@ describe('Component async', () => { Vue.nextTick(step1) }, 0) }, - 'view-b': (resolve) => { + 'view-b': resolve => { setTimeout(() => { resolve({ template: '

B

' @@ -184,14 +184,14 @@ describe('Component async', () => { expect('Reason: nooooo').toHaveBeenWarned() }) - it('with v-for', (done) => { + it('with v-for', done => { const vm = new Vue({ template: '
', data: { list: [1, 2, 3] }, components: { - test: (resolve) => { + test: resolve => { setTimeout(() => { resolve({ props: ['n'], @@ -209,12 +209,12 @@ describe('Component async', () => { } }) - it('returning Promise', (done) => { + it('returning Promise', done => { const vm = new Vue({ template: '
', components: { test: () => { - return new Promise((resolve) => { + return new Promise(resolve => { setTimeout(() => { resolve({ template: '
hi
' @@ -239,12 +239,12 @@ describe('Component async', () => { }) describe('loading/error/timeout', () => { - it('with loading component', (done) => { + it('with loading component', done => { const vm = new Vue({ template: `
`, components: { test: () => ({ - component: new Promise((resolve) => { + component: new Promise(resolve => { setTimeout(() => { resolve({ template: '
hi
' }) // wait for promise resolve and then parent update @@ -276,12 +276,12 @@ describe('Component async', () => { } }) - it('with loading component (0 delay)', (done) => { + it('with loading component (0 delay)', done => { const vm = new Vue({ template: `
`, components: { test: () => ({ - component: new Promise((resolve) => { + component: new Promise(resolve => { setTimeout(() => { resolve({ template: '
hi
' }) // wait for promise resolve and then parent update @@ -304,7 +304,7 @@ describe('Component async', () => { } }) - it('with error component', (done) => { + it('with error component', done => { const vm = new Vue({ template: `
`, components: { @@ -334,7 +334,7 @@ describe('Component async', () => { } }) - it('with error component + timeout', (done) => { + it('with error component + timeout', done => { const vm = new Vue({ template: `
`, components: { @@ -371,7 +371,7 @@ describe('Component async', () => { } }) - it('should not trigger timeout if resolved', (done) => { + it('should not trigger timeout if resolved', done => { const vm = new Vue({ template: `
`, components: { @@ -394,7 +394,7 @@ describe('Component async', () => { }, 50) }) - it('should not have running timeout/loading if resolved', (done) => { + it('should not have running timeout/loading if resolved', done => { const vm = new Vue({ template: `
`, components: { @@ -423,7 +423,7 @@ describe('Component async', () => { }) // #7107 - it(`should work when resolving sync in sibling component's mounted hook`, (done) => { + it(`should work when resolving sync in sibling component's mounted hook`, done => { let resolveTwo const vm = new Vue({ @@ -435,7 +435,7 @@ describe('Component async', () => { resolveTwo() } }, - two: (resolve) => { + two: resolve => { resolveTwo = () => { resolve({ template: `
two
` diff --git a/test/unit/features/component/component-keep-alive.spec.ts b/test/unit/features/component/component-keep-alive.spec.ts index 833a33ea9f1..28722d0c6a6 100644 --- a/test/unit/features/component/component-keep-alive.spec.ts +++ b/test/unit/features/component/component-keep-alive.spec.ts @@ -37,7 +37,7 @@ describe('Component keep-alive', () => { ]).toEqual(callCounts) } - it('should work', (done) => { + it('should work', done => { const vm = new Vue({ template: `
@@ -82,7 +82,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('should invoke hooks on the entire sub tree', (done) => { + it('should invoke hooks on the entire sub tree', done => { one.template = '' one.components = { two } @@ -124,7 +124,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('should handle nested keep-alive hooks properly', (done) => { + it('should handle nested keep-alive hooks properly', done => { one.template = '' one.data = () => ({ ok: true }) one.components = { two } @@ -262,7 +262,7 @@ describe('Component keep-alive', () => { .then(done) } - it('include (string)', (done) => { + it('include (string)', done => { const vm = new Vue({ template: `
@@ -280,7 +280,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('include (regex)', (done) => { + it('include (regex)', done => { const vm = new Vue({ template: `
@@ -298,7 +298,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('include (array)', (done) => { + it('include (array)', done => { const vm = new Vue({ template: `
@@ -316,7 +316,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('exclude (string)', (done) => { + it('exclude (string)', done => { const vm = new Vue({ template: `
@@ -334,7 +334,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('exclude (regex)', (done) => { + it('exclude (regex)', done => { const vm = new Vue({ template: `
@@ -352,7 +352,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('exclude (array)', (done) => { + it('exclude (array)', done => { const vm = new Vue({ template: `
@@ -370,7 +370,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('include + exclude', (done) => { + it('include + exclude', done => { const vm = new Vue({ template: `
@@ -388,7 +388,7 @@ describe('Component keep-alive', () => { sharedAssertions(vm, done) }) - it('prune cache on include/exclude change', (done) => { + it('prune cache on include/exclude change', done => { const vm = new Vue({ template: `
@@ -422,7 +422,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('prune cache on include/exclude change + view switch', (done) => { + it('prune cache on include/exclude change + view switch', done => { const vm = new Vue({ template: `
@@ -453,7 +453,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('should not prune currently active instance', (done) => { + it('should not prune currently active instance', done => { const vm = new Vue({ template: `
@@ -483,7 +483,7 @@ describe('Component keep-alive', () => { }) // #3882 - it('deeply nested keep-alive should be destroyed properly', (done) => { + it('deeply nested keep-alive should be destroyed properly', done => { one.template = `
` one.components = { two } const vm = new Vue({ @@ -508,7 +508,7 @@ describe('Component keep-alive', () => { }) // #4237 - it('should update latest props/listeners for a re-activated component', (done) => { + it('should update latest props/listeners for a re-activated component', done => { const one = { props: ['prop'], template: `
one {{ prop }}
` @@ -541,7 +541,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('max', (done) => { + it('max', done => { const spyA = vi.fn() const spyB = vi.fn() const spyC = vi.fn() @@ -611,7 +611,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('max=1', (done) => { + it('max=1', done => { const spyA = vi.fn() const spyB = vi.fn() const spyC = vi.fn() @@ -690,7 +690,7 @@ describe('Component keep-alive', () => { }) // #6938 - it('should not cache anonymous component when include is specified', (done) => { + it('should not cache anonymous component when include is specified', done => { const Foo = { name: 'foo', template: `
foo
`, @@ -746,7 +746,7 @@ describe('Component keep-alive', () => { .then(done) }) - it('should cache anonymous components if include is not specified', (done) => { + it('should cache anonymous components if include is not specified', done => { const Foo = { template: `
foo
`, created: vi.fn() @@ -802,7 +802,7 @@ describe('Component keep-alive', () => { }) // #7105 - it('should not destroy active instance when pruning cache', (done) => { + it('should not destroy active instance when pruning cache', done => { const Foo = { template: `
foo
`, destroyed: vi.fn() diff --git a/test/unit/features/component/component-scoped-slot.spec.ts b/test/unit/features/component/component-scoped-slot.spec.ts index 21b7d8e0db3..96c23f8c66c 100644 --- a/test/unit/features/component/component-scoped-slot.spec.ts +++ b/test/unit/features/component/component-scoped-slot.spec.ts @@ -12,7 +12,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { msg: 'hello' } }, template: ` @@ -40,7 +40,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { msg: 'hello' } }, template: ` @@ -70,7 +70,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { msg: 'hello', obj: { msg2: 'world', msg3: '.' } @@ -103,7 +103,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { text: 'some text' } @@ -129,7 +129,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { foo: { text: 'some text' @@ -144,7 +144,9 @@ describe('Component scoped slot', () => { } } }).$mount() - expect('slot v-bind without argument expects an Object').not.toHaveBeenWarned() + expect( + 'slot v-bind without argument expects an Object' + ).not.toHaveBeenWarned() }) it('named scoped slot', done => { @@ -158,7 +160,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { foo: 'FOO', bar: 'BAR' } }, template: ` @@ -186,7 +188,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { foo: 'FOO', bar: 'BAR' } }, template: ` @@ -210,7 +212,7 @@ describe('Component scoped slot', () => { template: ``, components: { test: { - data () { + data() { return { msg: 'hello' } }, template: ` @@ -237,7 +239,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { items: ['foo', 'bar', 'baz'] } @@ -251,17 +253,24 @@ describe('Component scoped slot', () => { } }).$mount() - function assertOutput () { - expect(vm.$el.innerHTML).toBe(vm.$refs.test.items.map(item => { - return `${item}` - }).join('')) + function assertOutput() { + expect(vm.$el.innerHTML).toBe( + vm.$refs.test.items + .map(item => { + return `${item}` + }) + .join('') + ) } assertOutput() vm.$refs.test.items.reverse() - waitForUpdate(assertOutput).then(() => { - vm.$refs.test.items.push('qux') - }).then(assertOutput).then(done) + waitForUpdate(assertOutput) + .then(() => { + vm.$refs.test.items.push('qux') + }) + .then(assertOutput) + .then(done) }) it('slot inside v-for', done => { @@ -275,7 +284,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { items: ['foo', 'bar', 'baz'] } @@ -291,17 +300,24 @@ describe('Component scoped slot', () => { } }).$mount() - function assertOutput () { - expect(vm.$el.innerHTML).toBe(vm.$refs.test.items.map(item => { - return `
  • ${item}
  • ` - }).join('')) + function assertOutput() { + expect(vm.$el.innerHTML).toBe( + vm.$refs.test.items + .map(item => { + return `
  • ${item}
  • ` + }) + .join('') + ) } assertOutput() vm.$refs.test.items.reverse() - waitForUpdate(assertOutput).then(() => { - vm.$refs.test.items.push('qux') - }).then(assertOutput).then(done) + waitForUpdate(assertOutput) + .then(() => { + vm.$refs.test.items.push('qux') + }) + .then(assertOutput) + .then(done) }) it('scoped slot without scope alias', () => { @@ -313,7 +329,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { msg: 'hello' } }, template: ` @@ -338,7 +354,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { msg: 'hello' } }, template: ` @@ -363,7 +379,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { items: ['foo', 'bar', 'baz'] } @@ -381,7 +397,7 @@ describe('Component scoped slot', () => { it('render function usage (named, via data)', done => { const vm = new Vue({ - render (h) { + render(h) { return h('test', { ref: 'test', scopedSlots: { @@ -391,13 +407,16 @@ describe('Component scoped slot', () => { }, components: { test: { - data () { + data() { return { msg: 'hello' } }, - render (h) { - return h('div', this.$scopedSlots.item({ - text: this.msg - })) + render(h) { + return h( + 'div', + this.$scopedSlots.item({ + text: this.msg + }) + ) } } } @@ -412,17 +431,15 @@ describe('Component scoped slot', () => { it('render function usage (default, as children)', () => { const vm = new Vue({ - render (h) { - return h('test', [ - props => h('span', [props.msg]) - ]) + render(h) { + return h('test', [props => h('span', [props.msg])]) }, components: { test: { - data () { + data() { return { msg: 'hello' } }, - render (h) { + render(h) { return h('div', this.$scopedSlots.default({ msg: this.msg })) } } @@ -433,17 +450,15 @@ describe('Component scoped slot', () => { it('render function usage (default, as root)', () => { const vm = new Vue({ - render (h) { - return h('test', [ - props => h('span', [props.msg]) - ]) + render(h) { + return h('test', [props => h('span', [props.msg])]) }, components: { test: { - data () { + data() { return { msg: 'hello' } }, - render (h) { + render(h) { const res = this.$scopedSlots.default({ msg: this.msg }) // all scoped slots should be normalized into arrays expect(Array.isArray(res)).toBe(true) @@ -559,10 +574,14 @@ describe('Component scoped slot', () => { } }).$mount() - expect(vm.$el.innerHTML).toBe('hello foo hello bar hello abc') + expect(vm.$el.innerHTML).toBe( + 'hello foo hello bar hello abc' + ) vm.$refs.test.msg = 'world' waitForUpdate(() => { - expect(vm.$el.innerHTML).toBe('world foo world bar world abc') + expect(vm.$el.innerHTML).toBe( + 'world foo world bar world abc' + ) }).then(done) }) @@ -589,10 +608,14 @@ describe('Component scoped slot', () => { } }).$mount() - expect(vm.$el.innerHTML).toBe('hello foo hello bar hello abc') + expect(vm.$el.innerHTML).toBe( + 'hello foo hello bar hello abc' + ) vm.$refs.test.msg = 'world' waitForUpdate(() => { - expect(vm.$el.innerHTML).toBe('world foo world bar world abc') + expect(vm.$el.innerHTML).toBe( + 'world foo world bar world abc' + ) }).then(done) }) @@ -611,7 +634,7 @@ describe('Component scoped slot', () => { `, components: { test: { - data () { + data() { return { msg: 'hello' } }, template: ` @@ -636,7 +659,7 @@ describe('Component scoped slot', () => { // the behavior of the new syntax is slightly different. it('scoped slot v-if using slot-scope value', () => { const Child = { - template: '
    ', + template: '
    ' } const vm = new Vue({ components: { Child }, @@ -656,7 +679,8 @@ describe('Component scoped slot', () => { const Foo = { render(h) { return h('div', [ - this.$scopedSlots.default && this.$scopedSlots.default('from foo default'), + this.$scopedSlots.default && + this.$scopedSlots.default('from foo default'), this.$scopedSlots.one && this.$scopedSlots.one('from foo one'), this.$scopedSlots.two && this.$scopedSlots.two('from foo two') ]) @@ -665,19 +689,24 @@ describe('Component scoped slot', () => { const Bar = { render(h) { - return this.$scopedSlots.default && this.$scopedSlots.default('from bar') + return ( + this.$scopedSlots.default && this.$scopedSlots.default('from bar') + ) } } const Baz = { render(h) { - return this.$scopedSlots.default && this.$scopedSlots.default('from baz') + return ( + this.$scopedSlots.default && this.$scopedSlots.default('from baz') + ) } } - const toNamed = (syntax, name) => syntax[0] === '#' - ? `#${name}` // shorthand - : `${syntax}:${name}` // full syntax + const toNamed = (syntax, name) => + syntax[0] === '#' + ? `#${name}` // shorthand + : `${syntax}:${name}` // full syntax function runSuite(syntax) { it('default slot', () => { @@ -685,7 +714,9 @@ describe('Component scoped slot', () => { template: `{{ foo }}
    {{ foo }}
    `, components: { Foo } }).$mount() - expect(vm.$el.innerHTML).toBe(`from foo default
    from foo default
    `) + expect(vm.$el.innerHTML).toBe( + `from foo default
    from foo default
    ` + ) }) it('nested default slots', () => { @@ -701,7 +732,9 @@ describe('Component scoped slot', () => { `, components: { Foo, Bar, Baz } }).$mount() - expect(vm.$el.innerHTML.trim()).toBe(`from foo default | from bar | from baz`) + expect(vm.$el.innerHTML.trim()).toBe( + `from foo default | from bar | from baz` + ) }) it('named slots', () => { @@ -721,7 +754,9 @@ describe('Component scoped slot', () => { `, components: { Foo } }).$mount() - expect(vm.$el.innerHTML.replace(/\s+/g, ' ')).toMatch(`from foo default from foo one from foo two`) + expect(vm.$el.innerHTML.replace(/\s+/g, ' ')).toMatch( + `from foo default from foo one from foo two` + ) }) it('nested + named + default slots', () => { @@ -742,14 +777,18 @@ describe('Component scoped slot', () => { `, components: { Foo, Bar, Baz } }).$mount() - expect(vm.$el.innerHTML.replace(/\s+/g, ' ')).toMatch(`from foo one from bar from foo two from baz`) + expect(vm.$el.innerHTML.replace(/\s+/g, ' ')).toMatch( + `from foo one from bar from foo two from baz` + ) }) it('should warn v-slot usage on non-component elements', () => { new Vue({ template: `
    ` }).$mount() - expect(`v-slot can only be used on components or