]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
style: update format & lint config (#9162)
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Tue, 26 Dec 2023 11:39:47 +0000 (19:39 +0800)
committerGitHub <noreply@github.com>
Tue, 26 Dec 2023 11:39:47 +0000 (19:39 +0800)
Co-authored-by: 丶远方 <yangpanteng@gmail.com>
Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
Co-authored-by: Guo Xingjun <99574369+Plumbiu@users.noreply.github.com>
464 files changed:
.eslintrc.cjs
.github/renovate.json5
.prettierignore
.prettierrc
.vscode/launch.json
package.json
packages/compiler-core/__tests__/codegen.spec.ts
packages/compiler-core/__tests__/compile.spec.ts
packages/compiler-core/__tests__/parse.spec.ts
packages/compiler-core/__tests__/scopeId.spec.ts
packages/compiler-core/__tests__/testUtils.ts
packages/compiler-core/__tests__/transform.spec.ts
packages/compiler-core/__tests__/transforms/hoistStatic.spec.ts
packages/compiler-core/__tests__/transforms/noopDirectiveTransform.spec.ts
packages/compiler-core/__tests__/transforms/transformElement.spec.ts
packages/compiler-core/__tests__/transforms/transformExpressions.spec.ts
packages/compiler-core/__tests__/transforms/transformSlotOutlet.spec.ts
packages/compiler-core/__tests__/transforms/transformText.spec.ts
packages/compiler-core/__tests__/transforms/vBind.spec.ts
packages/compiler-core/__tests__/transforms/vFor.spec.ts
packages/compiler-core/__tests__/transforms/vIf.spec.ts
packages/compiler-core/__tests__/transforms/vMemo.spec.ts
packages/compiler-core/__tests__/transforms/vModel.spec.ts
packages/compiler-core/__tests__/transforms/vOn.spec.ts
packages/compiler-core/__tests__/transforms/vOnce.spec.ts
packages/compiler-core/__tests__/transforms/vSlot.spec.ts
packages/compiler-core/__tests__/utils.spec.ts
packages/compiler-core/src/ast.ts
packages/compiler-core/src/babelUtils.ts
packages/compiler-core/src/codegen.ts
packages/compiler-core/src/compat/compatConfig.ts
packages/compiler-core/src/compat/transformFilter.ts
packages/compiler-core/src/compile.ts
packages/compiler-core/src/errors.ts
packages/compiler-core/src/index.ts
packages/compiler-core/src/options.ts
packages/compiler-core/src/parser.ts
packages/compiler-core/src/runtimeHelpers.ts
packages/compiler-core/src/tokenizer.ts
packages/compiler-core/src/transform.ts
packages/compiler-core/src/transforms/hoistStatic.ts
packages/compiler-core/src/transforms/noopDirectiveTransform.ts
packages/compiler-core/src/transforms/transformElement.ts
packages/compiler-core/src/transforms/transformExpression.ts
packages/compiler-core/src/transforms/transformSlotOutlet.ts
packages/compiler-core/src/transforms/transformText.ts
packages/compiler-core/src/transforms/vBind.ts
packages/compiler-core/src/transforms/vFor.ts
packages/compiler-core/src/transforms/vIf.ts
packages/compiler-core/src/transforms/vMemo.ts
packages/compiler-core/src/transforms/vModel.ts
packages/compiler-core/src/transforms/vOn.ts
packages/compiler-core/src/transforms/vOnce.ts
packages/compiler-core/src/transforms/vSlot.ts
packages/compiler-core/src/utils.ts
packages/compiler-core/src/validateExpression.ts
packages/compiler-dom/__tests__/decoderHtmlBrowser.spec.ts
packages/compiler-dom/__tests__/parse.spec.ts
packages/compiler-dom/__tests__/transforms/Transition.spec.ts
packages/compiler-dom/__tests__/transforms/ignoreSideEffectTags.spec.ts
packages/compiler-dom/__tests__/transforms/stringifyStatic.spec.ts
packages/compiler-dom/__tests__/transforms/transformStyle.spec.ts
packages/compiler-dom/__tests__/transforms/vHtml.spec.ts
packages/compiler-dom/__tests__/transforms/vModel.spec.ts
packages/compiler-dom/__tests__/transforms/vOn.spec.ts
packages/compiler-dom/__tests__/transforms/vShow.spec.ts
packages/compiler-dom/__tests__/transforms/vText.spec.ts
packages/compiler-dom/src/errors.ts
packages/compiler-dom/src/index.ts
packages/compiler-dom/src/parserOptions.ts
packages/compiler-dom/src/runtimeHelpers.ts
packages/compiler-dom/src/transforms/Transition.ts
packages/compiler-dom/src/transforms/ignoreSideEffectTags.ts
packages/compiler-dom/src/transforms/stringifyStatic.ts
packages/compiler-dom/src/transforms/transformStyle.ts
packages/compiler-dom/src/transforms/vHtml.ts
packages/compiler-dom/src/transforms/vModel.ts
packages/compiler-dom/src/transforms/vOn.ts
packages/compiler-dom/src/transforms/vShow.ts
packages/compiler-dom/src/transforms/vText.ts
packages/compiler-sfc/__tests__/compileScript.spec.ts
packages/compiler-sfc/__tests__/compileScript/defineEmits.spec.ts
packages/compiler-sfc/__tests__/compileScript/defineExpose.spec.ts
packages/compiler-sfc/__tests__/compileScript/defineModel.spec.ts
packages/compiler-sfc/__tests__/compileScript/defineOptions.spec.ts
packages/compiler-sfc/__tests__/compileScript/defineProps.spec.ts
packages/compiler-sfc/__tests__/compileScript/definePropsDestructure.spec.ts
packages/compiler-sfc/__tests__/compileScript/defineSlots.spec.ts
packages/compiler-sfc/__tests__/compileScript/hoistStatic.spec.ts
packages/compiler-sfc/__tests__/compileScript/resolveType.spec.ts
packages/compiler-sfc/__tests__/compileStyle.spec.ts
packages/compiler-sfc/__tests__/compileTemplate.spec.ts
packages/compiler-sfc/__tests__/cssVars.spec.ts
packages/compiler-sfc/__tests__/parse.spec.ts
packages/compiler-sfc/__tests__/rewriteDefault.spec.ts
packages/compiler-sfc/__tests__/templateTransformAssetUrl.spec.ts
packages/compiler-sfc/__tests__/templateTransformSrcset.spec.ts
packages/compiler-sfc/__tests__/templateUtils.spec.ts
packages/compiler-sfc/__tests__/utils.ts
packages/compiler-sfc/src/cache.ts
packages/compiler-sfc/src/compileScript.ts
packages/compiler-sfc/src/compileStyle.ts
packages/compiler-sfc/src/compileTemplate.ts
packages/compiler-sfc/src/index.ts
packages/compiler-sfc/src/parse.ts
packages/compiler-sfc/src/rewriteDefault.ts
packages/compiler-sfc/src/script/analyzeScriptBindings.ts
packages/compiler-sfc/src/script/context.ts
packages/compiler-sfc/src/script/defineEmits.ts
packages/compiler-sfc/src/script/defineExpose.ts
packages/compiler-sfc/src/script/defineModel.ts
packages/compiler-sfc/src/script/defineOptions.ts
packages/compiler-sfc/src/script/defineProps.ts
packages/compiler-sfc/src/script/definePropsDestructure.ts
packages/compiler-sfc/src/script/defineSlots.ts
packages/compiler-sfc/src/script/importUsageCheck.ts
packages/compiler-sfc/src/script/normalScript.ts
packages/compiler-sfc/src/script/resolveType.ts
packages/compiler-sfc/src/script/topLevelAwait.ts
packages/compiler-sfc/src/script/utils.ts
packages/compiler-sfc/src/style/cssVars.ts
packages/compiler-sfc/src/style/pluginScoped.ts
packages/compiler-sfc/src/style/pluginTrim.ts
packages/compiler-sfc/src/style/preprocessors.ts
packages/compiler-sfc/src/template/templateUtils.ts
packages/compiler-sfc/src/template/transformAssetUrl.ts
packages/compiler-sfc/src/template/transformSrcset.ts
packages/compiler-sfc/src/warn.ts
packages/compiler-ssr/__tests__/ssrComponent.spec.ts
packages/compiler-ssr/__tests__/ssrElement.spec.ts
packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts
packages/compiler-ssr/__tests__/ssrPortal.spec.ts
packages/compiler-ssr/__tests__/ssrScopeId.spec.ts
packages/compiler-ssr/__tests__/ssrSlotOutlet.spec.ts
packages/compiler-ssr/__tests__/ssrSuspense.spec.ts
packages/compiler-ssr/__tests__/ssrText.spec.ts
packages/compiler-ssr/__tests__/ssrTransitionGroup.spec.ts
packages/compiler-ssr/__tests__/ssrVFor.spec.ts
packages/compiler-ssr/__tests__/ssrVIf.spec.ts
packages/compiler-ssr/__tests__/ssrVModel.spec.ts
packages/compiler-ssr/__tests__/ssrVShow.spec.ts
packages/compiler-ssr/__tests__/utils.ts
packages/compiler-ssr/src/errors.ts
packages/compiler-ssr/src/index.ts
packages/compiler-ssr/src/runtimeHelpers.ts
packages/compiler-ssr/src/ssrCodegenTransform.ts
packages/compiler-ssr/src/transforms/ssrInjectCssVars.ts
packages/compiler-ssr/src/transforms/ssrInjectFallthroughAttrs.ts
packages/compiler-ssr/src/transforms/ssrTransformComponent.ts
packages/compiler-ssr/src/transforms/ssrTransformElement.ts
packages/compiler-ssr/src/transforms/ssrTransformSlotOutlet.ts
packages/compiler-ssr/src/transforms/ssrTransformSuspense.ts
packages/compiler-ssr/src/transforms/ssrTransformTeleport.ts
packages/compiler-ssr/src/transforms/ssrTransformTransition.ts
packages/compiler-ssr/src/transforms/ssrTransformTransitionGroup.ts
packages/compiler-ssr/src/transforms/ssrVFor.ts
packages/compiler-ssr/src/transforms/ssrVIf.ts
packages/compiler-ssr/src/transforms/ssrVModel.ts
packages/compiler-ssr/src/transforms/ssrVShow.ts
packages/dts-built-test/src/index.ts
packages/dts-test/appDirective.test-d.ts
packages/dts-test/appUse.test-d.ts
packages/dts-test/built.test-d.ts
packages/dts-test/compiler.test-d.ts
packages/dts-test/component.test-d.ts
packages/dts-test/componentInstance.test-d.tsx
packages/dts-test/componentTypeExtensions.test-d.tsx
packages/dts-test/defineComponent.test-d.tsx
packages/dts-test/defineCustomElement.test-d.ts
packages/dts-test/extractProps.test-d.ts
packages/dts-test/functionalComponent.test-d.tsx
packages/dts-test/h.test-d.ts
packages/dts-test/inject.test-d.ts
packages/dts-test/reactivity.test-d.ts
packages/dts-test/ref.test-d.ts
packages/dts-test/setupHelpers.test-d.ts
packages/dts-test/tsx.test-d.tsx
packages/dts-test/watch.test-d.ts
packages/global.d.ts
packages/reactivity/__tests__/collections/Map.spec.ts
packages/reactivity/__tests__/collections/Set.spec.ts
packages/reactivity/__tests__/collections/WeakMap.spec.ts
packages/reactivity/__tests__/collections/WeakSet.spec.ts
packages/reactivity/__tests__/collections/shallowReadonly.spec.ts
packages/reactivity/__tests__/computed.bench.ts
packages/reactivity/__tests__/computed.spec.ts
packages/reactivity/__tests__/effect.spec.ts
packages/reactivity/__tests__/effectScope.spec.ts
packages/reactivity/__tests__/gc.spec.ts
packages/reactivity/__tests__/reactive.spec.ts
packages/reactivity/__tests__/reactiveArray.bench.ts
packages/reactivity/__tests__/reactiveArray.spec.ts
packages/reactivity/__tests__/reactiveMap.bench.ts
packages/reactivity/__tests__/reactiveObject.bench.ts
packages/reactivity/__tests__/readonly.spec.ts
packages/reactivity/__tests__/ref.bench.ts
packages/reactivity/__tests__/ref.spec.ts
packages/reactivity/__tests__/shallowReactive.spec.ts
packages/reactivity/__tests__/shallowReadonly.spec.ts
packages/reactivity/src/baseHandlers.ts
packages/reactivity/src/collectionHandlers.ts
packages/reactivity/src/computed.ts
packages/reactivity/src/constants.ts
packages/reactivity/src/dep.ts
packages/reactivity/src/effect.ts
packages/reactivity/src/effectScope.ts
packages/reactivity/src/index.ts
packages/reactivity/src/reactive.ts
packages/reactivity/src/reactiveEffect.ts
packages/reactivity/src/ref.ts
packages/runtime-core/__tests__/apiAsyncComponent.spec.ts
packages/runtime-core/__tests__/apiCreateApp.spec.ts
packages/runtime-core/__tests__/apiExpose.spec.ts
packages/runtime-core/__tests__/apiInject.spec.ts
packages/runtime-core/__tests__/apiLifecycle.spec.ts
packages/runtime-core/__tests__/apiOptions.spec.ts
packages/runtime-core/__tests__/apiSetupContext.spec.ts
packages/runtime-core/__tests__/apiSetupHelpers.spec.ts
packages/runtime-core/__tests__/apiWatch.bench.ts
packages/runtime-core/__tests__/apiWatch.spec.ts
packages/runtime-core/__tests__/componentEmits.spec.ts
packages/runtime-core/__tests__/componentProps.spec.ts
packages/runtime-core/__tests__/componentPublicInstance.spec.ts
packages/runtime-core/__tests__/componentSlots.spec.ts
packages/runtime-core/__tests__/components/BaseTransition.spec.ts
packages/runtime-core/__tests__/components/KeepAlive.spec.ts
packages/runtime-core/__tests__/components/Suspense.spec.ts
packages/runtime-core/__tests__/components/Teleport.spec.ts
packages/runtime-core/__tests__/directives.spec.ts
packages/runtime-core/__tests__/errorHandling.spec.ts
packages/runtime-core/__tests__/h.spec.ts
packages/runtime-core/__tests__/helpers/createSlots.spec.ts
packages/runtime-core/__tests__/helpers/renderList.spec.ts
packages/runtime-core/__tests__/helpers/renderSlot.spec.ts
packages/runtime-core/__tests__/helpers/resolveAssets.spec.ts
packages/runtime-core/__tests__/helpers/toHandlers.spec.ts
packages/runtime-core/__tests__/helpers/withMemo.spec.ts
packages/runtime-core/__tests__/hmr.spec.ts
packages/runtime-core/__tests__/hydration.spec.ts
packages/runtime-core/__tests__/misc.spec.ts
packages/runtime-core/__tests__/rendererAttrsFallthrough.spec.ts
packages/runtime-core/__tests__/rendererChildren.spec.ts
packages/runtime-core/__tests__/rendererComponent.spec.ts
packages/runtime-core/__tests__/rendererElement.spec.ts
packages/runtime-core/__tests__/rendererFragment.spec.ts
packages/runtime-core/__tests__/rendererOptimizedMode.spec.ts
packages/runtime-core/__tests__/rendererTemplateRef.spec.ts
packages/runtime-core/__tests__/scheduler.spec.ts
packages/runtime-core/__tests__/scopeId.spec.ts
packages/runtime-core/__tests__/vnode.spec.ts
packages/runtime-core/__tests__/vnodeHooks.spec.ts
packages/runtime-core/src/apiAsyncComponent.ts
packages/runtime-core/src/apiComputed.ts
packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/apiDefineComponent.ts
packages/runtime-core/src/apiInject.ts
packages/runtime-core/src/apiLifecycle.ts
packages/runtime-core/src/apiSetupHelpers.ts
packages/runtime-core/src/apiWatch.ts
packages/runtime-core/src/compat/attrsFallthrough.ts
packages/runtime-core/src/compat/compatConfig.ts
packages/runtime-core/src/compat/component.ts
packages/runtime-core/src/compat/componentAsync.ts
packages/runtime-core/src/compat/componentFunctional.ts
packages/runtime-core/src/compat/componentVModel.ts
packages/runtime-core/src/compat/customDirective.ts
packages/runtime-core/src/compat/global.ts
packages/runtime-core/src/compat/globalConfig.ts
packages/runtime-core/src/compat/instance.ts
packages/runtime-core/src/compat/instanceChildren.ts
packages/runtime-core/src/compat/instanceEventEmitter.ts
packages/runtime-core/src/compat/instanceListeners.ts
packages/runtime-core/src/compat/props.ts
packages/runtime-core/src/compat/renderFn.ts
packages/runtime-core/src/compat/renderHelpers.ts
packages/runtime-core/src/component.ts
packages/runtime-core/src/componentEmits.ts
packages/runtime-core/src/componentOptions.ts
packages/runtime-core/src/componentProps.ts
packages/runtime-core/src/componentPublicInstance.ts
packages/runtime-core/src/componentRenderContext.ts
packages/runtime-core/src/componentRenderUtils.ts
packages/runtime-core/src/componentSlots.ts
packages/runtime-core/src/components/BaseTransition.ts
packages/runtime-core/src/components/KeepAlive.ts
packages/runtime-core/src/components/Suspense.ts
packages/runtime-core/src/components/Teleport.ts
packages/runtime-core/src/customFormatter.ts
packages/runtime-core/src/devtools.ts
packages/runtime-core/src/directives.ts
packages/runtime-core/src/enums.ts
packages/runtime-core/src/errorHandling.ts
packages/runtime-core/src/featureFlags.ts
packages/runtime-core/src/h.ts
packages/runtime-core/src/helpers/createSlots.ts
packages/runtime-core/src/helpers/renderList.ts
packages/runtime-core/src/helpers/renderSlot.ts
packages/runtime-core/src/helpers/resolveAssets.ts
packages/runtime-core/src/helpers/toHandlers.ts
packages/runtime-core/src/helpers/useSsrContext.ts
packages/runtime-core/src/helpers/withMemo.ts
packages/runtime-core/src/hmr.ts
packages/runtime-core/src/hydration.ts
packages/runtime-core/src/index.ts
packages/runtime-core/src/profiling.ts
packages/runtime-core/src/renderer.ts
packages/runtime-core/src/rendererTemplateRef.ts
packages/runtime-core/src/scheduler.ts
packages/runtime-core/src/vnode.ts
packages/runtime-core/src/warning.ts
packages/runtime-dom/__tests__/createApp.spec.ts
packages/runtime-dom/__tests__/customElement.spec.ts
packages/runtime-dom/__tests__/customizedBuiltIn.spec.ts
packages/runtime-dom/__tests__/directives/vCloak.spec.ts
packages/runtime-dom/__tests__/directives/vModel.spec.ts
packages/runtime-dom/__tests__/directives/vOn.spec.ts
packages/runtime-dom/__tests__/directives/vShow.spec.ts
packages/runtime-dom/__tests__/helpers/useCssModule.spec.ts
packages/runtime-dom/__tests__/helpers/useCssVars.spec.ts
packages/runtime-dom/__tests__/nodeOps.spec.ts
packages/runtime-dom/__tests__/patchClass.spec.ts
packages/runtime-dom/__tests__/patchEvents.spec.ts
packages/runtime-dom/__tests__/patchProps.spec.ts
packages/runtime-dom/__tests__/patchStyle.spec.ts
packages/runtime-dom/src/apiCustomElement.ts
packages/runtime-dom/src/components/Transition.ts
packages/runtime-dom/src/components/TransitionGroup.ts
packages/runtime-dom/src/directives/vModel.ts
packages/runtime-dom/src/directives/vOn.ts
packages/runtime-dom/src/directives/vShow.ts
packages/runtime-dom/src/helpers/useCssModule.ts
packages/runtime-dom/src/helpers/useCssVars.ts
packages/runtime-dom/src/index.ts
packages/runtime-dom/src/jsx.ts
packages/runtime-dom/src/modules/attrs.ts
packages/runtime-dom/src/modules/class.ts
packages/runtime-dom/src/modules/events.ts
packages/runtime-dom/src/modules/props.ts
packages/runtime-dom/src/modules/style.ts
packages/runtime-dom/src/nodeOps.ts
packages/runtime-dom/src/patchProp.ts
packages/runtime-test/__tests__/testRuntime.spec.ts
packages/runtime-test/src/index.ts
packages/runtime-test/src/nodeOps.ts
packages/runtime-test/src/patchProp.ts
packages/runtime-test/src/serialize.ts
packages/runtime-test/src/triggerEvent.ts
packages/server-renderer/__tests__/render.spec.ts
packages/server-renderer/__tests__/ssrAttrFallthrough.spec.ts
packages/server-renderer/__tests__/ssrCompilerOptions.spec.ts
packages/server-renderer/__tests__/ssrComputed.spec.ts
packages/server-renderer/__tests__/ssrDirectives.spec.ts
packages/server-renderer/__tests__/ssrDynamicComponent.spec.ts
packages/server-renderer/__tests__/ssrInterpolate.spec.ts
packages/server-renderer/__tests__/ssrRenderAttrs.spec.ts
packages/server-renderer/__tests__/ssrRenderList.spec.ts
packages/server-renderer/__tests__/ssrScopeId.spec.ts
packages/server-renderer/__tests__/ssrSlot.spec.ts
packages/server-renderer/__tests__/ssrSuspense.spec.ts
packages/server-renderer/__tests__/ssrTeleport.spec.ts
packages/server-renderer/__tests__/ssrVModelHelpers.spec.ts
packages/server-renderer/__tests__/ssrWatch.spec.ts
packages/server-renderer/__tests__/webStream.spec.ts
packages/server-renderer/src/helpers/ssrCompile.ts
packages/server-renderer/src/helpers/ssrGetDirectiveProps.ts
packages/server-renderer/src/helpers/ssrRenderAttrs.ts
packages/server-renderer/src/helpers/ssrRenderComponent.ts
packages/server-renderer/src/helpers/ssrRenderList.ts
packages/server-renderer/src/helpers/ssrRenderSlot.ts
packages/server-renderer/src/helpers/ssrRenderSuspense.ts
packages/server-renderer/src/helpers/ssrRenderTeleport.ts
packages/server-renderer/src/helpers/ssrVModelHelpers.ts
packages/server-renderer/src/index.ts
packages/server-renderer/src/internal.ts
packages/server-renderer/src/render.ts
packages/server-renderer/src/renderToStream.ts
packages/server-renderer/src/renderToString.ts
packages/sfc-playground/src/App.vue
packages/sfc-playground/src/Header.vue
packages/sfc-playground/src/VersionSelect.vue
packages/sfc-playground/src/download/download.ts
packages/sfc-playground/src/download/template/vite.config.js
packages/sfc-playground/src/icons/GitHub.vue
packages/sfc-playground/src/icons/Moon.vue
packages/sfc-playground/src/icons/Reload.vue
packages/sfc-playground/src/icons/Sun.vue
packages/sfc-playground/src/main.ts
packages/sfc-playground/src/vue-dev-proxy-prod.ts
packages/sfc-playground/vite.config.ts
packages/shared/__tests__/codeframe.spec.ts
packages/shared/__tests__/looseEqual.spec.ts
packages/shared/__tests__/normalizeProp.spec.ts
packages/shared/__tests__/toDisplayString.spec.ts
packages/shared/src/codeframe.ts
packages/shared/src/domAttrConfig.ts
packages/shared/src/general.ts
packages/shared/src/makeMap.ts
packages/shared/src/normalizeProp.ts
packages/shared/src/patchFlags.ts
packages/shared/src/shapeFlags.ts
packages/shared/src/slotFlags.ts
packages/shared/src/toDisplayString.ts
packages/template-explorer/src/index.ts
packages/template-explorer/src/options.ts
packages/template-explorer/src/theme.ts
packages/template-explorer/style.css
packages/vue-compat/__tests__/compiler.spec.ts
packages/vue-compat/__tests__/componentAsync.spec.ts
packages/vue-compat/__tests__/componentFunctional.spec.ts
packages/vue-compat/__tests__/componentVModel.spec.ts
packages/vue-compat/__tests__/filters.spec.ts
packages/vue-compat/__tests__/global.spec.ts
packages/vue-compat/__tests__/globalConfig.spec.ts
packages/vue-compat/__tests__/instance.spec.ts
packages/vue-compat/__tests__/misc.spec.ts
packages/vue-compat/__tests__/options.spec.ts
packages/vue-compat/__tests__/renderFn.spec.ts
packages/vue-compat/__tests__/utils.ts
packages/vue-compat/src/createCompatVue.ts
packages/vue-compat/src/dev.ts
packages/vue-compat/src/index.ts
packages/vue-compat/src/runtime.ts
packages/vue/__tests__/customElementCasing.spec.ts
packages/vue/__tests__/e2e/Transition.spec.ts
packages/vue/__tests__/e2e/TransitionGroup.spec.ts
packages/vue/__tests__/e2e/commits.mock.ts
packages/vue/__tests__/e2e/commits.spec.ts
packages/vue/__tests__/e2e/e2eUtils.ts
packages/vue/__tests__/e2e/grid.spec.ts
packages/vue/__tests__/e2e/markdown.spec.ts
packages/vue/__tests__/e2e/svg.spec.ts
packages/vue/__tests__/e2e/todomvc.spec.ts
packages/vue/__tests__/e2e/tree.spec.ts
packages/vue/__tests__/index.spec.ts
packages/vue/__tests__/mathmlNamespace.spec.ts
packages/vue/__tests__/runtimeCompilerOptions.spec.ts
packages/vue/__tests__/svgNamespace.spec.ts
packages/vue/index.mjs
packages/vue/jsx-runtime/index.d.ts
packages/vue/jsx-runtime/index.mjs
packages/vue/jsx.d.ts
packages/vue/macros.d.ts
packages/vue/server-renderer/index.mjs
packages/vue/src/dev.ts
packages/vue/src/index.ts
packages/vue/src/runtime.ts
pnpm-lock.yaml
rollup.config.js
rollup.dts.config.js
scripts/aliases.js
scripts/build.js
scripts/dev.js
scripts/inline-enums.js
scripts/pre-dev-sfc.js
scripts/release.js
scripts/setup-vitest.ts
scripts/size-report.ts
scripts/usage-size.ts
scripts/utils.js
scripts/verify-commit.js
scripts/verify-treeshaking.js
vitest.config.ts
vitest.e2e.config.ts
vitest.unit.config.ts

index 92b5b534293855854fb3c8a9c16611b10b0566dc..b8afcf9843f7bbe4b79134c0d253bc42ba901d8e 100644 (file)
@@ -1,12 +1,11 @@
-/* eslint-disable no-restricted-globals */
-
+const { builtinModules } = require('node:module')
 const DOMGlobals = ['window', 'document']
 const NodeGlobals = ['module', 'require']
 
 const banConstEnum = {
   selector: 'TSEnumDeclaration[const=true]',
   message:
-    'Please use non-const enums. This project automatically inlines enums.'
+    'Please use non-const enums. This project automatically inlines enums.',
 }
 
 /**
@@ -15,9 +14,9 @@ const banConstEnum = {
 module.exports = {
   parser: '@typescript-eslint/parser',
   parserOptions: {
-    sourceType: 'module'
+    sourceType: 'module',
   },
-  plugins: ['jest'],
+  plugins: ['jest', 'import', '@typescript-eslint'],
   rules: {
     'no-debugger': 'error',
     // most of the codebase are expected to be env agnostic
@@ -32,8 +31,27 @@ module.exports = {
       // tsc compiles assignment spread into Object.assign() calls, but esbuild
       // still generates verbose helpers, so spread assignment is also prohiboted
       'ObjectExpression > SpreadElement',
-      'AwaitExpression'
-    ]
+      'AwaitExpression',
+    ],
+    'sort-imports': ['error', { ignoreDeclarationSort: true }],
+
+    'import/no-nodejs-modules': [
+      'error',
+      { allow: builtinModules.map(mod => `node:${mod}`) },
+    ],
+    // This rule enforces the preference for using '@ts-expect-error' comments in TypeScript
+    // code to indicate intentional type errors, improving code clarity and maintainability.
+    '@typescript-eslint/prefer-ts-expect-error': 'error',
+    // Enforce the use of 'import type' for importing types
+    '@typescript-eslint/consistent-type-imports': [
+      'error',
+      {
+        fixStyle: 'inline-type-imports',
+        disallowTypeAnnotations: false,
+      },
+    ],
+    // Enforce the use of top-level import type qualifier when an import only has specifiers with inline type qualifiers
+    '@typescript-eslint/no-import-type-side-effects': 'error',
   },
   overrides: [
     // tests, no restrictions (runs in Node / jest with jsdom)
@@ -43,54 +61,66 @@ module.exports = {
         'no-restricted-globals': 'off',
         'no-restricted-syntax': 'off',
         'jest/no-disabled-tests': 'error',
-        'jest/no-focused-tests': 'error'
-      }
+        'jest/no-focused-tests': 'error',
+      },
     },
     // shared, may be used in any env
     {
-      files: ['packages/shared/**'],
+      files: ['packages/shared/**', '.eslintrc.cjs'],
       rules: {
-        'no-restricted-globals': 'off'
-      }
+        'no-restricted-globals': 'off',
+      },
     },
     // Packages targeting DOM
     {
       files: ['packages/{vue,vue-compat,runtime-dom}/**'],
       rules: {
-        'no-restricted-globals': ['error', ...NodeGlobals]
-      }
+        'no-restricted-globals': ['error', ...NodeGlobals],
+      },
     },
     // Packages targeting Node
     {
       files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
       rules: {
         'no-restricted-globals': ['error', ...DOMGlobals],
-        'no-restricted-syntax': ['error', banConstEnum]
-      }
+        'no-restricted-syntax': ['error', banConstEnum],
+      },
     },
     // Private package, browser only + no syntax restrictions
     {
       files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
       rules: {
         'no-restricted-globals': ['error', ...NodeGlobals],
-        'no-restricted-syntax': ['error', banConstEnum]
-      }
+        'no-restricted-syntax': ['error', banConstEnum],
+      },
     },
     // JavaScript files
     {
       files: ['*.js', '*.cjs'],
       rules: {
         // We only do `no-unused-vars` checks for js files, TS files are checked by TypeScript itself.
-        'no-unused-vars': ['error', { vars: 'all', args: 'none' }]
-      }
+        'no-unused-vars': ['error', { vars: 'all', args: 'none' }],
+      },
     },
     // Node scripts
     {
-      files: ['scripts/**', '*.{js,ts}', 'packages/**/index.js'],
+      files: [
+        'scripts/**',
+        './*.{js,ts}',
+        'packages/*/*.js',
+        'packages/vue/*/*.js',
+      ],
       rules: {
         'no-restricted-globals': 'off',
-        'no-restricted-syntax': ['error', banConstEnum]
-      }
-    }
-  ]
+        'no-restricted-syntax': ['error', banConstEnum],
+      },
+    },
+    // Import nodejs modules in compiler-sfc
+    {
+      files: ['packages/compiler-sfc/src/**'],
+      rules: {
+        'import/no-nodejs-modules': ['error', { allow: builtinModules }],
+      },
+    },
+  ],
 }
index 088913317c754e8c4dcaef5baa29d8ead73fd5ef..a43f4ae30cf215ee9ea0ca2e6e8c3e6cb0c19be7 100644 (file)
@@ -7,35 +7,35 @@
   packageRules: [
     {
       depTypeList: ['peerDependencies'],
-      enabled: false
+      enabled: false,
     },
     {
       groupName: 'test',
       matchPackageNames: ['vitest', 'jsdom', 'puppeteer'],
-      matchPackagePrefixes: ['@vitest']
+      matchPackagePrefixes: ['@vitest'],
     },
     {
       groupName: 'playground',
       matchFileNames: [
         'packages/sfc-playground/package.json',
-        'packages/template-explorer/package.json'
-      ]
+        'packages/template-explorer/package.json',
+      ],
     },
     {
       groupName: 'compiler',
       matchPackageNames: ['magic-string'],
-      matchPackagePrefixes: ['@babel', 'postcss']
+      matchPackagePrefixes: ['@babel', 'postcss'],
     },
     {
       groupName: 'build',
       matchPackageNames: ['vite', 'terser'],
-      matchPackagePrefixes: ['rollup', 'esbuild', '@rollup', '@vitejs']
+      matchPackagePrefixes: ['rollup', 'esbuild', '@rollup', '@vitejs'],
     },
     {
       groupName: 'lint',
       matchPackageNames: ['simple-git-hooks', 'lint-staged'],
-      matchPackagePrefixes: ['@typescript-eslint', 'eslint', 'prettier']
-    }
+      matchPackagePrefixes: ['@typescript-eslint', 'eslint', 'prettier'],
+    },
   ],
   ignoreDeps: [
     'vue',
@@ -45,6 +45,6 @@
     'typescript',
 
     // ESM only
-    'estree-walker'
-  ]
+    'estree-walker',
+  ],
 }
index 1521c8b7652b1eec8ed4fe50877aae880c758ee3..fbd3dca8ca3199d1a83f65290035174663c92374 100644 (file)
@@ -1 +1,4 @@
 dist
+*.md
+*.html
+pnpm-lock.yaml
index ef93d94821a8486b23231d10bf3ce939ecaaa7b8..759232e7cf69c711bdc6ccb75c40fff4da4a6e20 100644 (file)
@@ -1,5 +1,5 @@
-semi: false
-singleQuote: true
-printWidth: 80
-trailingComma: 'none'
-arrowParens: 'avoid'
+{
+  "semi": false,
+  "singleQuote": true,
+  "arrowParens": "avoid"
+}
index b63ffc79b80e819ab0dd285e3b370c4295162937..b616400b48edb1d6ee30f2c80530ce7ac2180fe4 100644 (file)
@@ -21,7 +21,7 @@
       "console": "integratedTerminal",
       "sourceMaps": true,
       "windows": {
-        "program": "${workspaceFolder}/node_modules/jest/bin/jest",
+        "program": "${workspaceFolder}/node_modules/jest/bin/jest"
       }
     }
   ]
index 0030ef94429087bd08920769f6b4c671b08f406f..f1f3bee34aa1bda4fcef960a8fd2821df5424da5 100644 (file)
@@ -13,9 +13,9 @@
     "size-esm-runtime": "node scripts/build.js vue -f esm-bundler-runtime",
     "size-esm": "node scripts/build.js runtime-dom runtime-core reactivity shared -f esm-bundler",
     "check": "tsc --incremental --noEmit",
-    "lint": "eslint --cache --ext .ts packages/*/{src,__tests__}/**.ts",
-    "format": "prettier --write --cache \"**/*.[tj]s?(x)\"",
-    "format-check": "prettier --check --cache \"**/*.[tj]s?(x)\"",
+    "lint": "eslint --cache --ext .js,.ts,.tsx .",
+    "format": "prettier --write --cache .",
+    "format-check": "prettier --check --cache .",
     "test": "vitest",
     "test-unit": "vitest -c vitest.unit.config.ts",
     "test-e2e": "node scripts/build.js vue -f global -d && vitest -c vitest.e2e.config.ts",
@@ -72,6 +72,7 @@
     "@types/minimist": "^1.2.5",
     "@types/node": "^20.10.5",
     "@types/semver": "^7.5.5",
+    "@typescript-eslint/eslint-plugin": "^6.16.0",
     "@typescript-eslint/parser": "^6.15.0",
     "@vitest/coverage-istanbul": "^1.1.0",
     "@vue/consolidate": "0.17.3",
@@ -81,6 +82,7 @@
     "esbuild-plugin-polyfill-node": "^0.3.0",
     "eslint": "^8.56.0",
     "eslint-define-config": "^1.24.1",
+    "eslint-plugin-import": "npm:eslint-plugin-i@^2.29.1",
     "eslint-plugin-jest": "^27.6.0",
     "estree-walker": "^2.0.2",
     "execa": "^8.0.1",
index 4938e7585464e4a01220eb60c58d13bb95d7242c..9c9230756343d0867a176df82a6b580ac016a8b7 100644 (file)
@@ -1,38 +1,38 @@
 import {
-  locStub,
-  generate,
+  ConstantTypes,
+  type DirectiveArguments,
+  type ForCodegenNode,
+  type IfConditionalExpression,
   NodeTypes,
-  RootNode,
-  createSimpleExpression,
-  createObjectExpression,
-  createObjectProperty,
+  type RootNode,
+  type VNodeCall,
   createArrayExpression,
-  createCompoundExpression,
-  createInterpolation,
+  createAssignmentExpression,
+  createBlockStatement,
+  createCacheExpression,
   createCallExpression,
+  createCompoundExpression,
   createConditionalExpression,
-  ForCodegenNode,
-  createCacheExpression,
-  createTemplateLiteral,
-  createBlockStatement,
   createIfStatement,
-  createAssignmentExpression,
-  IfConditionalExpression,
+  createInterpolation,
+  createObjectExpression,
+  createObjectProperty,
+  createSimpleExpression,
+  createTemplateLiteral,
   createVNodeCall,
-  VNodeCall,
-  DirectiveArguments,
-  ConstantTypes
+  generate,
+  locStub,
 } from '../src'
 import {
-  CREATE_VNODE,
-  TO_DISPLAY_STRING,
-  RESOLVE_DIRECTIVE,
-  helperNameMap,
-  RESOLVE_COMPONENT,
   CREATE_COMMENT,
+  CREATE_ELEMENT_VNODE,
+  CREATE_VNODE,
   FRAGMENT,
   RENDER_LIST,
-  CREATE_ELEMENT_VNODE
+  RESOLVE_COMPONENT,
+  RESOLVE_DIRECTIVE,
+  TO_DISPLAY_STRING,
+  helperNameMap,
 } from '../src/runtimeHelpers'
 import { createElementWithCodegen, genFlagText } from './testUtils'
 import { PatchFlags } from '@vue/shared'
@@ -51,59 +51,59 @@ function createRoot(options: Partial<RootNode> = {}): RootNode {
     temps: 0,
     codegenNode: createSimpleExpression(`null`, false),
     loc: locStub,
-    ...options
+    ...options,
   }
 }
 
 describe('compiler: codegen', () => {
   test('module mode preamble', () => {
     const root = createRoot({
-      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE])
+      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE]),
     })
     const { code } = generate(root, { mode: 'module' })
     expect(code).toMatch(
-      `import { ${helperNameMap[CREATE_VNODE]} as _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]} as _${helperNameMap[RESOLVE_DIRECTIVE]} } from "vue"`
+      `import { ${helperNameMap[CREATE_VNODE]} as _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]} as _${helperNameMap[RESOLVE_DIRECTIVE]} } from "vue"`,
     )
     expect(code).toMatchSnapshot()
   })
 
   test('module mode preamble w/ optimizeImports: true', () => {
     const root = createRoot({
-      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE])
+      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE]),
     })
     const { code } = generate(root, { mode: 'module', optimizeImports: true })
     expect(code).toMatch(
-      `import { ${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]} } from "vue"`
+      `import { ${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]} } from "vue"`,
     )
     expect(code).toMatch(
-      `const _${helperNameMap[CREATE_VNODE]} = ${helperNameMap[CREATE_VNODE]}, _${helperNameMap[RESOLVE_DIRECTIVE]} = ${helperNameMap[RESOLVE_DIRECTIVE]}`
+      `const _${helperNameMap[CREATE_VNODE]} = ${helperNameMap[CREATE_VNODE]}, _${helperNameMap[RESOLVE_DIRECTIVE]} = ${helperNameMap[RESOLVE_DIRECTIVE]}`,
     )
     expect(code).toMatchSnapshot()
   })
 
   test('function mode preamble', () => {
     const root = createRoot({
-      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE])
+      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE]),
     })
     const { code } = generate(root, { mode: 'function' })
     expect(code).toMatch(`const _Vue = Vue`)
     expect(code).toMatch(
-      `const { ${helperNameMap[CREATE_VNODE]}: _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${helperNameMap[RESOLVE_DIRECTIVE]} } = _Vue`
+      `const { ${helperNameMap[CREATE_VNODE]}: _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${helperNameMap[RESOLVE_DIRECTIVE]} } = _Vue`,
     )
     expect(code).toMatchSnapshot()
   })
 
   test('function mode preamble w/ prefixIdentifiers: true', () => {
     const root = createRoot({
-      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE])
+      helpers: new Set([CREATE_VNODE, RESOLVE_DIRECTIVE]),
     })
     const { code } = generate(root, {
       mode: 'function',
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(code).not.toMatch(`const _Vue = Vue`)
     expect(code).toMatch(
-      `const { ${helperNameMap[CREATE_VNODE]}: _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${helperNameMap[RESOLVE_DIRECTIVE]} } = Vue`
+      `const { ${helperNameMap[CREATE_VNODE]}: _${helperNameMap[CREATE_VNODE]}, ${helperNameMap[RESOLVE_DIRECTIVE]}: _${helperNameMap[RESOLVE_DIRECTIVE]} } = Vue`,
     )
     expect(code).toMatchSnapshot()
   })
@@ -112,27 +112,27 @@ describe('compiler: codegen', () => {
     const root = createRoot({
       components: [`Foo`, `bar-baz`, `barbaz`, `Qux__self`],
       directives: [`my_dir_0`, `my_dir_1`],
-      temps: 3
+      temps: 3,
     })
     const { code } = generate(root, { mode: 'function' })
     expect(code).toMatch(
-      `const _component_Foo = _${helperNameMap[RESOLVE_COMPONENT]}("Foo")\n`
+      `const _component_Foo = _${helperNameMap[RESOLVE_COMPONENT]}("Foo")\n`,
     )
     expect(code).toMatch(
-      `const _component_bar_baz = _${helperNameMap[RESOLVE_COMPONENT]}("bar-baz")\n`
+      `const _component_bar_baz = _${helperNameMap[RESOLVE_COMPONENT]}("bar-baz")\n`,
     )
     expect(code).toMatch(
-      `const _component_barbaz = _${helperNameMap[RESOLVE_COMPONENT]}("barbaz")\n`
+      `const _component_barbaz = _${helperNameMap[RESOLVE_COMPONENT]}("barbaz")\n`,
     )
     // implicit self reference from SFC filename
     expect(code).toMatch(
-      `const _component_Qux = _${helperNameMap[RESOLVE_COMPONENT]}("Qux", true)\n`
+      `const _component_Qux = _${helperNameMap[RESOLVE_COMPONENT]}("Qux", true)\n`,
     )
     expect(code).toMatch(
-      `const _directive_my_dir_0 = _${helperNameMap[RESOLVE_DIRECTIVE]}("my_dir_0")\n`
+      `const _directive_my_dir_0 = _${helperNameMap[RESOLVE_DIRECTIVE]}("my_dir_0")\n`,
     )
     expect(code).toMatch(
-      `const _directive_my_dir_1 = _${helperNameMap[RESOLVE_DIRECTIVE]}("my_dir_1")\n`
+      `const _directive_my_dir_1 = _${helperNameMap[RESOLVE_DIRECTIVE]}("my_dir_1")\n`,
     )
     expect(code).toMatch(`let _temp0, _temp1, _temp2`)
     expect(code).toMatchSnapshot()
@@ -146,12 +146,12 @@ describe('compiler: codegen', () => {
           [
             createObjectProperty(
               createSimpleExpression(`id`, true, locStub),
-              createSimpleExpression(`foo`, true, locStub)
-            )
+              createSimpleExpression(`foo`, true, locStub),
+            ),
           ],
-          locStub
-        )
-      ]
+          locStub,
+        ),
+      ],
     })
     const { code } = generate(root)
     expect(code).toMatch(`const _hoisted_1 = hello`)
@@ -161,7 +161,7 @@ describe('compiler: codegen', () => {
 
   test('temps', () => {
     const root = createRoot({
-      temps: 3
+      temps: 3,
     })
     const { code } = generate(root)
     expect(code).toMatch(`let _temp0, _temp1, _temp2`)
@@ -174,9 +174,9 @@ describe('compiler: codegen', () => {
         codegenNode: {
           type: NodeTypes.TEXT,
           content: 'hello',
-          loc: locStub
-        }
-      })
+          loc: locStub,
+        },
+      }),
     )
     expect(code).toMatch(`return "hello"`)
     expect(code).toMatchSnapshot()
@@ -185,8 +185,8 @@ describe('compiler: codegen', () => {
   test('interpolation', () => {
     const { code } = generate(
       createRoot({
-        codegenNode: createInterpolation(`hello`, locStub)
-      })
+        codegenNode: createInterpolation(`hello`, locStub),
+      }),
     )
     expect(code).toMatch(`return _${helperNameMap[TO_DISPLAY_STRING]}(hello)`)
     expect(code).toMatchSnapshot()
@@ -198,9 +198,9 @@ describe('compiler: codegen', () => {
         codegenNode: {
           type: NodeTypes.COMMENT,
           content: 'foo',
-          loc: locStub
-        }
-      })
+          loc: locStub,
+        },
+      }),
     )
     expect(code).toMatch(`return _${helperNameMap[CREATE_COMMENT]}("foo")`)
     expect(code).toMatchSnapshot()
@@ -216,15 +216,15 @@ describe('compiler: codegen', () => {
           {
             type: NodeTypes.INTERPOLATION,
             loc: locStub,
-            content: createSimpleExpression(`bar`, false, locStub)
+            content: createSimpleExpression(`bar`, false, locStub),
           },
           // nested compound
-          createCompoundExpression([` + `, `nested`])
-        ])
-      })
+          createCompoundExpression([` + `, `nested`]),
+        ]),
+      }),
     )
     expect(code).toMatch(
-      `return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar) + nested`
+      `return _ctx.foo + _${helperNameMap[TO_DISPLAY_STRING]}(bar) + nested`,
     )
     expect(code).toMatchSnapshot()
   })
@@ -239,10 +239,10 @@ describe('compiler: codegen', () => {
           codegenNode: createConditionalExpression(
             createSimpleExpression('foo', false),
             createSimpleExpression('bar', false),
-            createSimpleExpression('baz', false)
-          ) as IfConditionalExpression
-        }
-      })
+            createSimpleExpression('baz', false),
+          ) as IfConditionalExpression,
+        },
+      }),
     )
     expect(code).toMatch(/return foo\s+\? bar\s+: baz/)
     expect(code).toMatchSnapshot()
@@ -270,10 +270,10 @@ describe('compiler: codegen', () => {
             patchFlag: '1',
             dynamicProps: undefined,
             directives: undefined,
-            loc: locStub
-          } as ForCodegenNode
-        }
-      })
+            loc: locStub,
+          } as ForCodegenNode,
+        },
+      }),
     )
     expect(code).toMatch(`openBlock(true)`)
     expect(code).toMatchSnapshot()
@@ -289,7 +289,7 @@ describe('compiler: codegen', () => {
             '1 + 2',
             false,
             locStub,
-            ConstantTypes.CAN_STRINGIFY
+            ConstantTypes.CAN_STRINGIFY,
           ),
           valueAlias: undefined,
           keyAlias: undefined,
@@ -306,10 +306,10 @@ describe('compiler: codegen', () => {
             patchFlag: genFlagText(PatchFlags.STABLE_FRAGMENT),
             dynamicProps: undefined,
             directives: undefined,
-            loc: locStub
-          } as ForCodegenNode
-        }
-      })
+            loc: locStub,
+          } as ForCodegenNode,
+        },
+      }),
     )
     expect(code).toMatch(`openBlock()`)
     expect(code).toMatchSnapshot()
@@ -326,11 +326,11 @@ describe('compiler: codegen', () => {
             [
               createObjectProperty(
                 createSimpleExpression(`id`, true, locStub),
-                createSimpleExpression(`foo`, true, locStub)
+                createSimpleExpression(`foo`, true, locStub),
               ),
               createObjectProperty(
                 createSimpleExpression(`prop`, false, locStub),
-                createSimpleExpression(`bar`, false, locStub)
+                createSimpleExpression(`bar`, false, locStub),
               ),
               // compound expression as computed key
               createObjectProperty(
@@ -339,13 +339,13 @@ describe('compiler: codegen', () => {
                   loc: locStub,
                   children: [
                     `foo + `,
-                    createSimpleExpression(`bar`, false, locStub)
-                  ]
+                    createSimpleExpression(`bar`, false, locStub),
+                  ],
                 },
-                createSimpleExpression(`bar`, false, locStub)
-              )
+                createSimpleExpression(`bar`, false, locStub),
+              ),
             ],
-            locStub
+            locStub,
           ),
           // ChildNode[]
           [
@@ -356,17 +356,17 @@ describe('compiler: codegen', () => {
                   createObjectProperty(
                     // should quote the key!
                     createSimpleExpression(`some-key`, true, locStub),
-                    createSimpleExpression(`foo`, true, locStub)
-                  )
+                    createSimpleExpression(`foo`, true, locStub),
+                  ),
                 ],
-                locStub
-              )
-            )
+                locStub,
+              ),
+            ),
           ],
           // flag
-          PatchFlags.FULL_PROPS + ''
-        )
-      })
+          PatchFlags.FULL_PROPS + '',
+        ),
+      }),
     )
     expect(code).toMatch(`
     return _${helperNameMap[CREATE_ELEMENT_VNODE]}("div", {
@@ -384,9 +384,9 @@ describe('compiler: codegen', () => {
       createRoot({
         codegenNode: createArrayExpression([
           createSimpleExpression(`foo`, false),
-          createCallExpression(`bar`, [`baz`])
-        ])
-      })
+          createCallExpression(`bar`, [`baz`]),
+        ]),
+      }),
     )
     expect(code).toMatch(`return [
       foo,
@@ -404,17 +404,17 @@ describe('compiler: codegen', () => {
           createConditionalExpression(
             createSimpleExpression(`orNot`, false),
             createCallExpression(`bar`),
-            createCallExpression(`baz`)
-          )
-        )
-      })
+            createCallExpression(`baz`),
+          ),
+        ),
+      }),
     )
     expect(code).toMatch(
       `return ok
       ? foo()
       : orNot
         ? bar()
-        : baz()`
+        : baz()`,
     )
     expect(code).toMatchSnapshot()
   })
@@ -425,13 +425,13 @@ describe('compiler: codegen', () => {
         cached: 1,
         codegenNode: createCacheExpression(
           1,
-          createSimpleExpression(`foo`, false)
-        )
+          createSimpleExpression(`foo`, false),
+        ),
       }),
       {
         mode: 'module',
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     expect(code).toMatch(`_cache[1] || (_cache[1] = foo)`)
     expect(code).toMatchSnapshot()
@@ -444,13 +444,13 @@ describe('compiler: codegen', () => {
         codegenNode: createCacheExpression(
           1,
           createSimpleExpression(`foo`, false),
-          true
-        )
+          true,
+        ),
       }),
       {
         mode: 'module',
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     expect(code).toMatch(
       `
@@ -460,7 +460,7 @@ describe('compiler: codegen', () => {
     _setBlockTracking(1),
     _cache[1]
   )
-    `.trim()
+    `.trim(),
     )
     expect(code).toMatchSnapshot()
   })
@@ -472,11 +472,11 @@ describe('compiler: codegen', () => {
           createTemplateLiteral([
             `foo`,
             createCallExpression(`_renderAttr`, ['id', 'foo']),
-            `bar`
-          ])
-        ])
+            `bar`,
+          ]),
+        ]),
       }),
-      { ssr: true, mode: 'module' }
+      { ssr: true, mode: 'module' },
     )
     expect(code).toMatchInlineSnapshot(`
       "
@@ -493,11 +493,11 @@ describe('compiler: codegen', () => {
           codegenNode: createBlockStatement([
             createIfStatement(
               createSimpleExpression('foo', false),
-              createBlockStatement([createCallExpression(`ok`)])
-            )
-          ])
+              createBlockStatement([createCallExpression(`ok`)]),
+            ),
+          ]),
         }),
-        { ssr: true, mode: 'module' }
+        { ssr: true, mode: 'module' },
       )
       expect(code).toMatchInlineSnapshot(`
         "
@@ -516,11 +516,11 @@ describe('compiler: codegen', () => {
             createIfStatement(
               createSimpleExpression('foo', false),
               createBlockStatement([createCallExpression(`foo`)]),
-              createBlockStatement([createCallExpression('bar')])
-            )
-          ])
+              createBlockStatement([createCallExpression('bar')]),
+            ),
+          ]),
         }),
-        { ssr: true, mode: 'module' }
+        { ssr: true, mode: 'module' },
       )
       expect(code).toMatchInlineSnapshot(`
         "
@@ -543,12 +543,12 @@ describe('compiler: codegen', () => {
               createBlockStatement([createCallExpression(`foo`)]),
               createIfStatement(
                 createSimpleExpression('bar', false),
-                createBlockStatement([createCallExpression(`bar`)])
-              )
-            )
-          ])
+                createBlockStatement([createCallExpression(`bar`)]),
+              ),
+            ),
+          ]),
         }),
-        { ssr: true, mode: 'module' }
+        { ssr: true, mode: 'module' },
       )
       expect(code).toMatchInlineSnapshot(`
         "
@@ -572,12 +572,12 @@ describe('compiler: codegen', () => {
               createIfStatement(
                 createSimpleExpression('bar', false),
                 createBlockStatement([createCallExpression(`bar`)]),
-                createBlockStatement([createCallExpression('baz')])
-              )
-            )
-          ])
+                createBlockStatement([createCallExpression('baz')]),
+              ),
+            ),
+          ]),
         }),
-        { ssr: true, mode: 'module' }
+        { ssr: true, mode: 'module' },
       )
       expect(code).toMatchInlineSnapshot(`
         "
@@ -599,9 +599,9 @@ describe('compiler: codegen', () => {
       createRoot({
         codegenNode: createAssignmentExpression(
           createSimpleExpression(`foo`, false),
-          createSimpleExpression(`bar`, false)
-        )
-      })
+          createSimpleExpression(`bar`, false),
+        ),
+      }),
     )
     expect(code).toMatchInlineSnapshot(`
       "
@@ -617,17 +617,17 @@ describe('compiler: codegen', () => {
     function genCode(node: VNodeCall) {
       return generate(
         createRoot({
-          codegenNode: node
-        })
+          codegenNode: node,
+        }),
       ).code.match(/with \(_ctx\) \{\s+([^]+)\s+\}\s+\}$/)![1]
     }
 
     const mockProps = createObjectExpression([
-      createObjectProperty(`foo`, createSimpleExpression(`bar`, true))
+      createObjectProperty(`foo`, createSimpleExpression(`bar`, true)),
     ])
     const mockChildren = createCompoundExpression(['children'])
     const mockDirs = createArrayExpression([
-      createArrayExpression([`foo`, createSimpleExpression(`bar`, false)])
+      createArrayExpression([`foo`, createSimpleExpression(`bar`, false)]),
     ]) as DirectiveArguments
 
     test('tag only', () => {
@@ -684,9 +684,9 @@ describe('compiler: codegen', () => {
             undefined,
             undefined,
             undefined,
-            true
-          )
-        )
+            true,
+          ),
+        ),
       ).toMatchInlineSnapshot(`
         "return (_openBlock(), _createElementBlock("div", { foo: "bar" }, children))
          "
@@ -705,9 +705,9 @@ describe('compiler: codegen', () => {
             undefined,
             undefined,
             true,
-            true
-          )
-        )
+            true,
+          ),
+        ),
       ).toMatchInlineSnapshot(`
         "return (_openBlock(true), _createElementBlock("div", { foo: "bar" }, children))
          "
@@ -724,9 +724,9 @@ describe('compiler: codegen', () => {
             mockChildren,
             undefined,
             undefined,
-            mockDirs
-          )
-        )
+            mockDirs,
+          ),
+        ),
       ).toMatchInlineSnapshot(`
         "return _withDirectives(_createElementVNode("div", { foo: "bar" }, children), [
               [foo, bar]
@@ -746,9 +746,9 @@ describe('compiler: codegen', () => {
             undefined,
             undefined,
             mockDirs,
-            true
-          )
-        )
+            true,
+          ),
+        ),
       ).toMatchInlineSnapshot(`
         "return _withDirectives((_openBlock(), _createElementBlock("div", { foo: "bar" }, children)), [
               [foo, bar]
index dc4f57ad3d2725f487201ea517e3edd6dd2c1b7e..995741091df6082d50abe479b8a9e9d6348beb9c 100644 (file)
@@ -1,5 +1,5 @@
 import { baseCompile as compile } from '../src'
-import { SourceMapConsumer, RawSourceMap } from 'source-map-js'
+import { type RawSourceMap, SourceMapConsumer } from 'source-map-js'
 
 describe('compiler: integration tests', () => {
   const source = `
@@ -20,7 +20,7 @@ describe('compiler: integration tests', () => {
   function getPositionInCode(
     code: string,
     token: string,
-    expectName: string | boolean = false
+    expectName: string | boolean = false,
   ): Pos {
     const generatedOffset = code.indexOf(token)
     let line = 1
@@ -36,7 +36,7 @@ describe('compiler: integration tests', () => {
       column:
         lastNewLinePos === -1
           ? generatedOffset
-          : generatedOffset - lastNewLinePos - 1
+          : generatedOffset - lastNewLinePos - 1,
     }
     if (expectName) {
       res.name = typeof expectName === 'string' ? expectName : token
@@ -47,7 +47,7 @@ describe('compiler: integration tests', () => {
   test('function mode', () => {
     const { code, map } = compile(source, {
       sourceMap: true,
-      filename: `foo.vue`
+      filename: `foo.vue`,
     })
 
     expect(code).toMatchSnapshot()
@@ -57,55 +57,55 @@ describe('compiler: integration tests', () => {
     const consumer = new SourceMapConsumer(map as RawSourceMap)
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `id`))
+      consumer.originalPositionFor(getPositionInCode(code, `id`)),
     ).toMatchObject(getPositionInCode(source, `id`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `"foo"`))
+      consumer.originalPositionFor(getPositionInCode(code, `"foo"`)),
     ).toMatchObject(getPositionInCode(source, `"foo"`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `class:`))
+      consumer.originalPositionFor(getPositionInCode(code, `class:`)),
     ).toMatchObject(getPositionInCode(source, `class=`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `bar`))
+      consumer.originalPositionFor(getPositionInCode(code, `bar`)),
     ).toMatchObject(getPositionInCode(source, `bar`))
 
     // without prefixIdentifiers: true, identifiers inside compound expressions
     // are mapped to closest parent expression.
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `baz`))
+      consumer.originalPositionFor(getPositionInCode(code, `baz`)),
     ).toMatchObject(getPositionInCode(source, `bar`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `world`))
+      consumer.originalPositionFor(getPositionInCode(code, `world`)),
     ).toMatchObject(getPositionInCode(source, `world`))
 
     // without prefixIdentifiers: true, identifiers inside compound expressions
     // are mapped to closest parent expression.
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `burn()`))
+      consumer.originalPositionFor(getPositionInCode(code, `burn()`)),
     ).toMatchObject(getPositionInCode(source, `world`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `ok`))
+      consumer.originalPositionFor(getPositionInCode(code, `ok`)),
     ).toMatchObject(getPositionInCode(source, `ok`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `list`))
+      consumer.originalPositionFor(getPositionInCode(code, `list`)),
     ).toMatchObject(getPositionInCode(source, `list`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `value`))
+      consumer.originalPositionFor(getPositionInCode(code, `value`)),
     ).toMatchObject(getPositionInCode(source, `value`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `index`))
+      consumer.originalPositionFor(getPositionInCode(code, `index`)),
     ).toMatchObject(getPositionInCode(source, `index`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `value + index`))
+      consumer.originalPositionFor(getPositionInCode(code, `value + index`)),
     ).toMatchObject(getPositionInCode(source, `value + index`))
   })
 
@@ -113,7 +113,7 @@ describe('compiler: integration tests', () => {
     const { code, map } = compile(source, {
       sourceMap: true,
       filename: `foo.vue`,
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
 
     expect(code).toMatchSnapshot()
@@ -123,64 +123,66 @@ describe('compiler: integration tests', () => {
     const consumer = new SourceMapConsumer(map as RawSourceMap)
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `id`))
+      consumer.originalPositionFor(getPositionInCode(code, `id`)),
     ).toMatchObject(getPositionInCode(source, `id`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `"foo"`))
+      consumer.originalPositionFor(getPositionInCode(code, `"foo"`)),
     ).toMatchObject(getPositionInCode(source, `"foo"`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `class:`))
+      consumer.originalPositionFor(getPositionInCode(code, `class:`)),
     ).toMatchObject(getPositionInCode(source, `class=`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `bar`))
+      consumer.originalPositionFor(getPositionInCode(code, `bar`)),
     ).toMatchObject(getPositionInCode(source, `bar`))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `_ctx.bar`, `bar`))
+      consumer.originalPositionFor(getPositionInCode(code, `_ctx.bar`, `bar`)),
     ).toMatchObject(getPositionInCode(source, `bar`, true))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `baz`))
+      consumer.originalPositionFor(getPositionInCode(code, `baz`)),
     ).toMatchObject(getPositionInCode(source, `baz`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `world`, true))
+      consumer.originalPositionFor(getPositionInCode(code, `world`, true)),
     ).toMatchObject(getPositionInCode(source, `world`, `world`))
     expect(
       consumer.originalPositionFor(
-        getPositionInCode(code, `_ctx.world`, `world`)
-      )
+        getPositionInCode(code, `_ctx.world`, `world`),
+      ),
     ).toMatchObject(getPositionInCode(source, `world`, `world`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `burn()`))
+      consumer.originalPositionFor(getPositionInCode(code, `burn()`)),
     ).toMatchObject(getPositionInCode(source, `burn()`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `ok`))
+      consumer.originalPositionFor(getPositionInCode(code, `ok`)),
     ).toMatchObject(getPositionInCode(source, `ok`))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `_ctx.ok`, `ok`))
+      consumer.originalPositionFor(getPositionInCode(code, `_ctx.ok`, `ok`)),
     ).toMatchObject(getPositionInCode(source, `ok`, true))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `list`))
+      consumer.originalPositionFor(getPositionInCode(code, `list`)),
     ).toMatchObject(getPositionInCode(source, `list`))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `_ctx.list`, `list`))
+      consumer.originalPositionFor(
+        getPositionInCode(code, `_ctx.list`, `list`),
+      ),
     ).toMatchObject(getPositionInCode(source, `list`, true))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `value`))
+      consumer.originalPositionFor(getPositionInCode(code, `value`)),
     ).toMatchObject(getPositionInCode(source, `value`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `index`))
+      consumer.originalPositionFor(getPositionInCode(code, `index`)),
     ).toMatchObject(getPositionInCode(source, `index`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `value + index`))
+      consumer.originalPositionFor(getPositionInCode(code, `value + index`)),
     ).toMatchObject(getPositionInCode(source, `value + index`))
   })
 
@@ -188,7 +190,7 @@ describe('compiler: integration tests', () => {
     const { code, map } = compile(source, {
       mode: 'module',
       sourceMap: true,
-      filename: `foo.vue`
+      filename: `foo.vue`,
     })
 
     expect(code).toMatchSnapshot()
@@ -198,64 +200,66 @@ describe('compiler: integration tests', () => {
     const consumer = new SourceMapConsumer(map as RawSourceMap)
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `id`))
+      consumer.originalPositionFor(getPositionInCode(code, `id`)),
     ).toMatchObject(getPositionInCode(source, `id`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `"foo"`))
+      consumer.originalPositionFor(getPositionInCode(code, `"foo"`)),
     ).toMatchObject(getPositionInCode(source, `"foo"`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `class:`))
+      consumer.originalPositionFor(getPositionInCode(code, `class:`)),
     ).toMatchObject(getPositionInCode(source, `class=`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `bar`))
+      consumer.originalPositionFor(getPositionInCode(code, `bar`)),
     ).toMatchObject(getPositionInCode(source, `bar`))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `_ctx.bar`, `bar`))
+      consumer.originalPositionFor(getPositionInCode(code, `_ctx.bar`, `bar`)),
     ).toMatchObject(getPositionInCode(source, `bar`, true))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `baz`))
+      consumer.originalPositionFor(getPositionInCode(code, `baz`)),
     ).toMatchObject(getPositionInCode(source, `baz`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `world`, true))
+      consumer.originalPositionFor(getPositionInCode(code, `world`, true)),
     ).toMatchObject(getPositionInCode(source, `world`, `world`))
     expect(
       consumer.originalPositionFor(
-        getPositionInCode(code, `_ctx.world`, `world`)
-      )
+        getPositionInCode(code, `_ctx.world`, `world`),
+      ),
     ).toMatchObject(getPositionInCode(source, `world`, `world`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `burn()`))
+      consumer.originalPositionFor(getPositionInCode(code, `burn()`)),
     ).toMatchObject(getPositionInCode(source, `burn()`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `ok`))
+      consumer.originalPositionFor(getPositionInCode(code, `ok`)),
     ).toMatchObject(getPositionInCode(source, `ok`))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `_ctx.ok`, `ok`))
+      consumer.originalPositionFor(getPositionInCode(code, `_ctx.ok`, `ok`)),
     ).toMatchObject(getPositionInCode(source, `ok`, true))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `list`))
+      consumer.originalPositionFor(getPositionInCode(code, `list`)),
     ).toMatchObject(getPositionInCode(source, `list`))
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `_ctx.list`, `list`))
+      consumer.originalPositionFor(
+        getPositionInCode(code, `_ctx.list`, `list`),
+      ),
     ).toMatchObject(getPositionInCode(source, `list`, true))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `value`))
+      consumer.originalPositionFor(getPositionInCode(code, `value`)),
     ).toMatchObject(getPositionInCode(source, `value`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `index`))
+      consumer.originalPositionFor(getPositionInCode(code, `index`)),
     ).toMatchObject(getPositionInCode(source, `index`))
 
     expect(
-      consumer.originalPositionFor(getPositionInCode(code, `value + index`))
+      consumer.originalPositionFor(getPositionInCode(code, `value + index`)),
     ).toMatchObject(getPositionInCode(source, `value + index`))
   })
 })
index e49ce2bd4ce5adee1033bcc0f3dfa54901fa45f7..d5bdb4bc5fdb4ca2db3d735f7bba38376beac402 100644 (file)
@@ -1,20 +1,20 @@
-import { ParserOptions } from '../src/options'
+import type { ParserOptions } from '../src/options'
 import { ErrorCodes } from '../src/errors'
 import {
-  CommentNode,
-  ElementNode,
+  type CommentNode,
+  ConstantTypes,
+  type DirectiveNode,
+  type ElementNode,
   ElementTypes,
+  type InterpolationNode,
   Namespaces,
   NodeTypes,
-  Position,
-  TextNode,
-  InterpolationNode,
-  ConstantTypes,
-  DirectiveNode
+  type Position,
+  type TextNode,
 } from '../src/ast'
 
 import { baseParse } from '../src/parser'
-import { Program } from '@babel/types'
+import type { Program } from '@babel/types'
 
 /* eslint jest/no-disabled-tests: "off" */
 
@@ -30,8 +30,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 9, line: 1, column: 10 },
-          source: 'some text'
-        }
+          source: 'some text',
+        },
       })
     })
 
@@ -46,10 +46,10 @@ describe('compiler: parse', () => {
             code: ErrorCodes.X_INVALID_END_TAG,
             loc: {
               start: { column: 10, line: 1, offset: 9 },
-              end: { column: 10, line: 1, offset: 9 }
-            }
-          }
-        ]
+              end: { column: 10, line: 1, offset: 9 },
+            },
+          },
+        ],
       ])
 
       expect(text).toStrictEqual({
@@ -58,8 +58,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 9, line: 1, column: 10 },
-          source: 'some text'
-        }
+          source: 'some text',
+        },
       })
     })
 
@@ -74,8 +74,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 5, line: 1, column: 6 },
-          source: 'some '
-        }
+          source: 'some ',
+        },
       })
       expect(text2).toStrictEqual({
         type: NodeTypes.TEXT,
@@ -83,8 +83,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 20, line: 1, column: 21 },
           end: { offset: 25, line: 1, column: 26 },
-          source: ' text'
-        }
+          source: ' text',
+        },
       })
     })
 
@@ -99,8 +99,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 5, line: 1, column: 6 },
-          source: 'some '
-        }
+          source: 'some ',
+        },
       })
       expect(text2).toStrictEqual({
         type: NodeTypes.TEXT,
@@ -108,8 +108,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 21, line: 1, column: 22 },
           end: { offset: 26, line: 1, column: 27 },
-          source: ' text'
-        }
+          source: ' text',
+        },
       })
     })
 
@@ -124,8 +124,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 5, line: 1, column: 6 },
-          source: 'some '
-        }
+          source: 'some ',
+        },
       })
       expect(text2).toStrictEqual({
         type: NodeTypes.TEXT,
@@ -133,8 +133,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 32, line: 1, column: 33 },
           end: { offset: 37, line: 1, column: 38 },
-          source: ' text'
-        }
+          source: ' text',
+        },
       })
     })
 
@@ -144,7 +144,7 @@ describe('compiler: parse', () => {
           if (err.code !== ErrorCodes.INVALID_FIRST_CHARACTER_OF_TAG_NAME) {
             throw err
           }
-        }
+        },
       })
       const text = ast.children[0] as TextNode
 
@@ -154,8 +154,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 5, line: 1, column: 6 },
-          source: 'a < b'
-        }
+          source: 'a < b',
+        },
       })
     })
 
@@ -165,7 +165,7 @@ describe('compiler: parse', () => {
           if (error.code !== ErrorCodes.X_MISSING_INTERPOLATION_END) {
             throw error
           }
-        }
+        },
       })
       const text = ast.children[0] as TextNode
 
@@ -175,8 +175,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 6, line: 1, column: 7 },
-          source: 'a {{ b'
-        }
+          source: 'a {{ b',
+        },
       })
     })
   })
@@ -196,14 +196,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 2, line: 1, column: 3 },
             end: { offset: 9, line: 1, column: 10 },
-            source: 'message'
-          }
+            source: 'message',
+          },
         },
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 11, line: 1, column: 12 },
-          source: '{{message}}'
-        }
+          source: '{{message}}',
+        },
       })
     })
 
@@ -221,14 +221,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 3, line: 1, column: 4 },
             end: { offset: 6, line: 1, column: 7 },
-            source: 'a<b'
-          }
+            source: 'a<b',
+          },
         },
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 9, line: 1, column: 10 },
-          source: '{{ a<b }}'
-        }
+          source: '{{ a<b }}',
+        },
       })
     })
 
@@ -247,14 +247,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 3, line: 1, column: 4 },
             end: { offset: 6, line: 1, column: 7 },
-            source: 'a<b'
-          }
+            source: 'a<b',
+          },
         },
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 9, line: 1, column: 10 },
-          source: '{{ a<b }}'
-        }
+          source: '{{ a<b }}',
+        },
       })
 
       expect(interpolation2).toStrictEqual({
@@ -267,14 +267,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 12, line: 1, column: 13 },
             end: { offset: 15, line: 1, column: 16 },
-            source: 'c>d'
-          }
+            source: 'c>d',
+          },
         },
         loc: {
           start: { offset: 9, line: 1, column: 10 },
           end: { offset: 18, line: 1, column: 19 },
-          source: '{{ c>d }}'
-        }
+          source: '{{ c>d }}',
+        },
       })
     })
 
@@ -294,20 +294,20 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 8, line: 1, column: 9 },
             end: { offset: 16, line: 1, column: 17 },
-            source: '"</div>"'
-          }
+            source: '"</div>"',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 19, line: 1, column: 20 },
-          source: '{{ "</div>" }}'
-        }
+          source: '{{ "</div>" }}',
+        },
       })
     })
 
     test('custom delimiters', () => {
       const ast = baseParse('<p>{msg}</p>', {
-        delimiters: ['{', '}']
+        delimiters: ['{', '}'],
       })
       const element = ast.children[0] as ElementNode
       const interpolation = element.children[0] as InterpolationNode
@@ -322,14 +322,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 4, line: 1, column: 5 },
             end: { offset: 7, line: 1, column: 8 },
-            source: 'msg'
-          }
+            source: 'msg',
+          },
         },
         loc: {
           start: { offset: 3, line: 1, column: 4 },
           end: { offset: 8, line: 1, column: 9 },
-          source: '{msg}'
-        }
+          source: '{msg}',
+        },
       })
     })
   })
@@ -345,8 +345,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 7, line: 1, column: 8 },
-          source: '<!---->'
-        }
+          source: '<!---->',
+        },
       })
     })
 
@@ -360,8 +360,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 10, line: 1, column: 11 },
-          source: '<!--abc-->'
-        }
+          source: '<!--abc-->',
+        },
       })
     })
 
@@ -376,8 +376,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 10, line: 1, column: 11 },
-          source: '<!--abc-->'
-        }
+          source: '<!--abc-->',
+        },
       })
       expect(comment2).toStrictEqual({
         type: NodeTypes.COMMENT,
@@ -385,8 +385,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 10, line: 1, column: 11 },
           end: { offset: 20, line: 1, column: 21 },
-          source: '<!--def-->'
-        }
+          source: '<!--def-->',
+        },
       })
     })
 
@@ -403,38 +403,38 @@ describe('compiler: parse', () => {
       const rawText = `<p/><!-- foo --><p/>`
 
       const astWithComments = baseParse(`<pre>${rawText}</pre>`, {
-        comments: true
+        comments: true,
       })
       expect(
-        (astWithComments.children[0] as ElementNode).children
+        (astWithComments.children[0] as ElementNode).children,
       ).toMatchObject([
         {
           type: NodeTypes.ELEMENT,
-          tag: 'p'
+          tag: 'p',
         },
         {
-          type: NodeTypes.COMMENT
+          type: NodeTypes.COMMENT,
         },
         {
           type: NodeTypes.ELEMENT,
-          tag: 'p'
-        }
+          tag: 'p',
+        },
       ])
 
       const astWithoutComments = baseParse(`<pre>${rawText}</pre>`, {
-        comments: false
+        comments: false,
       })
       expect(
-        (astWithoutComments.children[0] as ElementNode).children
+        (astWithoutComments.children[0] as ElementNode).children,
       ).toMatchObject([
         {
           type: NodeTypes.ELEMENT,
-          tag: 'p'
+          tag: 'p',
         },
         {
           type: NodeTypes.ELEMENT,
-          tag: 'p'
-        }
+          tag: 'p',
+        },
       ])
     })
   })
@@ -458,15 +458,15 @@ describe('compiler: parse', () => {
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 10, line: 1, column: 11 },
-              source: 'hello'
-            }
-          }
+              source: 'hello',
+            },
+          },
         ],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 16, line: 1, column: 17 },
-          source: '<div>hello</div>'
-        }
+          source: '<div>hello</div>',
+        },
       })
     })
 
@@ -485,8 +485,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 11, line: 1, column: 12 },
-          source: '<div></div>'
-        }
+          source: '<div></div>',
+        },
       })
     })
 
@@ -506,14 +506,14 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 6, line: 1, column: 7 },
-          source: '<div/>'
-        }
+          source: '<div/>',
+        },
       })
     })
 
     test('void element', () => {
       const ast = baseParse('<img>after', {
-        isVoidTag: tag => tag === 'img'
+        isVoidTag: tag => tag === 'img',
       })
       const element = ast.children[0] as ElementNode
 
@@ -528,14 +528,14 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 5, line: 1, column: 6 },
-          source: '<img>'
-        }
+          source: '<img>',
+        },
       })
     })
 
     test('self-closing void element', () => {
       const ast = baseParse('<img/>after', {
-        isVoidTag: tag => tag === 'img'
+        isVoidTag: tag => tag === 'img',
       })
       const element = ast.children[0] as ElementNode
 
@@ -551,8 +551,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 6, line: 1, column: 7 },
-          source: '<img/>'
-        }
+          source: '<img/>',
+        },
       })
     })
 
@@ -561,7 +561,7 @@ describe('compiler: parse', () => {
       const element = ast.children[0]
       expect(element).toMatchObject({
         type: NodeTypes.ELEMENT,
-        tagType: ElementTypes.TEMPLATE
+        tagType: ElementTypes.TEMPLATE,
       })
     })
 
@@ -570,31 +570,31 @@ describe('compiler: parse', () => {
       const element = ast.children[0]
       expect(element).toMatchObject({
         type: NodeTypes.ELEMENT,
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
     })
 
     test('native element with `isNativeTag`', () => {
       const ast = baseParse('<div></div><comp></comp><Comp></Comp>', {
-        isNativeTag: tag => tag === 'div'
+        isNativeTag: tag => tag === 'div',
       })
 
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
 
       expect(ast.children[2]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'Comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
@@ -604,19 +604,19 @@ describe('compiler: parse', () => {
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'comp',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[2]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'Comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
@@ -624,26 +624,26 @@ describe('compiler: parse', () => {
       const ast = baseParse(
         `<div></div><div is="vue:foo"></div><Comp></Comp>`,
         {
-          isNativeTag: tag => tag === 'div'
-        }
+          isNativeTag: tag => tag === 'div',
+        },
       )
 
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
 
       expect(ast.children[2]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'Comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
@@ -653,56 +653,56 @@ describe('compiler: parse', () => {
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
 
       expect(ast.children[2]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'Comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
     test('custom element', () => {
       const ast = baseParse('<div></div><comp></comp>', {
         isNativeTag: tag => tag === 'div',
-        isCustomElement: tag => tag === 'comp'
+        isCustomElement: tag => tag === 'comp',
       })
 
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'comp',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
     })
 
     test('built-in component', () => {
       const ast = baseParse('<div></div><comp></comp>', {
-        isBuiltInComponent: tag => (tag === 'comp' ? Symbol() : void 0)
+        isBuiltInComponent: tag => (tag === 'comp' ? Symbol() : void 0),
       })
 
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
@@ -712,13 +712,13 @@ describe('compiler: parse', () => {
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'slot',
-        tagType: ElementTypes.SLOT
+        tagType: ElementTypes.SLOT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'Comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
@@ -739,23 +739,23 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: undefined,
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
-            }
-          }
+              source: 'id',
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 14, line: 1, column: 15 },
-          source: '<div id></div>'
-        }
+          source: '<div id></div>',
+        },
       })
     })
 
@@ -776,7 +776,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -784,23 +784,23 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 8, line: 1, column: 9 },
                 end: { offset: 10, line: 1, column: 11 },
-                source: '""'
-              }
+                source: '""',
+              },
             },
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 10, line: 1, column: 11 },
-              source: 'id=""'
-            }
-          }
+              source: 'id=""',
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 17, line: 1, column: 18 },
-          source: '<div id=""></div>'
-        }
+          source: '<div id=""></div>',
+        },
       })
     })
 
@@ -821,7 +821,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -829,23 +829,23 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 8, line: 1, column: 9 },
                 end: { offset: 10, line: 1, column: 11 },
-                source: "''"
-              }
+                source: "''",
+              },
             },
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 10, line: 1, column: 11 },
-              source: "id=''"
-            }
-          }
+              source: "id=''",
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 17, line: 1, column: 18 },
-          source: "<div id=''></div>"
-        }
+          source: "<div id=''></div>",
+        },
       })
     })
 
@@ -866,7 +866,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -874,23 +874,23 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 8, line: 1, column: 9 },
                 end: { offset: 12, line: 1, column: 13 },
-                source: '">\'"'
-              }
+                source: '">\'"',
+              },
             },
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 12, line: 1, column: 13 },
-              source: 'id=">\'"'
-            }
-          }
+              source: 'id=">\'"',
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 19, line: 1, column: 20 },
-          source: '<div id=">\'"></div>'
-        }
+          source: '<div id=">\'"></div>',
+        },
       })
     })
 
@@ -911,7 +911,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -919,23 +919,23 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 8, line: 1, column: 9 },
                 end: { offset: 12, line: 1, column: 13 },
-                source: "'>\"'"
-              }
+                source: "'>\"'",
+              },
             },
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 12, line: 1, column: 13 },
-              source: "id='>\"'"
-            }
-          }
+              source: "id='>\"'",
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 19, line: 1, column: 20 },
-          source: "<div id='>\"'></div>"
-        }
+          source: "<div id='>\"'></div>",
+        },
       })
     })
 
@@ -956,7 +956,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -964,30 +964,30 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 8, line: 1, column: 9 },
                 end: { offset: 10, line: 1, column: 11 },
-                source: 'a/'
-              }
+                source: 'a/',
+              },
             },
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 10, line: 1, column: 11 },
-              source: 'id=a/'
-            }
-          }
+              source: 'id=a/',
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 17, line: 1, column: 18 },
-          source: '<div id=a/></div>'
-        }
+          source: '<div id=a/></div>',
+        },
       })
     })
 
     test('attribute value with >', () => {
       const ast = baseParse(
         '<script setup lang="ts" generic="T extends Record<string,string>"></script>',
-        { parseMode: 'sfc' }
+        { parseMode: 'sfc' },
       )
       const element = ast.children[0] as ElementNode
       expect(element).toMatchObject({
@@ -999,35 +999,35 @@ describe('compiler: parse', () => {
         children: [],
         innerLoc: {
           start: { column: 67, line: 1, offset: 66 },
-          end: { column: 67, line: 1, offset: 66 }
+          end: { column: 67, line: 1, offset: 66 },
         },
         props: [
           {
             loc: {
               source: 'setup',
               end: { column: 14, line: 1, offset: 13 },
-              start: { column: 9, line: 1, offset: 8 }
+              start: { column: 9, line: 1, offset: 8 },
             },
             name: 'setup',
             nameLoc: {
               source: 'setup',
               end: { column: 14, line: 1, offset: 13 },
-              start: { column: 9, line: 1, offset: 8 }
+              start: { column: 9, line: 1, offset: 8 },
             },
             type: NodeTypes.ATTRIBUTE,
-            value: undefined
+            value: undefined,
           },
           {
             loc: {
               source: 'lang="ts"',
               end: { column: 24, line: 1, offset: 23 },
-              start: { column: 15, line: 1, offset: 14 }
+              start: { column: 15, line: 1, offset: 14 },
             },
             name: 'lang',
             nameLoc: {
               source: 'lang',
               end: { column: 19, line: 1, offset: 18 },
-              start: { column: 15, line: 1, offset: 14 }
+              start: { column: 15, line: 1, offset: 14 },
             },
             type: NodeTypes.ATTRIBUTE,
             value: {
@@ -1035,22 +1035,22 @@ describe('compiler: parse', () => {
               loc: {
                 source: '"ts"',
                 end: { column: 24, line: 1, offset: 23 },
-                start: { column: 20, line: 1, offset: 19 }
+                start: { column: 20, line: 1, offset: 19 },
               },
-              type: NodeTypes.TEXT
-            }
+              type: NodeTypes.TEXT,
+            },
           },
           {
             loc: {
               source: 'generic="T extends Record<string,string>"',
               end: { column: 66, line: 1, offset: 65 },
-              start: { column: 25, line: 1, offset: 24 }
+              start: { column: 25, line: 1, offset: 24 },
             },
             name: 'generic',
             nameLoc: {
               source: 'generic',
               end: { column: 32, line: 1, offset: 31 },
-              start: { column: 25, line: 1, offset: 24 }
+              start: { column: 25, line: 1, offset: 24 },
             },
             type: NodeTypes.ATTRIBUTE,
             value: {
@@ -1058,12 +1058,12 @@ describe('compiler: parse', () => {
               loc: {
                 source: '"T extends Record<string,string>"',
                 end: { column: 66, line: 1, offset: 65 },
-                start: { column: 33, line: 1, offset: 32 }
+                start: { column: 33, line: 1, offset: 32 },
               },
-              type: NodeTypes.TEXT
-            }
-          }
-        ]
+              type: NodeTypes.TEXT,
+            },
+          },
+        ],
       })
     })
 
@@ -1084,7 +1084,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 7, line: 1, column: 8 },
-              source: 'id'
+              source: 'id',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -1092,14 +1092,14 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 8, line: 1, column: 9 },
                 end: { offset: 9, line: 1, column: 10 },
-                source: 'a'
-              }
+                source: 'a',
+              },
             },
             loc: {
               start: { offset: 5, line: 1, column: 6 },
               end: { offset: 9, line: 1, column: 10 },
-              source: 'id=a'
-            }
+              source: 'id=a',
+            },
           },
           {
             type: NodeTypes.ATTRIBUTE,
@@ -1107,7 +1107,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 10, line: 1, column: 11 },
               end: { offset: 15, line: 1, column: 16 },
-              source: 'class'
+              source: 'class',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -1115,14 +1115,14 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 16, line: 1, column: 17 },
                 end: { offset: 19, line: 1, column: 20 },
-                source: '"c"'
-              }
+                source: '"c"',
+              },
             },
             loc: {
               start: { offset: 10, line: 1, column: 11 },
               end: { offset: 19, line: 1, column: 20 },
-              source: 'class="c"'
-            }
+              source: 'class="c"',
+            },
           },
           {
             type: NodeTypes.ATTRIBUTE,
@@ -1130,14 +1130,14 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 20, line: 1, column: 21 },
               end: { offset: 25, line: 1, column: 26 },
-              source: 'inert'
+              source: 'inert',
             },
             value: undefined,
             loc: {
               start: { offset: 20, line: 1, column: 21 },
               end: { offset: 25, line: 1, column: 26 },
-              source: 'inert'
-            }
+              source: 'inert',
+            },
           },
           {
             type: NodeTypes.ATTRIBUTE,
@@ -1145,7 +1145,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { offset: 26, line: 1, column: 27 },
               end: { offset: 31, line: 1, column: 32 },
-              source: 'style'
+              source: 'style',
             },
             value: {
               type: NodeTypes.TEXT,
@@ -1153,23 +1153,23 @@ describe('compiler: parse', () => {
               loc: {
                 start: { offset: 32, line: 1, column: 33 },
                 end: { offset: 34, line: 1, column: 35 },
-                source: "''"
-              }
+                source: "''",
+              },
             },
             loc: {
               start: { offset: 26, line: 1, column: 27 },
               end: { offset: 34, line: 1, column: 35 },
-              source: "style=''"
-            }
-          }
+              source: "style=''",
+            },
+          },
         ],
 
         children: [],
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 41, line: 1, column: 42 },
-          source: '<div id=a class="c" inert style=\'\'></div>'
-        }
+          source: '<div id=a class="c" inert style=\'\'></div>',
+        },
       })
     })
 
@@ -1184,7 +1184,7 @@ describe('compiler: parse', () => {
         loc: {
           start: { column: 1, line: 1, offset: 0 },
           end: { column: 10, line: 3, offset: 29 },
-          source: '<div class=" \n\t c \t\n "></div>'
+          source: '<div class=" \n\t c \t\n "></div>',
         },
         ns: Namespaces.HTML,
         props: [
@@ -1193,7 +1193,7 @@ describe('compiler: parse', () => {
             nameLoc: {
               start: { column: 6, line: 1, offset: 5 },
               end: { column: 11, line: 1, offset: 10 },
-              source: 'class'
+              source: 'class',
             },
             type: NodeTypes.ATTRIBUTE,
             value: {
@@ -1201,20 +1201,20 @@ describe('compiler: parse', () => {
               loc: {
                 start: { column: 12, line: 1, offset: 11 },
                 end: { column: 3, line: 3, offset: 22 },
-                source: '" \n\t c \t\n "'
+                source: '" \n\t c \t\n "',
               },
-              type: NodeTypes.TEXT
+              type: NodeTypes.TEXT,
             },
             loc: {
               start: { column: 6, line: 1, offset: 5 },
               end: { column: 3, line: 3, offset: 22 },
-              source: 'class=" \n\t c \t\n "'
-            }
-          }
+              source: 'class=" \n\t c \t\n "',
+            },
+          },
         ],
         tag: 'div',
         tagType: ElementTypes.ELEMENT,
-        type: NodeTypes.ELEMENT
+        type: NodeTypes.ELEMENT,
       })
     })
 
@@ -1232,8 +1232,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 9, line: 1, column: 10 },
-          source: 'v-if'
-        }
+          source: 'v-if',
+        },
       })
     })
 
@@ -1255,14 +1255,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 11, line: 1, column: 12 },
             end: { offset: 12, line: 1, column: 13 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 13, line: 1, column: 14 },
-          source: 'v-if="a"'
-        }
+          source: 'v-if="a"',
+        },
       })
     })
 
@@ -1282,16 +1282,16 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 11, line: 1, offset: 10 },
             end: { column: 16, line: 1, offset: 15 },
-            source: 'click'
-          }
+            source: 'click',
+          },
         },
         modifiers: [],
         exp: undefined,
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 15, line: 1, column: 16 },
-          source: 'v-on:click'
-        }
+          source: 'v-on:click',
+        },
       })
     })
 
@@ -1303,8 +1303,8 @@ describe('compiler: parse', () => {
       expect(directive.arg).toMatchObject({
         loc: {
           start: { offset: 12, line: 1, column: 13 },
-          end: { offset: 16, line: 1, column: 17 }
-        }
+          end: { offset: 16, line: 1, column: 17 },
+        },
       })
     })
 
@@ -1317,8 +1317,8 @@ describe('compiler: parse', () => {
         content: 'item.item',
         loc: {
           start: { offset: 6, line: 1, column: 7 },
-          end: { offset: 15, line: 1, column: 16 }
-        }
+          end: { offset: 15, line: 1, column: 16 },
+        },
       })
     })
 
@@ -1338,16 +1338,16 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 11, line: 1, offset: 10 },
             end: { column: 18, line: 1, offset: 17 },
-            source: '[event]'
-          }
+            source: '[event]',
+          },
         },
         modifiers: [],
         exp: undefined,
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 17, line: 1, column: 18 },
-          source: 'v-on:[event]'
-        }
+          source: 'v-on:[event]',
+        },
       })
     })
 
@@ -1365,8 +1365,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 15, line: 1, column: 16 },
-          source: 'v-on.enter'
-        }
+          source: 'v-on.enter',
+        },
       })
     })
 
@@ -1384,8 +1384,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 21, line: 1, column: 22 },
-          source: 'v-on.enter.exact'
-        }
+          source: 'v-on.enter.exact',
+        },
       })
     })
 
@@ -1405,16 +1405,16 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 11, line: 1, offset: 10 },
             end: { column: 16, line: 1, offset: 15 },
-            source: 'click'
-          }
+            source: 'click',
+          },
         },
         modifiers: ['enter', 'exact'],
         exp: undefined,
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 27, line: 1, column: 28 },
-          source: 'v-on:click.enter.exact'
-        }
+          source: 'v-on:click.enter.exact',
+        },
       })
     })
 
@@ -1434,16 +1434,16 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 11, line: 1, offset: 10 },
             end: { column: 16, line: 1, offset: 15 },
-            source: '[a.b]'
-          }
+            source: '[a.b]',
+          },
         },
         modifiers: ['camel'],
         exp: undefined,
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 21, line: 1, column: 22 },
-          source: 'v-on:[a.b].camel'
-        }
+          source: 'v-on:[a.b].camel',
+        },
       })
     })
 
@@ -1452,7 +1452,7 @@ describe('compiler: parse', () => {
       const ast = baseParse('<div v-/>', {
         onError: err => {
           errorCode = err.code as number
-        }
+        },
       })
       const directive = (ast.children[0] as ElementNode).props[0]
 
@@ -1464,13 +1464,13 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 7, line: 1, column: 8 },
-          source: 'v-'
+          source: 'v-',
         },
         nameLoc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 7, line: 1, column: 8 },
-          source: 'v-'
-        }
+          source: 'v-',
+        },
       })
     })
 
@@ -1490,8 +1490,8 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 7, line: 1, offset: 6 },
             end: { column: 8, line: 1, offset: 7 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         modifiers: [],
         exp: {
@@ -1502,14 +1502,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 8, line: 1, column: 9 },
             end: { offset: 9, line: 1, column: 10 },
-            source: 'b'
-          }
+            source: 'b',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 9, line: 1, column: 10 },
-          source: ':a=b'
-        }
+          source: ':a=b',
+        },
       })
     })
 
@@ -1529,8 +1529,8 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 7, line: 1, offset: 6 },
             end: { column: 8, line: 1, offset: 7 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         modifiers: ['prop'],
         exp: {
@@ -1541,14 +1541,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 8, line: 1, column: 9 },
             end: { offset: 9, line: 1, column: 10 },
-            source: 'b'
-          }
+            source: 'b',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 9, line: 1, column: 10 },
-          source: '.a=b'
-        }
+          source: '.a=b',
+        },
       })
     })
 
@@ -1568,8 +1568,8 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 7, line: 1, offset: 6 },
             end: { column: 8, line: 1, offset: 7 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         modifiers: ['sync'],
         exp: {
@@ -1581,14 +1581,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 13, line: 1, column: 14 },
             end: { offset: 14, line: 1, column: 15 },
-            source: 'b'
-          }
+            source: 'b',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 14, line: 1, column: 15 },
-          source: ':a.sync=b'
-        }
+          source: ':a.sync=b',
+        },
       })
     })
 
@@ -1608,8 +1608,8 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 7, line: 1, offset: 6 },
             end: { column: 8, line: 1, offset: 7 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         modifiers: [],
         exp: {
@@ -1621,14 +1621,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 8, line: 1, column: 9 },
             end: { offset: 9, line: 1, column: 10 },
-            source: 'b'
-          }
+            source: 'b',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 9, line: 1, column: 10 },
-          source: '@a=b'
-        }
+          source: '@a=b',
+        },
       })
     })
 
@@ -1648,8 +1648,8 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 7, line: 1, offset: 6 },
             end: { column: 8, line: 1, offset: 7 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         modifiers: ['enter'],
         exp: {
@@ -1661,14 +1661,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 14, line: 1, column: 15 },
             end: { offset: 15, line: 1, column: 16 },
-            source: 'b'
-          }
+            source: 'b',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 15, line: 1, column: 16 },
-          source: '@a.enter=b'
-        }
+          source: '@a.enter=b',
+        },
       })
     })
 
@@ -1688,8 +1688,8 @@ describe('compiler: parse', () => {
           loc: {
             start: { column: 8, line: 1, offset: 7 },
             end: { column: 9, line: 1, offset: 8 },
-            source: 'a'
-          }
+            source: 'a',
+          },
         },
         modifiers: [],
         exp: {
@@ -1701,14 +1701,14 @@ describe('compiler: parse', () => {
           loc: {
             start: { offset: 10, line: 1, column: 11 },
             end: { offset: 15, line: 1, column: 16 },
-            source: '{ b }'
-          }
+            source: '{ b }',
+          },
         },
         loc: {
           start: { offset: 6, line: 1, column: 7 },
           end: { offset: 16, line: 1, column: 17 },
-          source: '#a="{ b }"'
-        }
+          source: '#a="{ b }"',
+        },
       })
     })
 
@@ -1730,22 +1730,22 @@ describe('compiler: parse', () => {
             start: {
               column: 14,
               line: 1,
-              offset: 13
+              offset: 13,
             },
             end: {
               column: 21,
               line: 1,
-              offset: 20
-            }
-          }
-        }
+              offset: 20,
+            },
+          },
+        },
       })
     })
 
     test('v-pre', () => {
       const ast = baseParse(
         `<div v-pre :id="foo"><Comp/>{{ bar }}</div>\n` +
-          `<div :id="foo"><Comp/>{{ bar }}</div>`
+          `<div :id="foo"><Comp/>{{ bar }}</div>`,
       )
 
       const divWithPre = ast.children[0] as ElementNode
@@ -1755,22 +1755,22 @@ describe('compiler: parse', () => {
           name: `:id`,
           value: {
             type: NodeTypes.TEXT,
-            content: `foo`
+            content: `foo`,
           },
           loc: {
             start: { line: 1, column: 12 },
-            end: { line: 1, column: 21 }
-          }
-        }
+            end: { line: 1, column: 21 },
+          },
+        },
       ])
       expect(divWithPre.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tagType: ElementTypes.ELEMENT,
-        tag: `Comp`
+        tag: `Comp`,
       })
       expect(divWithPre.children[1]).toMatchObject({
         type: NodeTypes.TEXT,
-        content: `{{ bar }}`
+        content: `{{ bar }}`,
       })
 
       // should not affect siblings after it
@@ -1782,37 +1782,37 @@ describe('compiler: parse', () => {
           arg: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             isStatic: true,
-            content: `id`
+            content: `id`,
           },
           exp: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             isStatic: false,
-            content: `foo`
+            content: `foo`,
           },
           loc: {
             start: {
               line: 2,
-              column: 6
+              column: 6,
             },
             end: {
               line: 2,
-              column: 15
-            }
-          }
-        }
+              column: 15,
+            },
+          },
+        },
       ])
       expect(divWithoutPre.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tagType: ElementTypes.COMPONENT,
-        tag: `Comp`
+        tag: `Comp`,
       })
       expect(divWithoutPre.children[1]).toMatchObject({
         type: NodeTypes.INTERPOLATION,
         content: {
           type: NodeTypes.SIMPLE_EXPRESSION,
           content: `bar`,
-          isStatic: false
-        }
+          isStatic: false,
+        },
       })
     })
 
@@ -1823,31 +1823,31 @@ describe('compiler: parse', () => {
           <span>{{ number </span>
           <span>}}</span>
         </div>
-        `
+        `,
       )
       expect((ast.children[0] as ElementNode).children).toMatchObject([
         {
           type: NodeTypes.ELEMENT,
-          children: [{ type: NodeTypes.TEXT, content: `{{ number ` }]
+          children: [{ type: NodeTypes.TEXT, content: `{{ number ` }],
         },
         {
           type: NodeTypes.ELEMENT,
-          children: [{ type: NodeTypes.TEXT, content: `}}` }]
-        }
+          children: [{ type: NodeTypes.TEXT, content: `}}` }],
+        },
       ])
 
       const ast2 = baseParse(`<div v-pre><span>{{ number </span></div>`)
       expect((ast2.children[0] as ElementNode).children).toMatchObject([
         {
           type: NodeTypes.ELEMENT,
-          children: [{ type: NodeTypes.TEXT, content: `{{ number ` }]
-        }
+          children: [{ type: NodeTypes.TEXT, content: `{{ number ` }],
+        },
       ])
     })
 
     test('self-closing v-pre', () => {
       const ast = baseParse(
-        `<div v-pre/>\n<div :id="foo"><Comp/>{{ bar }}</div>`
+        `<div v-pre/>\n<div :id="foo"><Comp/>{{ bar }}</div>`,
       )
       // should not affect siblings after it
       const divWithoutPre = ast.children[1] as ElementNode
@@ -1858,37 +1858,37 @@ describe('compiler: parse', () => {
           arg: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             isStatic: true,
-            content: `id`
+            content: `id`,
           },
           exp: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             isStatic: false,
-            content: `foo`
+            content: `foo`,
           },
           loc: {
             start: {
               line: 2,
-              column: 6
+              column: 6,
             },
             end: {
               line: 2,
-              column: 15
-            }
-          }
-        }
+              column: 15,
+            },
+          },
+        },
       ])
       expect(divWithoutPre.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tagType: ElementTypes.COMPONENT,
-        tag: `Comp`
+        tag: `Comp`,
       })
       expect(divWithoutPre.children[1]).toMatchObject({
         type: NodeTypes.INTERPOLATION,
         content: {
           type: NodeTypes.SIMPLE_EXPRESSION,
           content: `bar`,
-          isStatic: false
-        }
+          isStatic: false,
+        },
       })
     })
 
@@ -1903,8 +1903,8 @@ describe('compiler: parse', () => {
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 10, line: 1, column: 11 },
-          source: 'hello'
-        }
+          source: 'hello',
+        },
       })
     })
   })
@@ -1920,7 +1920,7 @@ describe('compiler: parse', () => {
     test('self closing multiple tag', () => {
       const ast = baseParse(
         `<div :class="{ some: condition }" />\n` +
-          `<p v-bind:style="{ color: 'red' }"/>`
+          `<p v-bind:style="{ color: 'red' }"/>`,
       )
 
       expect(ast).toMatchSnapshot()
@@ -1935,7 +1935,7 @@ describe('compiler: parse', () => {
         `<div :class="{ some: condition }">\n` +
           `  <p v-bind:style="{ color: 'red' }"/>\n` +
           `  <!-- a comment with <html> inside it -->\n` +
-          `</div>`
+          `</div>`,
       )
 
       expect(ast).toMatchSnapshot()
@@ -1943,14 +1943,14 @@ describe('compiler: parse', () => {
       expect(ast.children).toHaveLength(1)
       const el = ast.children[0] as any
       expect(el).toMatchObject({
-        tag: 'div'
+        tag: 'div',
       })
       expect(el.children).toHaveLength(2)
       expect(el.children[0]).toMatchObject({
-        tag: 'p'
+        tag: 'p',
       })
       expect(el.children[1]).toMatchObject({
-        type: NodeTypes.COMMENT
+        type: NodeTypes.COMMENT,
       })
     })
 
@@ -1961,7 +1961,7 @@ describe('compiler: parse', () => {
 
       const spy = vi.fn()
       const ast = baseParse(`<div>\n<span>\n</div>\n</span>`, {
-        onError: spy
+        onError: spy,
       })
 
       expect(spy.mock.calls).toMatchObject([
@@ -1972,10 +1972,10 @@ describe('compiler: parse', () => {
               start: {
                 offset: 6,
                 line: 2,
-                column: 1
-              }
-            }
-          }
+                column: 1,
+              },
+            },
+          },
         ],
         [
           {
@@ -1984,11 +1984,11 @@ describe('compiler: parse', () => {
               start: {
                 offset: 20,
                 line: 4,
-                column: 1
-              }
-            }
-          }
-        ]
+                column: 1,
+              },
+            },
+          },
+        ],
       ])
 
       expect(ast).toMatchSnapshot()
@@ -2000,7 +2000,7 @@ describe('compiler: parse', () => {
       const butSrc = ` but `
       const bazSrc = `{{ baz }}`
       const [foo, bar, but, baz] = baseParse(
-        fooSrc + barSrc + butSrc + bazSrc
+        fooSrc + barSrc + butSrc + bazSrc,
       ).children
 
       let offset = 0
@@ -2043,14 +2043,14 @@ describe('compiler: parse', () => {
       const ast = baseParse(
         `<template><Hello\n</template><script>console.log(1)</script>`,
         {
-          onError: spy
-        }
+          onError: spy,
+        },
       )
       //
       expect(ast.children.length).toBe(2)
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
-        tag: 'script'
+        tag: 'script',
       })
     })
 
@@ -2061,7 +2061,7 @@ describe('compiler: parse', () => {
         type: NodeTypes.DIRECTIVE,
         name: 'slot',
         exp: undefined,
-        arg: undefined
+        arg: undefined,
       })
     })
 
@@ -2084,10 +2084,10 @@ describe('compiler: parse', () => {
     test('should warn in non-browser build', () => {
       baseParse('&amp;&cups;', {
         decodeEntities: text => text.replace('&cups;', '\u222A\uFE00'),
-        onError: () => {} // Ignore errors
+        onError: () => {}, // Ignore errors
       })
       expect(
-        `decodeEntities option is passed but will be ignored`
+        `decodeEntities option is passed but will be ignored`,
       ).toHaveBeenWarned()
     })
   })
@@ -2096,7 +2096,7 @@ describe('compiler: parse', () => {
     const parse = (content: string, options?: ParserOptions) =>
       baseParse(content, {
         whitespace: 'condense',
-        ...options
+        ...options,
       })
 
     test('should remove whitespaces at start/end inside an element', () => {
@@ -2132,7 +2132,7 @@ describe('compiler: parse', () => {
       expect(ast.children[0].type).toBe(NodeTypes.INTERPOLATION)
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.TEXT,
-        content: ' '
+        content: ' ',
       })
       expect(ast.children[2].type).toBe(NodeTypes.INTERPOLATION)
     })
@@ -2143,7 +2143,7 @@ describe('compiler: parse', () => {
       expect(ast.children[0].type).toBe(NodeTypes.COMMENT)
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.TEXT,
-        content: ' '
+        content: ' ',
       })
       expect(ast.children[2].type).toBe(NodeTypes.INTERPOLATION)
     })
@@ -2156,7 +2156,7 @@ describe('compiler: parse', () => {
         NodeTypes.TEXT,
         NodeTypes.ELEMENT,
         NodeTypes.TEXT,
-        NodeTypes.ELEMENT
+        NodeTypes.ELEMENT,
       ])
     })
 
@@ -2167,7 +2167,7 @@ describe('compiler: parse', () => {
 
     test('should remove leading newline character immediately following the pre element start tag', () => {
       const ast = baseParse(`<pre>\n  foo  bar  </pre>`, {
-        isPreTag: tag => tag === 'pre'
+        isPreTag: tag => tag === 'pre',
       })
       expect(ast.children).toHaveLength(1)
       const preElement = ast.children[0] as ElementNode
@@ -2177,18 +2177,18 @@ describe('compiler: parse', () => {
 
     test('should NOT remove leading newline character immediately following child-tag of pre element', () => {
       const ast = baseParse(`<pre><span></span>\n  foo  bar  </pre>`, {
-        isPreTag: tag => tag === 'pre'
+        isPreTag: tag => tag === 'pre',
       })
       const preElement = ast.children[0] as ElementNode
       expect(preElement.children).toHaveLength(2)
       expect((preElement.children[1] as TextNode).content).toBe(
-        `\n  foo  bar  `
+        `\n  foo  bar  `,
       )
     })
 
     test('self-closing pre tag', () => {
       const ast = baseParse(`<pre/><span>\n  foo   bar</span>`, {
-        isPreTag: tag => tag === 'pre'
+        isPreTag: tag => tag === 'pre',
       })
       const elementAfterPre = ast.children[1] as ElementNode
       // should not affect the <span> and condense its whitespace inside
@@ -2197,7 +2197,7 @@ describe('compiler: parse', () => {
 
     test('should NOT condense whitespaces in RCDATA text mode', () => {
       const ast = baseParse(`<textarea>Text:\n   foo</textarea>`, {
-        parseMode: 'html'
+        parseMode: 'html',
       })
       const preElement = ast.children[0] as ElementNode
       expect(preElement.children).toHaveLength(1)
@@ -2209,7 +2209,7 @@ describe('compiler: parse', () => {
     const parse = (content: string, options?: ParserOptions) =>
       baseParse(content, {
         whitespace: 'preserve',
-        ...options
+        ...options,
       })
 
     test('should still remove whitespaces at start/end inside an element', () => {
@@ -2225,7 +2225,7 @@ describe('compiler: parse', () => {
         NodeTypes.TEXT,
         NodeTypes.ELEMENT,
         NodeTypes.TEXT,
-        NodeTypes.ELEMENT
+        NodeTypes.ELEMENT,
       ])
     })
 
@@ -2237,7 +2237,7 @@ describe('compiler: parse', () => {
         NodeTypes.TEXT,
         NodeTypes.COMMENT,
         NodeTypes.TEXT,
-        NodeTypes.ELEMENT
+        NodeTypes.ELEMENT,
       ])
     })
 
@@ -2249,7 +2249,7 @@ describe('compiler: parse', () => {
         NodeTypes.TEXT,
         NodeTypes.COMMENT,
         NodeTypes.TEXT,
-        NodeTypes.ELEMENT
+        NodeTypes.ELEMENT,
       ])
     })
 
@@ -2259,7 +2259,7 @@ describe('compiler: parse', () => {
       expect(ast.children[0].type).toBe(NodeTypes.INTERPOLATION)
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.TEXT,
-        content: ' '
+        content: ' ',
       })
       expect(ast.children[2].type).toBe(NodeTypes.INTERPOLATION)
     })
@@ -2272,7 +2272,7 @@ describe('compiler: parse', () => {
         NodeTypes.TEXT,
         NodeTypes.ELEMENT,
         NodeTypes.TEXT,
-        NodeTypes.ELEMENT
+        NodeTypes.ELEMENT,
       ])
     })
 
@@ -2286,54 +2286,54 @@ describe('compiler: parse', () => {
   describe('expression parsing', () => {
     test('interpolation', () => {
       const ast = baseParse(`{{ a + b }}`, { prefixIdentifiers: true })
-      // @ts-ignore
+      // @ts-expect-error
       expect((ast.children[0] as InterpolationNode).content.ast?.type).toBe(
-        'BinaryExpression'
+        'BinaryExpression',
       )
     })
 
     test('v-bind', () => {
       const ast = baseParse(`<div :[key+1]="foo()" />`, {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
       const dir = (ast.children[0] as ElementNode).props[0] as DirectiveNode
-      // @ts-ignore
+      // @ts-expect-error
       expect(dir.arg?.ast?.type).toBe('BinaryExpression')
-      // @ts-ignore
+      // @ts-expect-error
       expect(dir.exp?.ast?.type).toBe('CallExpression')
     })
 
     test('v-on multi statements', () => {
       const ast = baseParse(`<div @click="a++;b++" />`, {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
       const dir = (ast.children[0] as ElementNode).props[0] as DirectiveNode
-      // @ts-ignore
+      // @ts-expect-error
       expect(dir.exp?.ast?.type).toBe('Program')
       expect((dir.exp?.ast as Program).body).toMatchObject([
         { type: 'ExpressionStatement' },
-        { type: 'ExpressionStatement' }
+        { type: 'ExpressionStatement' },
       ])
     })
 
     test('v-slot', () => {
       const ast = baseParse(`<Comp #foo="{ a, b }" />`, {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
       const dir = (ast.children[0] as ElementNode).props[0] as DirectiveNode
-      // @ts-ignore
+      // @ts-expect-error
       expect(dir.exp?.ast?.type).toBe('ArrowFunctionExpression')
     })
 
     test('v-for', () => {
       const ast = baseParse(`<div v-for="({ a, b }, key, index) of a.b" />`, {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
       const dir = (ast.children[0] as ElementNode).props[0] as DirectiveNode
       const { source, value, key, index } = dir.forParseResult!
-      // @ts-ignore
+      // @ts-expect-error
       expect(source.ast?.type).toBe('MemberExpression')
-      // @ts-ignore
+      // @ts-expect-error
       expect(value?.ast?.type).toBe('ArrowFunctionExpression')
       expect(key?.ast).toBeNull() // simple ident
       expect(index?.ast).toBeNull() // simple ident
@@ -2382,14 +2382,14 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.CDATA_IN_HTML_CONTENT,
-              loc: { offset: 10, line: 1, column: 11 }
-            }
-          ]
+              loc: { offset: 10, line: 1, column: 11 },
+            },
+          ],
         },
         {
           code: '<template><svg><![CDATA[cdata]]></svg></template>',
-          errors: []
-        }
+          errors: [],
+        },
       ],
       DUPLICATE_ATTRIBUTE: [
         {
@@ -2397,10 +2397,10 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.DUPLICATE_ATTRIBUTE,
-              loc: { offset: 21, line: 1, column: 22 }
-            }
-          ]
-        }
+              loc: { offset: 21, line: 1, column: 22 },
+            },
+          ],
+        },
       ],
       // END_TAG_WITH_ATTRIBUTES: [
       //   {
@@ -2430,27 +2430,27 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.EOF_BEFORE_TAG_NAME,
-              loc: { offset: 11, line: 1, column: 12 }
+              loc: { offset: 11, line: 1, column: 12 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template></',
           errors: [
             {
               type: ErrorCodes.EOF_BEFORE_TAG_NAME,
-              loc: { offset: 12, line: 1, column: 13 }
+              loc: { offset: 12, line: 1, column: 13 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
-        }
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
+        },
       ],
       EOF_IN_CDATA: [
         {
@@ -2458,35 +2458,35 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.EOF_IN_CDATA,
-              loc: { offset: 29, line: 1, column: 30 }
+              loc: { offset: 29, line: 1, column: 30 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
+              loc: { offset: 10, line: 1, column: 11 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><svg><![CDATA[',
           errors: [
             {
               type: ErrorCodes.EOF_IN_CDATA,
-              loc: { offset: 24, line: 1, column: 25 }
+              loc: { offset: 24, line: 1, column: 25 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
+              loc: { offset: 10, line: 1, column: 11 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
-        }
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
+        },
       ],
       EOF_IN_COMMENT: [
         {
@@ -2494,27 +2494,27 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.EOF_IN_COMMENT,
-              loc: { offset: 21, line: 1, column: 22 }
+              loc: { offset: 21, line: 1, column: 22 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><!--',
           errors: [
             {
               type: ErrorCodes.EOF_IN_COMMENT,
-              loc: { offset: 14, line: 1, column: 15 }
+              loc: { offset: 14, line: 1, column: 15 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
-        }
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
+        },
         // // Bogus comments don't throw eof-in-comment error.
         // // https://html.spec.whatwg.org/multipage/parsing.html#bogus-comment-state
         // {
@@ -2587,52 +2587,52 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 14, line: 1, column: 15 }
+              loc: { offset: 14, line: 1, column: 15 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div ',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 15, line: 1, column: 16 }
+              loc: { offset: 15, line: 1, column: 16 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 17, line: 1, column: 18 }
+              loc: { offset: 17, line: 1, column: 18 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id ',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 18, line: 1, column: 19 }
+              loc: { offset: 18, line: 1, column: 19 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id =',
@@ -2643,143 +2643,143 @@ describe('compiler: parse', () => {
             // },
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 19, line: 1, column: 20 }
+              loc: { offset: 19, line: 1, column: 20 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: "<template><div id='abc",
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 22, line: 1, column: 23 }
+              loc: { offset: 22, line: 1, column: 23 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id="abc',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 22, line: 1, column: 23 }
+              loc: { offset: 22, line: 1, column: 23 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: "<template><div id='abc'",
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 23, line: 1, column: 24 }
+              loc: { offset: 23, line: 1, column: 24 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id="abc"',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 23, line: 1, column: 24 }
+              loc: { offset: 23, line: 1, column: 24 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id=abc',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 21, line: 1, column: 22 }
+              loc: { offset: 21, line: 1, column: 22 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: "<template><div id='abc'/",
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG,
-              loc: { offset: 23, line: 1, column: 24 }
+              loc: { offset: 23, line: 1, column: 24 },
             },
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 24, line: 1, column: 25 }
+              loc: { offset: 24, line: 1, column: 25 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id="abc"/',
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG,
-              loc: { offset: 23, line: 1, column: 24 }
+              loc: { offset: 23, line: 1, column: 24 },
             },
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 24, line: 1, column: 25 }
+              loc: { offset: 24, line: 1, column: 25 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<template><div id=abc /',
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG,
-              loc: { offset: 22, line: 1, column: 23 }
+              loc: { offset: 22, line: 1, column: 23 },
             },
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 23, line: 1, column: 24 }
+              loc: { offset: 23, line: 1, column: 24 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<div></div',
           errors: [
             {
               type: ErrorCodes.EOF_IN_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
+              loc: { offset: 10, line: 1, column: 11 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
-        }
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
+        },
       ],
       // INCORRECTLY_CLOSED_COMMENT: [
       //   {
@@ -2879,23 +2879,23 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.MISSING_ATTRIBUTE_VALUE,
-              loc: { offset: 18, line: 1, column: 19 }
-            }
-          ]
+              loc: { offset: 18, line: 1, column: 19 },
+            },
+          ],
         },
         {
           code: '<template><div id= ></div></template>',
           errors: [
             {
               type: ErrorCodes.MISSING_ATTRIBUTE_VALUE,
-              loc: { offset: 19, line: 1, column: 20 }
-            }
-          ]
+              loc: { offset: 19, line: 1, column: 20 },
+            },
+          ],
         },
         {
           code: '<template><div id= /></div></template>',
-          errors: []
-        }
+          errors: [],
+        },
       ],
       MISSING_END_TAG_NAME: [
         {
@@ -2903,10 +2903,10 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.MISSING_END_TAG_NAME,
-              loc: { offset: 12, line: 1, column: 13 }
-            }
-          ]
-        }
+              loc: { offset: 12, line: 1, column: 13 },
+            },
+          ],
+        },
       ],
       // MISSING_WHITESPACE_BETWEEN_ATTRIBUTES: [
       //   {
@@ -2981,28 +2981,28 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,
-              loc: { offset: 16, line: 1, column: 17 }
-            }
-          ]
+              loc: { offset: 16, line: 1, column: 17 },
+            },
+          ],
         },
         {
           code: "<template><div a'bc=''></div></template>",
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,
-              loc: { offset: 16, line: 1, column: 17 }
-            }
-          ]
+              loc: { offset: 16, line: 1, column: 17 },
+            },
+          ],
         },
         {
           code: "<template><div a<bc=''></div></template>",
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,
-              loc: { offset: 16, line: 1, column: 17 }
-            }
-          ]
-        }
+              loc: { offset: 16, line: 1, column: 17 },
+            },
+          ],
+        },
       ],
       UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE: [
         {
@@ -3010,46 +3010,46 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
-              loc: { offset: 22, line: 1, column: 23 }
-            }
-          ]
+              loc: { offset: 22, line: 1, column: 23 },
+            },
+          ],
         },
         {
           code: "<template><div foo=bar'></div></template>",
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
-              loc: { offset: 22, line: 1, column: 23 }
-            }
-          ]
+              loc: { offset: 22, line: 1, column: 23 },
+            },
+          ],
         },
         {
           code: '<template><div foo=bar<div></div></template>',
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
-              loc: { offset: 22, line: 1, column: 23 }
-            }
-          ]
+              loc: { offset: 22, line: 1, column: 23 },
+            },
+          ],
         },
         {
           code: '<template><div foo=bar=baz></div></template>',
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
-              loc: { offset: 22, line: 1, column: 23 }
-            }
-          ]
+              loc: { offset: 22, line: 1, column: 23 },
+            },
+          ],
         },
         {
           code: '<template><div foo=bar`></div></template>',
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
-              loc: { offset: 22, line: 1, column: 23 }
-            }
-          ]
-        }
+              loc: { offset: 22, line: 1, column: 23 },
+            },
+          ],
+        },
       ],
       UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME: [
         {
@@ -3057,19 +3057,19 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,
-              loc: { offset: 15, line: 1, column: 16 }
-            }
-          ]
+              loc: { offset: 15, line: 1, column: 16 },
+            },
+          ],
         },
         {
           code: '<template><div =></div></template>',
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,
-              loc: { offset: 15, line: 1, column: 16 }
-            }
-          ]
-        }
+              loc: { offset: 15, line: 1, column: 16 },
+            },
+          ],
+        },
       ],
       UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME: [
         {
@@ -3077,10 +3077,10 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,
-              loc: { offset: 11, line: 1, column: 12 }
-            }
-          ]
-        }
+              loc: { offset: 11, line: 1, column: 12 },
+            },
+          ],
+        },
       ],
       UNEXPECTED_SOLIDUS_IN_TAG: [
         {
@@ -3088,10 +3088,10 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.UNEXPECTED_SOLIDUS_IN_TAG,
-              loc: { offset: 16, line: 1, column: 17 }
-            }
-          ]
-        }
+              loc: { offset: 16, line: 1, column: 17 },
+            },
+          ],
+        },
       ],
       X_INVALID_END_TAG: [
         {
@@ -3099,52 +3099,52 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.X_INVALID_END_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
-            }
-          ]
+              loc: { offset: 10, line: 1, column: 11 },
+            },
+          ],
         },
         {
           code: '<template></div></div></template>',
           errors: [
             {
               type: ErrorCodes.X_INVALID_END_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
+              loc: { offset: 10, line: 1, column: 11 },
             },
             {
               type: ErrorCodes.X_INVALID_END_TAG,
-              loc: { offset: 16, line: 1, column: 17 }
-            }
-          ]
+              loc: { offset: 16, line: 1, column: 17 },
+            },
+          ],
         },
         {
           code: '<template>a </ b</template>',
           errors: [
             {
               type: ErrorCodes.X_INVALID_END_TAG,
-              loc: { offset: 12, line: 1, column: 13 }
+              loc: { offset: 12, line: 1, column: 13 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: "<template>{{'</div>'}}</template>",
-          errors: []
+          errors: [],
         },
         {
           code: '<textarea></div></textarea>',
-          errors: []
+          errors: [],
         },
         {
           code: '<svg><![CDATA[</div>]]></svg>',
-          errors: []
+          errors: [],
         },
         {
           code: '<svg><!--</div>--></svg>',
-          errors: []
-        }
+          errors: [],
+        },
       ],
       X_MISSING_END_TAG: [
         {
@@ -3152,23 +3152,23 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
-            }
-          ]
+              loc: { offset: 10, line: 1, column: 11 },
+            },
+          ],
         },
         {
           code: '<template><div>',
           errors: [
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 10, line: 1, column: 11 }
+              loc: { offset: 10, line: 1, column: 11 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
-        }
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
+        },
       ],
       X_MISSING_INTERPOLATION_END: [
         {
@@ -3176,36 +3176,36 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.X_MISSING_INTERPOLATION_END,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '{{',
           errors: [
             {
               type: ErrorCodes.X_MISSING_INTERPOLATION_END,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '<div>{{ foo</div>',
           errors: [
             {
               type: ErrorCodes.X_MISSING_INTERPOLATION_END,
-              loc: { offset: 5, line: 1, column: 6 }
+              loc: { offset: 5, line: 1, column: 6 },
             },
             {
               type: ErrorCodes.X_MISSING_END_TAG,
-              loc: { offset: 0, line: 1, column: 1 }
-            }
-          ]
+              loc: { offset: 0, line: 1, column: 1 },
+            },
+          ],
         },
         {
           code: '{{}}',
-          errors: []
-        }
+          errors: [],
+        },
       ],
       X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END: [
         {
@@ -3213,11 +3213,11 @@ describe('compiler: parse', () => {
           errors: [
             {
               type: ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END,
-              loc: { offset: 15, line: 1, column: 16 }
-            }
-          ]
-        }
-      ]
+              loc: { offset: 15, line: 1, column: 16 },
+            },
+          ],
+        },
+      ],
     }
 
     for (const key of Object.keys(patterns)) {
@@ -3226,7 +3226,7 @@ describe('compiler: parse', () => {
           test(
             code.replace(
               /[\r\n]/g,
-              c => `\\x0${c.codePointAt(0)!.toString(16)};`
+              c => `\\x0${c.codePointAt(0)!.toString(16)};`,
             ),
             () => {
               const spy = vi.fn()
@@ -3235,17 +3235,17 @@ describe('compiler: parse', () => {
                 getNamespace: tag =>
                   tag === 'svg' ? Namespaces.SVG : Namespaces.HTML,
                 ...options,
-                onError: spy
+                onError: spy,
               })
 
               expect(
                 spy.mock.calls.map(([err]) => ({
                   type: err.code,
-                  loc: err.loc.start
-                }))
+                  loc: err.loc.start,
+                })),
               ).toMatchObject(errors)
               expect(ast).toMatchSnapshot()
-            }
+            },
           )
         }
       })
index 5f7ea0d2e6ad4ade827960132d879d28763acd27..c7a21df7a7879dad57701c17fbbf0333e771d644 100644 (file)
@@ -1,5 +1,5 @@
 import { baseCompile } from '../src/compile'
-import { PUSH_SCOPE_ID, POP_SCOPE_ID } from '../src/runtimeHelpers'
+import { POP_SCOPE_ID, PUSH_SCOPE_ID } from '../src/runtimeHelpers'
 import { PatchFlags } from '@vue/shared'
 import { genFlagText } from './testUtils'
 
@@ -18,7 +18,7 @@ describe('scopeId compiler support', () => {
   test('should wrap default slot', () => {
     const { code } = baseCompile(`<Child><div/></Child>`, {
       mode: 'module',
-      scopeId: 'test'
+      scopeId: 'test',
     })
     expect(code).toMatch(`default: _withCtx(() => [`)
     expect(code).toMatchSnapshot()
@@ -33,8 +33,8 @@ describe('scopeId compiler support', () => {
       `,
       {
         mode: 'module',
-        scopeId: 'test'
-      }
+        scopeId: 'test',
+      },
     )
     expect(code).toMatch(`foo: _withCtx(({ msg }) => [`)
     expect(code).toMatch(`bar: _withCtx(() => [`)
@@ -50,8 +50,8 @@ describe('scopeId compiler support', () => {
       `,
       {
         mode: 'module',
-        scopeId: 'test'
-      }
+        scopeId: 'test',
+      },
     )
     expect(code).toMatch(/name: "foo",\s+fn: _withCtx\(/)
     expect(code).toMatch(/name: i,\s+fn: _withCtx\(/)
@@ -64,8 +64,8 @@ describe('scopeId compiler support', () => {
       {
         mode: 'module',
         scopeId: 'test',
-        hoistStatic: true
-      }
+        hoistStatic: true,
+      },
     )
     expect(ast.helpers).toContain(PUSH_SCOPE_ID)
     expect(ast.helpers).toContain(POP_SCOPE_ID)
@@ -73,11 +73,11 @@ describe('scopeId compiler support', () => {
     ;[
       `const _withScopeId = n => (_pushScopeId("test"),n=n(),_popScopeId(),n)`,
       `const _hoisted_1 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/_createElementVNode("div", null, "hello", ${genFlagText(
-        PatchFlags.HOISTED
+        PatchFlags.HOISTED,
       )}))`,
       `const _hoisted_2 = /*#__PURE__*/ _withScopeId(() => /*#__PURE__*/_createElementVNode("div", null, "world", ${genFlagText(
-        PatchFlags.HOISTED
-      )}))`
+        PatchFlags.HOISTED,
+      )}))`,
     ].forEach(c => expect(code).toMatch(c))
     expect(code).toMatchSnapshot()
   })
index 595a0a783f51320054ff1c522ab21a82da44c516..9618a482add64bc3757629953c5076323993cc33 100644 (file)
@@ -1,17 +1,17 @@
 import {
+  type ElementNode,
+  ElementTypes,
+  Namespaces,
   NodeTypes,
-  ElementNode,
+  type VNodeCall,
   locStub,
-  Namespaces,
-  ElementTypes,
-  VNodeCall
 } from '../src'
 import {
-  isString,
-  PatchFlags,
   PatchFlagNames,
+  type PatchFlags,
+  type ShapeFlags,
   isArray,
-  ShapeFlags
+  isString,
 } from '@vue/shared'
 
 const leadingBracketRE = /^\[/
@@ -30,16 +30,16 @@ export function createObjectMatcher(obj: Record<string, any>) {
       key: {
         type: NodeTypes.SIMPLE_EXPRESSION,
         content: key.replace(bracketsRE, ''),
-        isStatic: !leadingBracketRE.test(key)
+        isStatic: !leadingBracketRE.test(key),
       },
       value: isString(obj[key])
         ? {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: obj[key].replace(bracketsRE, ''),
-            isStatic: !leadingBracketRE.test(obj[key])
+            isStatic: !leadingBracketRE.test(obj[key]),
           }
-        : obj[key]
-    }))
+        : obj[key],
+    })),
   }
 }
 
@@ -48,7 +48,7 @@ export function createElementWithCodegen(
   props?: VNodeCall['props'],
   children?: VNodeCall['children'],
   patchFlag?: VNodeCall['patchFlag'],
-  dynamicProps?: VNodeCall['dynamicProps']
+  dynamicProps?: VNodeCall['dynamicProps'],
 ): ElementNode {
   return {
     type: NodeTypes.ELEMENT,
@@ -69,15 +69,15 @@ export function createElementWithCodegen(
       isBlock: false,
       disableTracking: false,
       isComponent: false,
-      loc: locStub
-    }
+      loc: locStub,
+    },
   }
 }
 
 type Flags = PatchFlags | ShapeFlags
 export function genFlagText(
   flag: Flags | Flags[],
-  names: { [k: number]: string } = PatchFlagNames
+  names: { [k: number]: string } = PatchFlagNames,
 ) {
   if (isArray(flag)) {
     let f = 0
index 33b80ff9043c9c0cbced3e4d1bd59dbe4900c4dd..a56be51bc5c906b5fc0797ed3c7762d9f6670dd1 100644 (file)
@@ -1,18 +1,18 @@
 import { baseParse } from '../src/parser'
-import { transform, NodeTransform } from '../src/transform'
+import { type NodeTransform, transform } from '../src/transform'
 import {
-  ElementNode,
+  type DirectiveNode,
+  type ElementNode,
+  type ExpressionNode,
   NodeTypes,
-  DirectiveNode,
-  ExpressionNode,
-  VNodeCall
+  type VNodeCall,
 } from '../src/ast'
 import { ErrorCodes, createCompilerError } from '../src/errors'
 import {
-  TO_DISPLAY_STRING,
+  CREATE_COMMENT,
   FRAGMENT,
   RENDER_SLOT,
-  CREATE_COMMENT
+  TO_DISPLAY_STRING,
 } from '../src/runtimeHelpers'
 import { transformIf } from '../src/transforms/vIf'
 import { transformFor } from '../src/transforms/vFor'
@@ -34,7 +34,7 @@ describe('compiler: transform', () => {
     }
 
     transform(ast, {
-      nodeTransforms: [plugin]
+      nodeTransforms: [plugin],
     })
 
     const div = ast.children[0] as ElementNode
@@ -43,29 +43,29 @@ describe('compiler: transform', () => {
       ast,
       {
         parent: null,
-        currentNode: ast
-      }
+        currentNode: ast,
+      },
     ])
     expect(calls[1]).toMatchObject([
       div,
       {
         parent: ast,
-        currentNode: div
-      }
+        currentNode: div,
+      },
     ])
     expect(calls[2]).toMatchObject([
       div.children[0],
       {
         parent: div,
-        currentNode: div.children[0]
-      }
+        currentNode: div.children[0],
+      },
     ])
     expect(calls[3]).toMatchObject([
       div.children[1],
       {
         parent: div,
-        currentNode: div.children[1]
-      }
+        currentNode: div.children[1],
+      },
     ])
   })
 
@@ -81,16 +81,16 @@ describe('compiler: transform', () => {
               {
                 type: NodeTypes.TEXT,
                 content: 'hello',
-                isEmpty: false
-              }
-            ]
-          })
+                isEmpty: false,
+              },
+            ],
+          }),
         )
       }
     }
     const spy = vi.fn(plugin)
     transform(ast, {
-      nodeTransforms: [spy]
+      nodeTransforms: [spy],
     })
 
     expect(ast.children.length).toBe(2)
@@ -115,7 +115,7 @@ describe('compiler: transform', () => {
     }
     const spy = vi.fn(plugin)
     transform(ast, {
-      nodeTransforms: [spy]
+      nodeTransforms: [spy],
     })
 
     expect(ast.children.length).toBe(2)
@@ -143,7 +143,7 @@ describe('compiler: transform', () => {
     }
     const spy = vi.fn(plugin)
     transform(ast, {
-      nodeTransforms: [spy]
+      nodeTransforms: [spy],
     })
 
     expect(ast.children.length).toBe(1)
@@ -170,7 +170,7 @@ describe('compiler: transform', () => {
     }
     const spy = vi.fn(plugin)
     transform(ast, {
-      nodeTransforms: [spy]
+      nodeTransforms: [spy],
     })
 
     expect(ast.children.length).toBe(1)
@@ -194,7 +194,7 @@ describe('compiler: transform', () => {
       }
     }
     transform(ast, {
-      nodeTransforms: [mock]
+      nodeTransforms: [mock],
     })
     expect(ast.hoists).toMatchObject(hoisted)
     expect((ast as any).children[0].props[0].exp.content).toBe(`_hoisted_1`)
@@ -211,13 +211,13 @@ describe('compiler: transform', () => {
 
     transform(ast, {
       filename: '/the/fileName.vue',
-      nodeTransforms: [plugin]
+      nodeTransforms: [plugin],
     })
 
     expect(calls.length).toBe(2)
     expect(calls[1]).toMatchObject({
       filename: '/the/fileName.vue',
-      selfName: 'FileName'
+      selfName: 'FileName',
     })
   })
 
@@ -226,19 +226,19 @@ describe('compiler: transform', () => {
     const loc = ast.children[0].loc
     const plugin: NodeTransform = (node, context) => {
       context.onError(
-        createCompilerError(ErrorCodes.X_INVALID_END_TAG, node.loc)
+        createCompilerError(ErrorCodes.X_INVALID_END_TAG, node.loc),
       )
     }
     const spy = vi.fn()
     transform(ast, {
       nodeTransforms: [plugin],
-      onError: spy
+      onError: spy,
     })
     expect(spy.mock.calls[0]).toMatchObject([
       {
         code: ErrorCodes.X_INVALID_END_TAG,
-        loc
-      }
+        loc,
+      },
     ])
   })
 
@@ -263,8 +263,8 @@ describe('compiler: transform', () => {
           transformFor,
           transformText,
           transformSlotOutlet,
-          transformElement
-        ]
+          transformElement,
+        ],
       })
       return ast
     }
@@ -273,7 +273,7 @@ describe('compiler: transform', () => {
       tag: VNodeCall['tag'],
       props?: VNodeCall['props'],
       children?: VNodeCall['children'],
-      patchFlag?: VNodeCall['patchFlag']
+      patchFlag?: VNodeCall['patchFlag'],
     ) {
       return {
         type: NodeTypes.VNODE_CALL,
@@ -281,7 +281,7 @@ describe('compiler: transform', () => {
         tag,
         props,
         children,
-        patchFlag
+        patchFlag,
       }
     }
 
@@ -295,8 +295,8 @@ describe('compiler: transform', () => {
       expect(ast.codegenNode).toMatchObject({
         codegenNode: {
           type: NodeTypes.JS_CALL_EXPRESSION,
-          callee: RENDER_SLOT
-        }
+          callee: RENDER_SLOT,
+        },
       })
     })
 
@@ -308,14 +308,14 @@ describe('compiler: transform', () => {
     test('root v-if', () => {
       const ast = transformWithCodegen(`<div v-if="ok" />`)
       expect(ast.codegenNode).toMatchObject({
-        type: NodeTypes.IF
+        type: NodeTypes.IF,
       })
     })
 
     test('root v-for', () => {
       const ast = transformWithCodegen(`<div v-for="i in list" />`)
       expect(ast.codegenNode).toMatchObject({
-        type: NodeTypes.FOR
+        type: NodeTypes.FOR,
       })
     })
 
@@ -323,28 +323,28 @@ describe('compiler: transform', () => {
       const ast = transformWithCodegen(`<div v-foo/>`)
       expect(ast.codegenNode).toMatchObject({
         type: NodeTypes.VNODE_CALL,
-        directives: { type: NodeTypes.JS_ARRAY_EXPRESSION }
+        directives: { type: NodeTypes.JS_ARRAY_EXPRESSION },
       })
     })
 
     test('single text', () => {
       const ast = transformWithCodegen(`hello`)
       expect(ast.codegenNode).toMatchObject({
-        type: NodeTypes.TEXT
+        type: NodeTypes.TEXT,
       })
     })
 
     test('single interpolation', () => {
       const ast = transformWithCodegen(`{{ foo }}`)
       expect(ast.codegenNode).toMatchObject({
-        type: NodeTypes.INTERPOLATION
+        type: NodeTypes.INTERPOLATION,
       })
     })
 
     test('single CompoundExpression', () => {
       const ast = transformWithCodegen(`{{ foo }} bar baz`)
       expect(ast.codegenNode).toMatchObject({
-        type: NodeTypes.COMPOUND_EXPRESSION
+        type: NodeTypes.COMPOUND_EXPRESSION,
       })
     })
 
@@ -356,10 +356,10 @@ describe('compiler: transform', () => {
           undefined,
           [
             { type: NodeTypes.ELEMENT, tag: `div` },
-            { type: NodeTypes.ELEMENT, tag: `div` }
+            { type: NodeTypes.ELEMENT, tag: `div` },
           ] as any,
-          genFlagText(PatchFlags.STABLE_FRAGMENT)
-        )
+          genFlagText(PatchFlags.STABLE_FRAGMENT),
+        ),
       )
     })
 
@@ -372,13 +372,13 @@ describe('compiler: transform', () => {
           [
             { type: NodeTypes.COMMENT },
             { type: NodeTypes.ELEMENT, tag: `div` },
-            { type: NodeTypes.COMMENT }
+            { type: NodeTypes.COMMENT },
           ] as any,
           genFlagText([
             PatchFlags.STABLE_FRAGMENT,
-            PatchFlags.DEV_ROOT_FRAGMENT
-          ])
-        )
+            PatchFlags.DEV_ROOT_FRAGMENT,
+          ]),
+        ),
       )
     })
   })
index 49ad7ad8982f5f7f28fe37a91b65f96fd078c842..d6c46b52eb3a3cb04f784f62cb4d329d09e4f578 100644 (file)
@@ -1,19 +1,19 @@
 import {
-  baseParse as parse,
-  transform,
+  type CompilerOptions,
+  ConstantTypes,
+  type ElementNode,
+  type ForNode,
+  type IfNode,
   NodeTypes,
+  type VNodeCall,
   generate,
-  CompilerOptions,
-  VNodeCall,
-  IfNode,
-  ElementNode,
-  ForNode,
-  ConstantTypes
+  baseParse as parse,
+  transform,
 } from '../../src'
 import {
   FRAGMENT,
+  NORMALIZE_CLASS,
   RENDER_LIST,
-  NORMALIZE_CLASS
 } from '../../src/runtimeHelpers'
 import { transformElement } from '../../src/transforms/transformElement'
 import { transformExpression } from '../../src/transforms/transformExpression'
@@ -31,9 +31,9 @@ const hoistedChildrenArrayMatcher = (startIndex = 1, length = 1) => ({
     type: NodeTypes.ELEMENT,
     codegenNode: {
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `_hoisted_${startIndex + i}`
-    }
-  }))
+      content: `_hoisted_${startIndex + i}`,
+    },
+  })),
 })
 
 function transformWithHoist(template: string, options: CompilerOptions = {}) {
@@ -45,17 +45,17 @@ function transformWithHoist(template: string, options: CompilerOptions = {}) {
       transformFor,
       ...(options.prefixIdentifiers ? [transformExpression] : []),
       transformElement,
-      transformText
+      transformText,
     ],
     directiveTransforms: {
       on: transformOn,
-      bind: transformBind
+      bind: transformBind,
     },
-    ...options
+    ...options,
   })
   expect(ast.codegenNode).toMatchObject({
     type: NodeTypes.VNODE_CALL,
-    isBlock: true
+    isBlock: true,
   })
   return ast
 }
@@ -67,14 +67,14 @@ describe('compiler: hoistStatic transform', () => {
     const root = transformWithHoist(`<div/>`)
     expect(root.hoists.length).toBe(0)
     expect(root.codegenNode).toMatchObject({
-      tag: `"div"`
+      tag: `"div"`,
     })
     expect(generate(root).code).toMatchSnapshot()
   })
 
   test('hoist simple element', () => {
     const root = transformWithHoist(
-      `<div><span class="inline">hello</span></div>`
+      `<div><span class="inline">hello</span></div>`,
     )
     expect(root.hoists).toMatchObject([
       {
@@ -83,15 +83,15 @@ describe('compiler: hoistStatic transform', () => {
         props: createObjectMatcher({ class: 'inline' }),
         children: {
           type: NodeTypes.TEXT,
-          content: `hello`
-        }
+          content: `hello`,
+        },
       },
-      hoistedChildrenArrayMatcher()
+      hoistedChildrenArrayMatcher(),
     ])
     expect(root.codegenNode).toMatchObject({
       tag: `"div"`,
       props: undefined,
-      children: { content: `_hoisted_2` }
+      children: { content: `_hoisted_2` },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -105,13 +105,13 @@ describe('compiler: hoistStatic transform', () => {
         props: undefined,
         children: [
           { type: NodeTypes.ELEMENT, tag: `span` },
-          { type: NodeTypes.ELEMENT, tag: `span` }
-        ]
+          { type: NodeTypes.ELEMENT, tag: `span` },
+        ],
       },
-      hoistedChildrenArrayMatcher()
+      hoistedChildrenArrayMatcher(),
     ])
     expect((root.codegenNode as VNodeCall).children).toMatchObject({
-      content: '_hoisted_2'
+      content: '_hoisted_2',
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -123,12 +123,12 @@ describe('compiler: hoistStatic transform', () => {
         type: NodeTypes.VNODE_CALL,
         tag: `"div"`,
         props: undefined,
-        children: [{ type: NodeTypes.COMMENT, content: `comment` }]
+        children: [{ type: NodeTypes.COMMENT, content: `comment` }],
       },
-      hoistedChildrenArrayMatcher()
+      hoistedChildrenArrayMatcher(),
     ])
     expect((root.codegenNode as VNodeCall).children).toMatchObject({
-      content: `_hoisted_2`
+      content: `_hoisted_2`,
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -138,16 +138,16 @@ describe('compiler: hoistStatic transform', () => {
     expect(root.hoists).toMatchObject([
       {
         type: NodeTypes.VNODE_CALL,
-        tag: `"span"`
+        tag: `"span"`,
       },
       {
         type: NodeTypes.VNODE_CALL,
-        tag: `"div"`
+        tag: `"div"`,
       },
-      hoistedChildrenArrayMatcher(1, 2)
+      hoistedChildrenArrayMatcher(1, 2),
     ])
     expect((root.codegenNode as VNodeCall).children).toMatchObject({
-      content: '_hoisted_3'
+      content: '_hoisted_3',
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -160,9 +160,9 @@ describe('compiler: hoistStatic transform', () => {
         type: NodeTypes.ELEMENT,
         codegenNode: {
           type: NodeTypes.VNODE_CALL,
-          tag: `_component_Comp`
-        }
-      }
+          tag: `_component_Comp`,
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -177,17 +177,17 @@ describe('compiler: hoistStatic transform', () => {
           type: NodeTypes.VNODE_CALL,
           tag: `"div"`,
           props: createObjectMatcher({
-            id: `[foo]`
+            id: `[foo]`,
           }),
           children: undefined,
           patchFlag: genFlagText(PatchFlags.PROPS),
           dynamicProps: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `_hoisted_1`,
-            isStatic: false
-          }
-        }
-      }
+            isStatic: false,
+          },
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -199,14 +199,14 @@ describe('compiler: hoistStatic transform', () => {
       {
         type: NodeTypes.VNODE_CALL,
         tag: `"div"`,
-        props: createObjectMatcher({ key: 'foo' })
+        props: createObjectMatcher({ key: 'foo' }),
       },
-      hoistedChildrenArrayMatcher()
+      hoistedChildrenArrayMatcher(),
     ])
     expect(root.codegenNode).toMatchObject({
       tag: `"div"`,
       props: undefined,
-      children: { content: `_hoisted_2` }
+      children: { content: `_hoisted_2` },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -221,10 +221,10 @@ describe('compiler: hoistStatic transform', () => {
           type: NodeTypes.VNODE_CALL,
           tag: `"div"`,
           props: createObjectMatcher({
-            key: `[foo]`
-          })
-        }
-      }
+            key: `[foo]`,
+          }),
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -239,12 +239,12 @@ describe('compiler: hoistStatic transform', () => {
           type: NodeTypes.VNODE_CALL,
           tag: `"div"`,
           props: createObjectMatcher({
-            ref: `[foo]`
+            ref: `[foo]`,
           }),
           children: undefined,
-          patchFlag: genFlagText(PatchFlags.NEED_PATCH)
-        }
-      }
+          patchFlag: genFlagText(PatchFlags.NEED_PATCH),
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -260,22 +260,22 @@ describe('compiler: hoistStatic transform', () => {
           tag: `"div"`,
           props: {
             type: NodeTypes.SIMPLE_EXPRESSION,
-            content: `_hoisted_1`
+            content: `_hoisted_1`,
           },
           children: undefined,
           patchFlag: genFlagText(PatchFlags.NEED_PATCH),
           directives: {
-            type: NodeTypes.JS_ARRAY_EXPRESSION
-          }
-        }
-      }
+            type: NodeTypes.JS_ARRAY_EXPRESSION,
+          },
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
 
   test('hoist static props for elements with dynamic text children', () => {
     const root = transformWithHoist(
-      `<div><div id="foo">{{ hello }}</div></div>`
+      `<div><div id="foo">{{ hello }}</div></div>`,
     )
     expect(root.hoists).toMatchObject([createObjectMatcher({ id: 'foo' })])
     expect((root.codegenNode as VNodeCall).children).toMatchObject([
@@ -286,9 +286,9 @@ describe('compiler: hoistStatic transform', () => {
           tag: `"div"`,
           props: { content: `_hoisted_1` },
           children: { type: NodeTypes.INTERPOLATION },
-          patchFlag: genFlagText(PatchFlags.TEXT)
-        }
-      }
+          patchFlag: genFlagText(PatchFlags.TEXT),
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -303,30 +303,30 @@ describe('compiler: hoistStatic transform', () => {
           type: NodeTypes.VNODE_CALL,
           tag: `"div"`,
           props: { content: `_hoisted_1` },
-          children: [{ type: NodeTypes.ELEMENT, tag: `Comp` }]
-        }
-      }
+          children: [{ type: NodeTypes.ELEMENT, tag: `Comp` }],
+        },
+      },
     ])
     expect(generate(root).code).toMatchSnapshot()
   })
 
   test('should hoist v-if props/children if static', () => {
     const root = transformWithHoist(
-      `<div><div v-if="ok" id="foo"><span/></div></div>`
+      `<div><div v-if="ok" id="foo"><span/></div></div>`,
     )
     expect(root.hoists).toMatchObject([
       createObjectMatcher({
         key: `[0]`, // key injected by v-if branch
-        id: 'foo'
+        id: 'foo',
       }),
       {
         type: NodeTypes.VNODE_CALL,
-        tag: `"span"`
+        tag: `"span"`,
       },
-      hoistedChildrenArrayMatcher(2)
+      hoistedChildrenArrayMatcher(2),
     ])
     expect(
-      ((root.children[0] as ElementNode).children[0] as IfNode).codegenNode
+      ((root.children[0] as ElementNode).children[0] as IfNode).codegenNode,
     ).toMatchObject({
       type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
       consequent: {
@@ -334,25 +334,25 @@ describe('compiler: hoistStatic transform', () => {
         type: NodeTypes.VNODE_CALL,
         tag: `"div"`,
         props: { content: `_hoisted_1` },
-        children: { content: `_hoisted_3` }
-      }
+        children: { content: `_hoisted_3` },
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
 
   test('should hoist v-for children if static', () => {
     const root = transformWithHoist(
-      `<div><div v-for="i in list" id="foo"><span/></div></div>`
+      `<div><div v-for="i in list" id="foo"><span/></div></div>`,
     )
     expect(root.hoists).toMatchObject([
       createObjectMatcher({
-        id: 'foo'
+        id: 'foo',
       }),
       {
         type: NodeTypes.VNODE_CALL,
-        tag: `"span"`
+        tag: `"span"`,
       },
-      hoistedChildrenArrayMatcher(2)
+      hoistedChildrenArrayMatcher(2),
     ])
     const forBlockCodegen = (
       (root.children[0] as ElementNode).children[0] as ForNode
@@ -363,16 +363,16 @@ describe('compiler: hoistStatic transform', () => {
       props: undefined,
       children: {
         type: NodeTypes.JS_CALL_EXPRESSION,
-        callee: RENDER_LIST
+        callee: RENDER_LIST,
       },
-      patchFlag: genFlagText(PatchFlags.UNKEYED_FRAGMENT)
+      patchFlag: genFlagText(PatchFlags.UNKEYED_FRAGMENT),
     })
     const innerBlockCodegen = forBlockCodegen!.children.arguments[1]
     expect(innerBlockCodegen.returns).toMatchObject({
       type: NodeTypes.VNODE_CALL,
       tag: `"div"`,
       props: { content: `_hoisted_1` },
-      children: { content: `_hoisted_3` }
+      children: { content: `_hoisted_3` },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -382,8 +382,8 @@ describe('compiler: hoistStatic transform', () => {
       const root = transformWithHoist(
         `<div><span>foo {{ 1 }} {{ true }}</span></div>`,
         {
-          prefixIdentifiers: true
-        }
+          prefixIdentifiers: true,
+        },
       )
       expect(root.hoists).toMatchObject([
         {
@@ -391,18 +391,18 @@ describe('compiler: hoistStatic transform', () => {
           tag: `"span"`,
           props: undefined,
           children: {
-            type: NodeTypes.COMPOUND_EXPRESSION
-          }
+            type: NodeTypes.COMPOUND_EXPRESSION,
+          },
         },
-        hoistedChildrenArrayMatcher()
+        hoistedChildrenArrayMatcher(),
       ])
       expect(root.codegenNode).toMatchObject({
         tag: `"div"`,
         props: undefined,
         children: {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `_hoisted_2`
-        }
+          content: `_hoisted_2`,
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -411,8 +411,8 @@ describe('compiler: hoistStatic transform', () => {
       const root = transformWithHoist(
         `<div><span :foo="0">{{ 1 }}</span></div>`,
         {
-          prefixIdentifiers: true
-        }
+          prefixIdentifiers: true,
+        },
       )
 
       expect(root.hoists).toMatchObject([
@@ -425,19 +425,19 @@ describe('compiler: hoistStatic transform', () => {
             content: {
               content: `1`,
               isStatic: false,
-              constType: ConstantTypes.CAN_STRINGIFY
-            }
-          }
+              constType: ConstantTypes.CAN_STRINGIFY,
+            },
+          },
         },
-        hoistedChildrenArrayMatcher()
+        hoistedChildrenArrayMatcher(),
       ])
       expect(root.codegenNode).toMatchObject({
         tag: `"div"`,
         props: undefined,
         children: {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `_hoisted_2`
-        }
+          content: `_hoisted_2`,
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -446,8 +446,8 @@ describe('compiler: hoistStatic transform', () => {
       const root = transformWithHoist(
         `<div><span :class="{ foo: true }">{{ bar }}</span></div>`,
         {
-          prefixIdentifiers: true
-        }
+          prefixIdentifiers: true,
+        },
       )
 
       expect(root.hoists).toMatchObject([
@@ -458,7 +458,7 @@ describe('compiler: hoistStatic transform', () => {
               key: {
                 content: `class`,
                 isStatic: true,
-                constType: ConstantTypes.CAN_STRINGIFY
+                constType: ConstantTypes.CAN_STRINGIFY,
               },
               value: {
                 type: NodeTypes.JS_CALL_EXPRESSION,
@@ -467,13 +467,13 @@ describe('compiler: hoistStatic transform', () => {
                   {
                     content: `{ foo: true }`,
                     isStatic: false,
-                    constType: ConstantTypes.CAN_STRINGIFY
-                  }
-                ]
-              }
-            }
-          ]
-        }
+                    constType: ConstantTypes.CAN_STRINGIFY,
+                  },
+                ],
+              },
+            },
+          ],
+        },
       ])
       expect(root.codegenNode).toMatchObject({
         tag: `"div"`,
@@ -486,20 +486,20 @@ describe('compiler: hoistStatic transform', () => {
               tag: `"span"`,
               props: {
                 type: NodeTypes.SIMPLE_EXPRESSION,
-                content: `_hoisted_1`
+                content: `_hoisted_1`,
               },
               children: {
                 type: NodeTypes.INTERPOLATION,
                 content: {
                   content: `_ctx.bar`,
                   isStatic: false,
-                  constType: ConstantTypes.NOT_CONSTANT
-                }
+                  constType: ConstantTypes.NOT_CONSTANT,
+                },
               },
-              patchFlag: `1 /* TEXT */`
-            }
-          }
-        ]
+              patchFlag: `1 /* TEXT */`,
+            },
+          },
+        ],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -508,8 +508,8 @@ describe('compiler: hoistStatic transform', () => {
       const root = transformWithHoist(
         `<div><p v-for="o in list"><span>{{ o }}</span></p></div>`,
         {
-          prefixIdentifiers: true
-        }
+          prefixIdentifiers: true,
+        },
       )
 
       expect(root.hoists.length).toBe(0)
@@ -520,8 +520,8 @@ describe('compiler: hoistStatic transform', () => {
       const root = transformWithHoist(
         `<div><p v-for="o in list"><span>{{ o + 'foo' }}</span></p></div>`,
         {
-          prefixIdentifiers: true
-        }
+          prefixIdentifiers: true,
+        },
       )
 
       expect(root.hoists.length).toBe(0)
@@ -532,8 +532,8 @@ describe('compiler: hoistStatic transform', () => {
       const root = transformWithHoist(
         `<Comp v-slot="{ foo }">{{ foo }}</Comp>`,
         {
-          prefixIdentifiers: true
-        }
+          prefixIdentifiers: true,
+        },
       )
 
       expect(root.hoists.length).toBe(0)
@@ -545,8 +545,8 @@ describe('compiler: hoistStatic transform', () => {
         `<div><div><div @click="foo"/></div></div>`,
         {
           prefixIdentifiers: true,
-          cacheHandlers: true
-        }
+          cacheHandlers: true,
+        },
       )
 
       expect(root.cached).toBe(1)
@@ -554,8 +554,8 @@ describe('compiler: hoistStatic transform', () => {
       expect(
         generate(root, {
           mode: 'module',
-          prefixIdentifiers: true
-        }).code
+          prefixIdentifiers: true,
+        }).code,
       ).toMatchSnapshot()
     })
 
@@ -564,8 +564,8 @@ describe('compiler: hoistStatic transform', () => {
         `<div><div><div :class="{}" @click="foo"/></div></div>`,
         {
           prefixIdentifiers: true,
-          cacheHandlers: true
-        }
+          cacheHandlers: true,
+        },
       )
 
       expect(root.cached).toBe(1)
@@ -573,14 +573,14 @@ describe('compiler: hoistStatic transform', () => {
       expect(
         generate(root, {
           mode: 'module',
-          prefixIdentifiers: true
-        }).code
+          prefixIdentifiers: true,
+        }).code,
       ).toMatchSnapshot()
     })
 
     test('should NOT hoist keyed template v-for with plain element child', () => {
       const root = transformWithHoist(
-        `<div><template v-for="item in items" :key="item"><span/></template></div>`
+        `<div><template v-for="item in items" :key="item"><span/></template></div>`,
       )
       expect(root.hoists.length).toBe(0)
       expect(generate(root).code).toMatchSnapshot()
@@ -588,7 +588,7 @@ describe('compiler: hoistStatic transform', () => {
 
     test('should NOT hoist SVG with directives', () => {
       const root = transformWithHoist(
-        `<div><svg v-foo><path d="M2,3H5.5L12"/></svg></div>`
+        `<div><svg v-foo><path d="M2,3H5.5L12"/></svg></div>`,
       )
       expect(root.hoists.length).toBe(2)
       expect(generate(root).code).toMatchSnapshot()
@@ -596,13 +596,13 @@ describe('compiler: hoistStatic transform', () => {
 
     test('clone hoisted array children in HMR mode', () => {
       const root = transformWithHoist(`<div><span class="hi"></span></div>`, {
-        hmr: true
+        hmr: true,
       })
       expect(root.hoists.length).toBe(2)
       expect(root.codegenNode).toMatchObject({
         children: {
-          content: '[..._hoisted_2]'
-        }
+          content: '[..._hoisted_2]',
+        },
       })
     })
   })
index 96a60bd1d4287e28f06ca820f37c8c71c1841850..fa711051c18ed65ea782f45bf7d33371bebc1fab 100644 (file)
@@ -1,9 +1,9 @@
 import {
+  type ElementNode,
+  type VNodeCall,
+  noopDirectiveTransform,
   baseParse as parse,
   transform,
-  ElementNode,
-  noopDirectiveTransform,
-  VNodeCall
 } from '../../src'
 import { transformElement } from '../../src/transforms/transformElement'
 
@@ -13,8 +13,8 @@ describe('compiler: noop directive transform', () => {
     transform(ast, {
       nodeTransforms: [transformElement],
       directiveTransforms: {
-        noop: noopDirectiveTransform
-      }
+        noop: noopDirectiveTransform,
+      },
     })
     const node = ast.children[0] as ElementNode
     // As v-noop adds no properties the codegen should be identical to
index e8cca822474bfb6a170f347a1c66457c851d9153..5d3f92ced181e97403c3eff16fb5263d4d2988c9 100644 (file)
@@ -1,36 +1,36 @@
 import {
-  CompilerOptions,
+  BindingTypes,
+  type CompilerOptions,
+  ErrorCodes,
+  type NodeTransform,
+  baseCompile,
   baseParse as parse,
   transform,
-  ErrorCodes,
-  BindingTypes,
-  NodeTransform,
   transformExpression,
-  baseCompile
 } from '../../src'
 import {
-  RESOLVE_COMPONENT,
+  BASE_TRANSITION,
   CREATE_VNODE,
+  GUARD_REACTIVE_PROPS,
+  KEEP_ALIVE,
   MERGE_PROPS,
+  NORMALIZE_CLASS,
+  NORMALIZE_PROPS,
+  NORMALIZE_STYLE,
+  RESOLVE_COMPONENT,
   RESOLVE_DIRECTIVE,
-  TO_HANDLERS,
-  helperNameMap,
-  TELEPORT,
   RESOLVE_DYNAMIC_COMPONENT,
   SUSPENSE,
-  KEEP_ALIVE,
-  BASE_TRANSITION,
-  NORMALIZE_CLASS,
-  NORMALIZE_STYLE,
-  NORMALIZE_PROPS,
-  GUARD_REACTIVE_PROPS
+  TELEPORT,
+  TO_HANDLERS,
+  helperNameMap,
 } from '../../src/runtimeHelpers'
 import {
+  type DirectiveNode,
   NodeTypes,
+  type RootNode,
+  type VNodeCall,
   createObjectProperty,
-  DirectiveNode,
-  RootNode,
-  VNodeCall
 } from '../../src/ast'
 import { transformElement } from '../../src/transforms/transformElement'
 import { transformStyle } from '../../../compiler-dom/src/transforms/transformStyle'
@@ -42,7 +42,7 @@ import { transformText } from '../../src/transforms/transformText'
 
 function parseWithElementTransform(
   template: string,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ): {
   root: RootNode
   node: VNodeCall
@@ -52,14 +52,14 @@ function parseWithElementTransform(
   const ast = parse(`<div>${template}</div>`, options)
   transform(ast, {
     nodeTransforms: [transformElement, transformText],
-    ...options
+    ...options,
   })
   const codegenNode = (ast as any).children[0].children[0]
     .codegenNode as VNodeCall
   expect(codegenNode.type).toBe(NodeTypes.VNODE_CALL)
   return {
     root: ast,
-    node: codegenNode
+    node: codegenNode,
   }
 }
 
@@ -68,8 +68,8 @@ function parseWithBind(template: string, options?: CompilerOptions) {
     ...options,
     directiveTransforms: {
       ...options?.directiveTransforms,
-      bind: transformBind
-    }
+      bind: transformBind,
+    },
   })
 }
 
@@ -82,7 +82,7 @@ describe('compiler: element transform', () => {
 
   test('resolve implicitly self-referencing component', () => {
     const { root } = parseWithElementTransform(`<Example/>`, {
-      filename: `/foo/bar/Example.vue?vue&type=template`
+      filename: `/foo/bar/Example.vue?vue&type=template`,
     })
     expect(root.helpers).toContain(RESOLVE_COMPONENT)
     expect(root.components).toContain(`Example__self`)
@@ -91,8 +91,8 @@ describe('compiler: element transform', () => {
   test('resolve component from setup bindings', () => {
     const { root, node } = parseWithElementTransform(`<Example/>`, {
       bindingMetadata: {
-        Example: BindingTypes.SETUP_MAYBE_REF
-      }
+        Example: BindingTypes.SETUP_MAYBE_REF,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`$setup["Example"]`)
@@ -102,8 +102,8 @@ describe('compiler: element transform', () => {
     const { root, node } = parseWithElementTransform(`<Example/>`, {
       inline: true,
       bindingMetadata: {
-        Example: BindingTypes.SETUP_MAYBE_REF
-      }
+        Example: BindingTypes.SETUP_MAYBE_REF,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`_unref(Example)`)
@@ -113,8 +113,8 @@ describe('compiler: element transform', () => {
     const { root, node } = parseWithElementTransform(`<Example/>`, {
       inline: true,
       bindingMetadata: {
-        Example: BindingTypes.SETUP_CONST
-      }
+        Example: BindingTypes.SETUP_CONST,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`Example`)
@@ -123,8 +123,8 @@ describe('compiler: element transform', () => {
   test('resolve namespaced component from setup bindings', () => {
     const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
       bindingMetadata: {
-        Foo: BindingTypes.SETUP_MAYBE_REF
-      }
+        Foo: BindingTypes.SETUP_MAYBE_REF,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`$setup["Foo"].Example`)
@@ -134,8 +134,8 @@ describe('compiler: element transform', () => {
     const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
       inline: true,
       bindingMetadata: {
-        Foo: BindingTypes.SETUP_MAYBE_REF
-      }
+        Foo: BindingTypes.SETUP_MAYBE_REF,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`_unref(Foo).Example`)
@@ -145,8 +145,8 @@ describe('compiler: element transform', () => {
     const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
       inline: true,
       bindingMetadata: {
-        Foo: BindingTypes.SETUP_CONST
-      }
+        Foo: BindingTypes.SETUP_CONST,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`Foo.Example`)
@@ -156,8 +156,8 @@ describe('compiler: element transform', () => {
     const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
       inline: true,
       bindingMetadata: {
-        Foo: BindingTypes.PROPS
-      }
+        Foo: BindingTypes.PROPS,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe(`_unref(__props["Foo"]).Example`)
@@ -167,8 +167,8 @@ describe('compiler: element transform', () => {
     const { root, node } = parseWithElementTransform(`<Foo.Example/>`, {
       inline: false,
       bindingMetadata: {
-        Foo: BindingTypes.PROPS
-      }
+        Foo: BindingTypes.PROPS,
+      },
     })
     expect(root.helpers).not.toContain(RESOLVE_COMPONENT)
     expect(node.tag).toBe('_unref($props["Foo"]).Example')
@@ -176,11 +176,11 @@ describe('compiler: element transform', () => {
 
   test('do not resolve component from non-script-setup bindings', () => {
     const bindingMetadata = {
-      Example: BindingTypes.SETUP_MAYBE_REF
+      Example: BindingTypes.SETUP_MAYBE_REF,
     }
     Object.defineProperty(bindingMetadata, '__isScriptSetup', { value: false })
     const { root } = parseWithElementTransform(`<Example/>`, {
-      bindingMetadata
+      bindingMetadata,
     })
     expect(root.helpers).toContain(RESOLVE_COMPONENT)
     expect(root.components).toContain(`Example`)
@@ -192,9 +192,9 @@ describe('compiler: element transform', () => {
       tag: `"div"`,
       props: createObjectMatcher({
         id: 'foo',
-        class: 'bar'
+        class: 'bar',
       }),
-      children: undefined
+      children: undefined,
     })
   })
 
@@ -204,7 +204,7 @@ describe('compiler: element transform', () => {
     expect(node).toMatchObject({
       tag: `"div"`,
       props: createObjectMatcher({
-        id: 'foo'
+        id: 'foo',
       }),
       children: [
         {
@@ -212,10 +212,10 @@ describe('compiler: element transform', () => {
           tag: 'span',
           codegenNode: {
             type: NodeTypes.VNODE_CALL,
-            tag: `"span"`
-          }
-        }
-      ]
+            tag: `"span"`,
+          },
+        },
+      ],
     })
   })
 
@@ -231,10 +231,10 @@ describe('compiler: element transform', () => {
           tag: 'span',
           codegenNode: {
             type: NodeTypes.VNODE_CALL,
-            tag: `"span"`
-          }
-        }
-      ]
+            tag: `"span"`,
+          },
+        },
+      ],
     })
   })
 
@@ -256,17 +256,17 @@ describe('compiler: element transform', () => {
           arguments: [
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: `obj`
-            }
-          ]
-        }
-      ]
+              content: `obj`,
+            },
+          ],
+        },
+      ],
     })
   })
 
   test('v-bind="obj" after static prop', () => {
     const { root, node } = parseWithElementTransform(
-      `<div id="foo" v-bind="obj" />`
+      `<div id="foo" v-bind="obj" />`,
     )
     expect(root.helpers).toContain(MERGE_PROPS)
 
@@ -275,19 +275,19 @@ describe('compiler: element transform', () => {
       callee: MERGE_PROPS,
       arguments: [
         createObjectMatcher({
-          id: 'foo'
+          id: 'foo',
         }),
         {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `obj`
-        }
-      ]
+          content: `obj`,
+        },
+      ],
     })
   })
 
   test('v-bind="obj" before static prop', () => {
     const { root, node } = parseWithElementTransform(
-      `<div v-bind="obj" id="foo" />`
+      `<div v-bind="obj" id="foo" />`,
     )
     expect(root.helpers).toContain(MERGE_PROPS)
 
@@ -297,18 +297,18 @@ describe('compiler: element transform', () => {
       arguments: [
         {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `obj`
+          content: `obj`,
         },
         createObjectMatcher({
-          id: 'foo'
-        })
-      ]
+          id: 'foo',
+        }),
+      ],
     })
   })
 
   test('v-bind="obj" between static props', () => {
     const { root, node } = parseWithElementTransform(
-      `<div id="foo" v-bind="obj" class="bar" />`
+      `<div id="foo" v-bind="obj" class="bar" />`,
     )
     expect(root.helpers).toContain(MERGE_PROPS)
 
@@ -317,22 +317,22 @@ describe('compiler: element transform', () => {
       callee: MERGE_PROPS,
       arguments: [
         createObjectMatcher({
-          id: 'foo'
+          id: 'foo',
         }),
         {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `obj`
+          content: `obj`,
         },
         createObjectMatcher({
-          class: 'bar'
-        })
-      ]
+          class: 'bar',
+        }),
+      ],
     })
   })
 
   test('v-on="obj"', () => {
     const { root, node } = parseWithElementTransform(
-      `<div id="foo" v-on="obj" class="bar" />`
+      `<div id="foo" v-on="obj" class="bar" />`,
     )
     expect(root.helpers).toContain(MERGE_PROPS)
 
@@ -341,7 +341,7 @@ describe('compiler: element transform', () => {
       callee: MERGE_PROPS,
       arguments: [
         createObjectMatcher({
-          id: 'foo'
+          id: 'foo',
         }),
         {
           type: NodeTypes.JS_CALL_EXPRESSION,
@@ -349,21 +349,21 @@ describe('compiler: element transform', () => {
           arguments: [
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: `obj`
+              content: `obj`,
             },
-            `true`
-          ]
+            `true`,
+          ],
         },
         createObjectMatcher({
-          class: 'bar'
-        })
-      ]
+          class: 'bar',
+        }),
+      ],
     })
   })
 
   test('v-on="obj" on component', () => {
     const { root, node } = parseWithElementTransform(
-      `<Foo id="foo" v-on="obj" class="bar" />`
+      `<Foo id="foo" v-on="obj" class="bar" />`,
     )
     expect(root.helpers).toContain(MERGE_PROPS)
 
@@ -372,7 +372,7 @@ describe('compiler: element transform', () => {
       callee: MERGE_PROPS,
       arguments: [
         createObjectMatcher({
-          id: 'foo'
+          id: 'foo',
         }),
         {
           type: NodeTypes.JS_CALL_EXPRESSION,
@@ -380,20 +380,20 @@ describe('compiler: element transform', () => {
           arguments: [
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: `obj`
-            }
-          ]
+              content: `obj`,
+            },
+          ],
         },
         createObjectMatcher({
-          class: 'bar'
-        })
-      ]
+          class: 'bar',
+        }),
+      ],
     })
   })
 
   test('v-on="obj" + v-bind="obj"', () => {
     const { root, node } = parseWithElementTransform(
-      `<div id="foo" v-on="handlers" v-bind="obj" />`
+      `<div id="foo" v-on="handlers" v-bind="obj" />`,
     )
     expect(root.helpers).toContain(MERGE_PROPS)
 
@@ -402,7 +402,7 @@ describe('compiler: element transform', () => {
       callee: MERGE_PROPS,
       arguments: [
         createObjectMatcher({
-          id: 'foo'
+          id: 'foo',
         }),
         {
           type: NodeTypes.JS_CALL_EXPRESSION,
@@ -410,16 +410,16 @@ describe('compiler: element transform', () => {
           arguments: [
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: `handlers`
+              content: `handlers`,
             },
-            `true`
-          ]
+            `true`,
+          ],
         },
         {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `obj`
-        }
-      ]
+          content: `obj`,
+        },
+      ],
     })
   })
 
@@ -429,15 +429,15 @@ describe('compiler: element transform', () => {
     expect(node).toMatchObject({
       tag: `"template"`,
       props: createObjectMatcher({
-        id: 'foo'
-      })
+        id: 'foo',
+      }),
     })
   })
 
   test('should handle <Teleport> with normal children', () => {
     function assert(tag: string) {
       const { root, node } = parseWithElementTransform(
-        `<${tag} target="#foo"><span /></${tag}>`
+        `<${tag} target="#foo"><span /></${tag}>`,
       )
       expect(root.components.length).toBe(0)
       expect(root.helpers).toContain(TELEPORT)
@@ -445,7 +445,7 @@ describe('compiler: element transform', () => {
       expect(node).toMatchObject({
         tag: TELEPORT,
         props: createObjectMatcher({
-          target: '#foo'
+          target: '#foo',
         }),
         children: [
           {
@@ -453,10 +453,10 @@ describe('compiler: element transform', () => {
             tag: 'span',
             codegenNode: {
               type: NodeTypes.VNODE_CALL,
-              tag: `"span"`
-            }
-          }
-        ]
+              tag: `"span"`,
+            },
+          },
+        ],
       })
     }
 
@@ -467,7 +467,7 @@ describe('compiler: element transform', () => {
   test('should handle <Suspense>', () => {
     function assert(tag: string, content: string, hasFallback?: boolean) {
       const { root, node } = parseWithElementTransform(
-        `<${tag}>${content}</${tag}>`
+        `<${tag}>${content}</${tag}>`,
       )
       expect(root.components.length).toBe(0)
       expect(root.helpers).toContain(SUSPENSE)
@@ -478,19 +478,19 @@ describe('compiler: element transform', () => {
         children: hasFallback
           ? createObjectMatcher({
               default: {
-                type: NodeTypes.JS_FUNCTION_EXPRESSION
+                type: NodeTypes.JS_FUNCTION_EXPRESSION,
               },
               fallback: {
-                type: NodeTypes.JS_FUNCTION_EXPRESSION
+                type: NodeTypes.JS_FUNCTION_EXPRESSION,
               },
-              _: `[1 /* STABLE */]`
+              _: `[1 /* STABLE */]`,
             })
           : createObjectMatcher({
               default: {
-                type: NodeTypes.JS_FUNCTION_EXPRESSION
+                type: NodeTypes.JS_FUNCTION_EXPRESSION,
               },
-              _: `[1 /* STABLE */]`
-            })
+              _: `[1 /* STABLE */]`,
+            }),
       })
     }
 
@@ -499,7 +499,7 @@ describe('compiler: element transform', () => {
     assert(
       `suspense`,
       `<template #default>foo</template><template #fallback>fallback</template>`,
-      true
+      true,
     )
   })
 
@@ -507,7 +507,7 @@ describe('compiler: element transform', () => {
     function assert(tag: string) {
       const root = parse(`<div><${tag}><span /></${tag}></div>`)
       transform(root, {
-        nodeTransforms: [transformElement, transformText]
+        nodeTransforms: [transformElement, transformText],
       })
       expect(root.components.length).toBe(0)
       expect(root.helpers).toContain(KEEP_ALIVE)
@@ -520,7 +520,7 @@ describe('compiler: element transform', () => {
         // keep-alive should not compile content to slots
         children: [{ type: NodeTypes.ELEMENT, tag: 'span' }],
         // should get a dynamic slots flag to force updates
-        patchFlag: genFlagText(PatchFlags.DYNAMIC_SLOTS)
+        patchFlag: genFlagText(PatchFlags.DYNAMIC_SLOTS),
       })
     }
 
@@ -531,7 +531,7 @@ describe('compiler: element transform', () => {
   test('should handle <BaseTransition>', () => {
     function assert(tag: string) {
       const { root, node } = parseWithElementTransform(
-        `<${tag}><span /></${tag}>`
+        `<${tag}><span /></${tag}>`,
       )
       expect(root.components.length).toBe(0)
       expect(root.helpers).toContain(BASE_TRANSITION)
@@ -541,10 +541,10 @@ describe('compiler: element transform', () => {
         props: undefined,
         children: createObjectMatcher({
           default: {
-            type: NodeTypes.JS_FUNCTION_EXPRESSION
+            type: NodeTypes.JS_FUNCTION_EXPRESSION,
           },
-          _: `[1 /* STABLE */]`
-        })
+          _: `[1 /* STABLE */]`,
+        }),
       })
     }
 
@@ -557,8 +557,8 @@ describe('compiler: element transform', () => {
     parseWithElementTransform(`<div v-bind/>`, { onError })
     expect(onError.mock.calls[0]).toMatchObject([
       {
-        code: ErrorCodes.X_V_BIND_NO_EXPRESSION
-      }
+        code: ErrorCodes.X_V_BIND_NO_EXPRESSION,
+      },
     ])
   })
 
@@ -569,10 +569,10 @@ describe('compiler: element transform', () => {
         foo(dir) {
           _dir = dir
           return {
-            props: [createObjectProperty(dir.arg!, dir.exp!)]
+            props: [createObjectProperty(dir.arg!, dir.exp!)],
           }
-        }
-      }
+        },
+      },
     })
 
     expect(node.props).toMatchObject({
@@ -581,9 +581,9 @@ describe('compiler: element transform', () => {
         {
           type: NodeTypes.JS_PROPERTY,
           key: _dir!.arg,
-          value: _dir!.exp
-        }
-      ]
+          value: _dir!.exp,
+        },
+      ],
     })
     // should factor in props returned by custom directive transforms
     // in patchFlag analysis
@@ -599,11 +599,11 @@ describe('compiler: element transform', () => {
           foo() {
             return {
               props: [],
-              needRuntime: true
+              needRuntime: true,
             }
-          }
-        }
-      }
+          },
+        },
+      },
     )
     expect(root.helpers).toContain(RESOLVE_DIRECTIVE)
     expect(root.directives).toContain(`foo`)
@@ -623,18 +623,18 @@ describe('compiler: element transform', () => {
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
                 content: `hello`,
-                isStatic: false
+                isStatic: false,
               },
               // arg
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
                 content: `bar`,
-                isStatic: true
-              }
-            ]
-          }
-        ]
-      }
+                isStatic: true,
+              },
+            ],
+          },
+        ],
+      },
     })
   })
 
@@ -646,24 +646,24 @@ describe('compiler: element transform', () => {
           foo() {
             return {
               props: [],
-              needRuntime: CREATE_VNODE
+              needRuntime: CREATE_VNODE,
             }
-          }
-        }
-      }
+          },
+        },
+      },
     )
 
     expect(root.helpers).toContain(CREATE_VNODE)
     expect(root.helpers).not.toContain(RESOLVE_DIRECTIVE)
     expect(root.directives.length).toBe(0)
     expect(node.directives!.elements[0].elements[0]).toBe(
-      `_${helperNameMap[CREATE_VNODE]}`
+      `_${helperNameMap[CREATE_VNODE]}`,
     )
   })
 
   test('runtime directives', () => {
     const { root, node } = parseWithElementTransform(
-      `<div v-foo v-bar="x" v-baz:[arg].mod.mad="y" />`
+      `<div v-foo v-bar="x" v-baz:[arg].mod.mad="y" />`,
     )
     expect(root.helpers).toContain(RESOLVE_DIRECTIVE)
     expect(root.directives).toContain(`foo`)
@@ -676,7 +676,7 @@ describe('compiler: element transform', () => {
         elements: [
           {
             type: NodeTypes.JS_ARRAY_EXPRESSION,
-            elements: [`_directive_foo`]
+            elements: [`_directive_foo`],
           },
           {
             type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -685,9 +685,9 @@ describe('compiler: element transform', () => {
               // exp
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
-                content: `x`
-              }
-            ]
+                content: `x`,
+              },
+            ],
           },
           {
             type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -697,13 +697,13 @@ describe('compiler: element transform', () => {
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
                 content: `y`,
-                isStatic: false
+                isStatic: false,
               },
               // arg
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
                 content: `arg`,
-                isStatic: false
+                isStatic: false,
               },
               // modifiers
               {
@@ -714,33 +714,33 @@ describe('compiler: element transform', () => {
                     key: {
                       type: NodeTypes.SIMPLE_EXPRESSION,
                       content: `mod`,
-                      isStatic: true
+                      isStatic: true,
                     },
                     value: {
                       type: NodeTypes.SIMPLE_EXPRESSION,
                       content: `true`,
-                      isStatic: false
-                    }
+                      isStatic: false,
+                    },
                   },
                   {
                     type: NodeTypes.JS_PROPERTY,
                     key: {
                       type: NodeTypes.SIMPLE_EXPRESSION,
                       content: `mad`,
-                      isStatic: true
+                      isStatic: true,
                     },
                     value: {
                       type: NodeTypes.SIMPLE_EXPRESSION,
                       content: `true`,
-                      isStatic: false
-                    }
-                  }
-                ]
-              }
-            ]
-          }
-        ]
-      }
+                      isStatic: false,
+                    },
+                  },
+                ],
+              },
+            ],
+          },
+        ],
+      },
     })
   })
 
@@ -749,9 +749,9 @@ describe('compiler: element transform', () => {
       `<div @click.foo="a" @click.bar="b" />`,
       {
         directiveTransforms: {
-          on: transformOn
-        }
-      }
+          on: transformOn,
+        },
+      },
     )
     expect(node.props).toMatchObject({
       type: NodeTypes.JS_OBJECT_EXPRESSION,
@@ -761,7 +761,7 @@ describe('compiler: element transform', () => {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `onClick`,
-            isStatic: true
+            isStatic: true,
           },
           value: {
             type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -769,17 +769,17 @@ describe('compiler: element transform', () => {
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
                 content: `a`,
-                isStatic: false
+                isStatic: false,
               },
               {
                 type: NodeTypes.SIMPLE_EXPRESSION,
                 content: `b`,
-                isStatic: false
-              }
-            ]
-          }
-        }
-      ]
+                isStatic: false,
+              },
+            ],
+          },
+        },
+      ],
     })
   })
 
@@ -789,9 +789,9 @@ describe('compiler: element transform', () => {
       {
         nodeTransforms: [transformStyle, transformElement],
         directiveTransforms: {
-          bind: transformBind
-        }
-      }
+          bind: transformBind,
+        },
+      },
     )
     expect(root.helpers).toContain(NORMALIZE_STYLE)
     expect(node.props).toMatchObject({
@@ -802,7 +802,7 @@ describe('compiler: element transform', () => {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `style`,
-            isStatic: true
+            isStatic: true,
           },
           value: {
             type: NodeTypes.JS_CALL_EXPRESSION,
@@ -814,19 +814,19 @@ describe('compiler: element transform', () => {
                   {
                     type: NodeTypes.SIMPLE_EXPRESSION,
                     content: `{"color":"green"}`,
-                    isStatic: false
+                    isStatic: false,
                   },
                   {
                     type: NodeTypes.SIMPLE_EXPRESSION,
                     content: `{ color: 'red' }`,
-                    isStatic: false
-                  }
-                ]
-              }
-            ]
-          }
-        }
-      ]
+                    isStatic: false,
+                  },
+                ],
+              },
+            ],
+          },
+        },
+      ],
     })
   })
 
@@ -836,10 +836,10 @@ describe('compiler: element transform', () => {
       {
         nodeTransforms: [transformExpression, transformStyle, transformElement],
         directiveTransforms: {
-          bind: transformBind
+          bind: transformBind,
         },
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     expect(root.helpers).toContain(NORMALIZE_STYLE)
     expect(node.props).toMatchObject({
@@ -850,14 +850,14 @@ describe('compiler: element transform', () => {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `style`,
-            isStatic: true
+            isStatic: true,
           },
           value: {
             type: NodeTypes.JS_CALL_EXPRESSION,
-            callee: NORMALIZE_STYLE
-          }
-        }
-      ]
+            callee: NORMALIZE_STYLE,
+          },
+        },
+      ],
     })
   })
 
@@ -867,10 +867,10 @@ describe('compiler: element transform', () => {
       {
         nodeTransforms: [transformExpression, transformStyle, transformElement],
         directiveTransforms: {
-          bind: transformBind
+          bind: transformBind,
         },
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     expect(root.helpers).toContain(NORMALIZE_STYLE)
     expect(node.props).toMatchObject({
@@ -881,14 +881,14 @@ describe('compiler: element transform', () => {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `style`,
-            isStatic: true
+            isStatic: true,
           },
           value: {
             type: NodeTypes.JS_CALL_EXPRESSION,
-            callee: NORMALIZE_STYLE
-          }
-        }
-      ]
+            callee: NORMALIZE_STYLE,
+          },
+        },
+      ],
     })
   })
 
@@ -897,9 +897,9 @@ describe('compiler: element transform', () => {
       `<div class="foo" :class="{ bar: isBar }" />`,
       {
         directiveTransforms: {
-          bind: transformBind
-        }
-      }
+          bind: transformBind,
+        },
+      },
     )
     expect(root.helpers).toContain(NORMALIZE_CLASS)
     expect(node.props).toMatchObject({
@@ -910,7 +910,7 @@ describe('compiler: element transform', () => {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `class`,
-            isStatic: true
+            isStatic: true,
           },
           value: {
             type: NodeTypes.JS_CALL_EXPRESSION,
@@ -922,19 +922,19 @@ describe('compiler: element transform', () => {
                   {
                     type: NodeTypes.SIMPLE_EXPRESSION,
                     content: `foo`,
-                    isStatic: true
+                    isStatic: true,
                   },
                   {
                     type: NodeTypes.SIMPLE_EXPRESSION,
                     content: `{ bar: isBar }`,
-                    isStatic: false
-                  }
-                ]
-              }
-            ]
-          }
-        }
-      ]
+                    isStatic: false,
+                  },
+                ],
+              },
+            ],
+          },
+        },
+      ],
     })
   })
 
@@ -969,10 +969,10 @@ describe('compiler: element transform', () => {
 
     test('CLASS + STYLE + PROPS', () => {
       const { node } = parseWithBind(
-        `<div id="foo" :class="cls" :style="styl" :foo="bar" :baz="qux"/>`
+        `<div id="foo" :class="cls" :style="styl" :foo="bar" :baz="qux"/>`,
       )
       expect(node.patchFlag).toBe(
-        genFlagText([PatchFlags.CLASS, PatchFlags.STYLE, PatchFlags.PROPS])
+        genFlagText([PatchFlags.CLASS, PatchFlags.STYLE, PatchFlags.PROPS]),
       )
       expect(node.dynamicProps).toBe(`["foo", "baz"]`)
     })
@@ -980,7 +980,7 @@ describe('compiler: element transform', () => {
     // should treat `class` and `style` as PROPS
     test('PROPS on component', () => {
       const { node } = parseWithBind(
-        `<Foo :id="foo" :class="cls" :style="styl" />`
+        `<Foo :id="foo" :class="cls" :style="styl" />`,
       )
       expect(node.patchFlag).toBe(genFlagText(PatchFlags.PROPS))
       expect(node.dynamicProps).toBe(`["id", "class", "style"]`)
@@ -998,7 +998,7 @@ describe('compiler: element transform', () => {
 
     test('FULL_PROPS (w/ others)', () => {
       const { node } = parseWithBind(
-        `<div id="foo" v-bind="bar" :class="cls" />`
+        `<div id="foo" v-bind="bar" :class="cls" />`,
       )
       expect(node.patchFlag).toBe(genFlagText(PatchFlags.FULL_PROPS))
     })
@@ -1021,7 +1021,7 @@ describe('compiler: element transform', () => {
     test('NEED_PATCH (vnode hooks)', () => {
       const root = baseCompile(`<div @vue:updated="foo" />`, {
         prefixIdentifiers: true,
-        cacheHandlers: true
+        cacheHandlers: true,
       }).ast
       const node = (root as any).children[0].codegenNode
       expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_PATCH))
@@ -1031,8 +1031,8 @@ describe('compiler: element transform', () => {
       const { node } = parseWithElementTransform(`<input ref="input"/>`, {
         inline: true,
         bindingMetadata: {
-          input: BindingTypes.SETUP_REF
-        }
+          input: BindingTypes.SETUP_REF,
+        },
       })
       expect(node.props).toMatchObject({
         type: NodeTypes.JS_OBJECT_EXPRESSION,
@@ -1041,31 +1041,31 @@ describe('compiler: element transform', () => {
             type: NodeTypes.JS_PROPERTY,
             key: {
               content: 'ref_key',
-              isStatic: true
+              isStatic: true,
             },
             value: {
               content: 'input',
-              isStatic: true
-            }
+              isStatic: true,
+            },
           },
           {
             type: NodeTypes.JS_PROPERTY,
             key: {
               content: 'ref',
-              isStatic: true
+              isStatic: true,
             },
             value: {
               content: 'input',
-              isStatic: false
-            }
-          }
-        ]
+              isStatic: false,
+            },
+          },
+        ],
       })
     })
 
     test('script setup inline mode template ref (binding does not exist)', () => {
       const { node } = parseWithElementTransform(`<input ref="input"/>`, {
-        inline: true
+        inline: true,
       })
       expect(node.props).toMatchObject({
         type: NodeTypes.JS_OBJECT_EXPRESSION,
@@ -1074,14 +1074,14 @@ describe('compiler: element transform', () => {
             type: NodeTypes.JS_PROPERTY,
             key: {
               content: 'ref',
-              isStatic: true
+              isStatic: true,
             },
             value: {
               content: 'input',
-              isStatic: true
-            }
-          }
-        ]
+              isStatic: true,
+            },
+          },
+        ],
       })
     })
 
@@ -1090,8 +1090,8 @@ describe('compiler: element transform', () => {
         inline: true,
         bindingMetadata: {
           msg: BindingTypes.PROPS,
-          ref: BindingTypes.SETUP_CONST
-        }
+          ref: BindingTypes.SETUP_CONST,
+        },
       })
       expect(node.props).toMatchObject({
         type: NodeTypes.JS_OBJECT_EXPRESSION,
@@ -1100,14 +1100,14 @@ describe('compiler: element transform', () => {
             type: NodeTypes.JS_PROPERTY,
             key: {
               content: 'ref',
-              isStatic: true
+              isStatic: true,
             },
             value: {
               content: 'msg',
-              isStatic: true
-            }
-          }
-        ]
+              isStatic: true,
+            },
+          },
+        ],
       })
     })
 
@@ -1115,8 +1115,8 @@ describe('compiler: element transform', () => {
       // ignore click events (has dedicated fast path)
       const { node } = parseWithElementTransform(`<div @click="foo" />`, {
         directiveTransforms: {
-          on: transformOn
-        }
+          on: transformOn,
+        },
       })
       // should only have props flag
       expect(node.patchFlag).toBe(genFlagText(PatchFlags.PROPS))
@@ -1125,24 +1125,24 @@ describe('compiler: element transform', () => {
         `<div @keyup="foo" />`,
         {
           directiveTransforms: {
-            on: transformOn
-          }
-        }
+            on: transformOn,
+          },
+        },
       )
       expect(node2.patchFlag).toBe(
-        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
+        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION]),
       )
     })
 
     test('NEED_HYDRATION for v-bind.prop', () => {
       const { node } = parseWithBind(`<div v-bind:id.prop="id" />`)
       expect(node.patchFlag).toBe(
-        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
+        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION]),
       )
 
       const { node: node2 } = parseWithBind(`<div .id="id" />`)
       expect(node2.patchFlag).toBe(
-        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
+        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION]),
       )
     })
 
@@ -1152,12 +1152,12 @@ describe('compiler: element transform', () => {
         `<component :is="foo" @input="foo" />`,
         {
           directiveTransforms: {
-            on: transformOn
-          }
-        }
+            on: transformOn,
+          },
+        },
       )
       expect(node.patchFlag).toBe(
-        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION])
+        genFlagText([PatchFlags.PROPS, PatchFlags.NEED_HYDRATION]),
       )
     })
 
@@ -1165,11 +1165,11 @@ describe('compiler: element transform', () => {
       const { node } = parseWithElementTransform(`<div @keydown="foo" />`, {
         prefixIdentifiers: true,
         bindingMetadata: {
-          foo: BindingTypes.SETUP_CONST
+          foo: BindingTypes.SETUP_CONST,
         },
         directiveTransforms: {
-          on: transformOn
-        }
+          on: transformOn,
+        },
       })
       // should only have hydration flag
       expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_HYDRATION))
@@ -1188,10 +1188,10 @@ describe('compiler: element transform', () => {
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: 'foo',
-              isStatic: true
-            }
-          ]
-        }
+              isStatic: true,
+            },
+          ],
+        },
       })
     })
 
@@ -1206,10 +1206,10 @@ describe('compiler: element transform', () => {
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: 'foo',
-              isStatic: true
-            }
-          ]
-        }
+              isStatic: true,
+            },
+          ],
+        },
       })
     })
 
@@ -1224,10 +1224,10 @@ describe('compiler: element transform', () => {
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: 'foo',
-              isStatic: false
-            }
-          ]
-        }
+              isStatic: false,
+            },
+          ],
+        },
       })
     })
 
@@ -1236,19 +1236,19 @@ describe('compiler: element transform', () => {
       expect(root.helpers).toContain(RESOLVE_COMPONENT)
       expect(node).toMatchObject({
         type: NodeTypes.VNODE_CALL,
-        tag: '_component_foo'
+        tag: '_component_foo',
       })
     })
 
     // #3934
     test('normal component with is prop', () => {
       const { node, root } = parseWithBind(`<custom-input is="foo" />`, {
-        isNativeTag: () => false
+        isNativeTag: () => false,
       })
       expect(root.helpers).toContain(RESOLVE_COMPONENT)
       expect(root.helpers).not.toContain(RESOLVE_DYNAMIC_COMPONENT)
       expect(node).toMatchObject({
-        tag: '_component_custom_input'
+        tag: '_component_custom_input',
       })
     })
   })
@@ -1256,12 +1256,12 @@ describe('compiler: element transform', () => {
   test('<svg> should be forced into blocks', () => {
     const ast = parse(`<div><svg/></div>`)
     transform(ast, {
-      nodeTransforms: [transformElement]
+      nodeTransforms: [transformElement],
     })
     expect((ast as any).children[0].children[0].codegenNode).toMatchObject({
       type: NodeTypes.VNODE_CALL,
       tag: `"svg"`,
-      isBlock: true
+      isBlock: true,
     })
   })
 
@@ -1273,7 +1273,7 @@ describe('compiler: element transform', () => {
   test('force block for inline before-update handlers w/ children', () => {
     expect(
       parseWithElementTransform(`<div @vue:before-update>hello</div>`).node
-        .isBlock
+        .isBlock,
     ).toBe(true)
   })
 
@@ -1281,12 +1281,12 @@ describe('compiler: element transform', () => {
   test('element with dynamic keys should be forced into blocks', () => {
     const ast = parse(`<div><div :key="foo" /></div>`)
     transform(ast, {
-      nodeTransforms: [transformElement]
+      nodeTransforms: [transformElement],
     })
     expect((ast as any).children[0].children[0].codegenNode).toMatchObject({
       type: NodeTypes.VNODE_CALL,
       tag: `"div"`,
-      isBlock: true
+      isBlock: true,
     })
   })
 
@@ -1301,23 +1301,23 @@ describe('compiler: element transform', () => {
             prop.type === NodeTypes.ATTRIBUTE &&
             prop.name === 'id' &&
             prop.value &&
-            prop.value.content === 'foo'
+            prop.value.content === 'foo',
         )
       ) {
         context.replaceNode({
           ...node,
-          tag: 'span'
+          tag: 'span',
         })
       }
     }
     const ast = parse(`<div><div id="foo" /></div>`)
     transform(ast, {
-      nodeTransforms: [transformElement, transformText, customNodeTransform]
+      nodeTransforms: [transformElement, transformText, customNodeTransform],
     })
     expect((ast as any).children[0].children[0].codegenNode).toMatchObject({
       type: NodeTypes.VNODE_CALL,
       tag: '"span"',
-      isBlock: false
+      isBlock: false,
     })
   })
 })
index b33cbbd80f6ef9ed9e6a82315caff5e61f84ef33..b8207e7d42f16522b3dae545cad36e8171fd2880 100644 (file)
@@ -1,14 +1,14 @@
 import {
+  BindingTypes,
+  type CompilerOptions,
+  ConstantTypes,
+  type DirectiveNode,
+  type ElementNode,
+  type InterpolationNode,
+  NodeTypes,
+  baseCompile,
   baseParse as parse,
   transform,
-  ElementNode,
-  DirectiveNode,
-  NodeTypes,
-  CompilerOptions,
-  InterpolationNode,
-  ConstantTypes,
-  BindingTypes,
-  baseCompile
 } from '../../src'
 import { transformIf } from '../../src/transforms/vIf'
 import { transformExpression } from '../../src/transforms/transformExpression'
@@ -16,13 +16,13 @@ import { PatchFlagNames, PatchFlags } from '../../../shared/src'
 
 function parseWithExpressionTransform(
   template: string,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ) {
   const ast = parse(template, options)
   transform(ast, {
     prefixIdentifiers: true,
     nodeTransforms: [transformIf, transformExpression],
-    ...options
+    ...options,
   })
   return ast.children[0]
 }
@@ -32,7 +32,7 @@ describe('compiler: expression transform', () => {
     const node = parseWithExpressionTransform(`{{ foo }}`) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `_ctx.foo`
+      content: `_ctx.foo`,
     })
   })
 
@@ -40,34 +40,34 @@ describe('compiler: expression transform', () => {
     const node = parseWithExpressionTransform(`{{}}`) as InterpolationNode
     const node2 = parseWithExpressionTransform(`{{ }}`) as InterpolationNode
     const node3 = parseWithExpressionTransform(
-      `<div>{{ }}</div>`
+      `<div>{{ }}</div>`,
     ) as ElementNode
 
     const objectToBeMatched = {
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: ``
+      content: ``,
     }
     expect(node.content).toMatchObject(objectToBeMatched)
     expect(node2.content).toMatchObject(objectToBeMatched)
     expect((node3.children[0] as InterpolationNode).content).toMatchObject(
-      objectToBeMatched
+      objectToBeMatched,
     )
   })
 
   test('interpolation (children)', () => {
     const el = parseWithExpressionTransform(
-      `<div>{{ foo }}</div>`
+      `<div>{{ foo }}</div>`,
     ) as ElementNode
     const node = el.children[0] as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `_ctx.foo`
+      content: `_ctx.foo`,
     })
   })
 
   test('interpolation (complex)', () => {
     const el = parseWithExpressionTransform(
-      `<div>{{ foo + bar(baz.qux) }}</div>`
+      `<div>{{ foo + bar(baz.qux) }}</div>`,
     ) as ElementNode
     const node = el.children[0] as InterpolationNode
     expect(node.content).toMatchObject({
@@ -80,46 +80,46 @@ describe('compiler: expression transform', () => {
         { content: `_ctx.baz` },
         `.`,
         { content: `qux` },
-        `)`
-      ]
+        `)`,
+      ],
     })
   })
 
   test('directive value', () => {
     const node = parseWithExpressionTransform(
-      `<div v-foo:arg="baz"/>`
+      `<div v-foo:arg="baz"/>`,
     ) as ElementNode
     const arg = (node.props[0] as DirectiveNode).arg!
     expect(arg).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `arg`
+      content: `arg`,
     })
     const exp = (node.props[0] as DirectiveNode).exp!
     expect(exp).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `_ctx.baz`
+      content: `_ctx.baz`,
     })
   })
 
   test('dynamic directive arg', () => {
     const node = parseWithExpressionTransform(
-      `<div v-foo:[arg]="baz"/>`
+      `<div v-foo:[arg]="baz"/>`,
     ) as ElementNode
     const arg = (node.props[0] as DirectiveNode).arg!
     expect(arg).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `_ctx.arg`
+      content: `_ctx.arg`,
     })
     const exp = (node.props[0] as DirectiveNode).exp!
     expect(exp).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `_ctx.baz`
+      content: `_ctx.baz`,
     })
   })
 
   test('should prefix complex expressions', () => {
     const node = parseWithExpressionTransform(
-      `{{ foo(baz + 1, { key: kuz }) }}`
+      `{{ foo(baz + 1, { key: kuz }) }}`,
     ) as InterpolationNode
     // should parse into compound expression
     expect(node.content).toMatchObject({
@@ -129,56 +129,56 @@ describe('compiler: expression transform', () => {
           content: `_ctx.foo`,
           loc: {
             start: { offset: 3, line: 1, column: 4 },
-            end: { offset: 6, line: 1, column: 7 }
-          }
+            end: { offset: 6, line: 1, column: 7 },
+          },
         },
         `(`,
         {
           content: `_ctx.baz`,
           loc: {
             start: { offset: 7, line: 1, column: 8 },
-            end: { offset: 10, line: 1, column: 11 }
-          }
+            end: { offset: 10, line: 1, column: 11 },
+          },
         },
         ` + 1, { key: `,
         {
           content: `_ctx.kuz`,
           loc: {
             start: { offset: 23, line: 1, column: 24 },
-            end: { offset: 26, line: 1, column: 27 }
-          }
+            end: { offset: 26, line: 1, column: 27 },
+          },
         },
-        ` })`
-      ]
+        ` })`,
+      ],
     })
   })
 
   test('should not prefix whitelisted globals', () => {
     const node = parseWithExpressionTransform(
-      `{{ Math.max(1, 2) }}`
+      `{{ Math.max(1, 2) }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
-      children: [{ content: `Math` }, `.`, { content: `max` }, `(1, 2)`]
+      children: [{ content: `Math` }, `.`, { content: `max` }, `(1, 2)`],
     })
 
     expect(
       (parseWithExpressionTransform(`{{ new Error() }}`) as InterpolationNode)
-        .content
+        .content,
     ).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
-      children: ['new ', { content: 'Error' }, '()']
+      children: ['new ', { content: 'Error' }, '()'],
     })
   })
 
   test('should not prefix reserved literals', () => {
     function assert(exp: string) {
       const node = parseWithExpressionTransform(
-        `{{ ${exp} }}`
+        `{{ ${exp} }}`,
       ) as InterpolationNode
       expect(node.content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: exp
+        content: exp,
       })
     }
     assert(`true`)
@@ -189,7 +189,7 @@ describe('compiler: expression transform', () => {
 
   test('should not prefix id of a function declaration', () => {
     const node = parseWithExpressionTransform(
-      `{{ function foo() { return bar } }}`
+      `{{ function foo() { return bar } }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -198,14 +198,14 @@ describe('compiler: expression transform', () => {
         { content: `foo` },
         `() { return `,
         { content: `_ctx.bar` },
-        ` }`
-      ]
+        ` }`,
+      ],
     })
   })
 
   test('should not prefix params of a function expression', () => {
     const node = parseWithExpressionTransform(
-      `{{ foo => foo + bar }}`
+      `{{ foo => foo + bar }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -214,14 +214,14 @@ describe('compiler: expression transform', () => {
         ` => `,
         { content: `foo` },
         ` + `,
-        { content: `_ctx.bar` }
-      ]
+        { content: `_ctx.bar` },
+      ],
     })
   })
 
   test('should prefix default value of a function expression param', () => {
     const node = parseWithExpressionTransform(
-      `{{ (foo = baz) => foo + bar }}`
+      `{{ (foo = baz) => foo + bar }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -233,14 +233,14 @@ describe('compiler: expression transform', () => {
         `) => `,
         { content: `foo` },
         ` + `,
-        { content: `_ctx.bar` }
-      ]
+        { content: `_ctx.bar` },
+      ],
     })
   })
 
   test('should not prefix function param destructuring', () => {
     const node = parseWithExpressionTransform(
-      `{{ ({ foo }) => foo + bar }}`
+      `{{ ({ foo }) => foo + bar }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -250,14 +250,14 @@ describe('compiler: expression transform', () => {
         ` }) => `,
         { content: `foo` },
         ` + `,
-        { content: `_ctx.bar` }
-      ]
+        { content: `_ctx.bar` },
+      ],
     })
   })
 
   test('function params should not affect out of scope identifiers', () => {
     const node = parseWithExpressionTransform(
-      `{{ { a: foo => foo, b: foo } }}`
+      `{{ { a: foo => foo, b: foo } }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -268,14 +268,14 @@ describe('compiler: expression transform', () => {
         { content: `foo` },
         `, b: `,
         { content: `_ctx.foo` },
-        ` }`
-      ]
+        ` }`,
+      ],
     })
   })
 
   test('should prefix default value of function param destructuring', () => {
     const node = parseWithExpressionTransform(
-      `{{ ({ foo = bar }) => foo + bar }}`
+      `{{ ({ foo = bar }) => foo + bar }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -287,13 +287,13 @@ describe('compiler: expression transform', () => {
         ` }) => `,
         { content: `foo` },
         ` + `,
-        { content: `_ctx.bar` }
-      ]
+        { content: `_ctx.bar` },
+      ],
     })
   })
   test('should not prefix an object property key', () => {
     const node = parseWithExpressionTransform(
-      `{{ { foo() { baz() }, value: bar } }}`
+      `{{ { foo() { baz() }, value: bar } }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -302,24 +302,24 @@ describe('compiler: expression transform', () => {
         { content: `_ctx.baz` },
         `() }, value: `,
         { content: `_ctx.bar` },
-        ` }`
-      ]
+        ` }`,
+      ],
     })
   })
 
   test('should not duplicate object key with same name as value', () => {
     const node = parseWithExpressionTransform(
-      `{{ { foo: foo } }}`
+      `{{ { foo: foo } }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
-      children: [`{ foo: `, { content: `_ctx.foo` }, ` }`]
+      children: [`{ foo: `, { content: `_ctx.foo` }, ` }`],
     })
   })
 
   test('should prefix a computed object property key', () => {
     const node = parseWithExpressionTransform(
-      `{{ { [foo]: bar } }}`
+      `{{ { [foo]: bar } }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -328,24 +328,24 @@ describe('compiler: expression transform', () => {
         { content: `_ctx.foo` },
         `]: `,
         { content: `_ctx.bar` },
-        ` }`
-      ]
+        ` }`,
+      ],
     })
   })
 
   test('should prefix object property shorthand value', () => {
     const node = parseWithExpressionTransform(
-      `{{ { foo } }}`
+      `{{ { foo } }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
-      children: [`{ foo: `, { content: `_ctx.foo` }, ` }`]
+      children: [`{ foo: `, { content: `_ctx.foo` }, ` }`],
     })
   })
 
   test('should not prefix id in a member expression', () => {
     const node = parseWithExpressionTransform(
-      `{{ foo.bar.baz }}`
+      `{{ foo.bar.baz }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -354,14 +354,14 @@ describe('compiler: expression transform', () => {
         `.`,
         { content: `bar` },
         `.`,
-        { content: `baz` }
-      ]
+        { content: `baz` },
+      ],
     })
   })
 
   test('should prefix computed id in a member expression', () => {
     const node = parseWithExpressionTransform(
-      `{{ foo[bar][baz] }}`
+      `{{ foo[bar][baz] }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -371,8 +371,8 @@ describe('compiler: expression transform', () => {
         { content: `_ctx.bar` },
         `][`,
         { content: '_ctx.baz' },
-        `]`
-      ]
+        `]`,
+      ],
     })
   })
 
@@ -380,23 +380,23 @@ describe('compiler: expression transform', () => {
     const onError = vi.fn()
     parseWithExpressionTransform(`{{ a( }}`, { onError })
     expect(onError.mock.calls[0][0].message).toMatch(
-      `Error parsing JavaScript expression: Unexpected token`
+      `Error parsing JavaScript expression: Unexpected token`,
     )
   })
 
   test('should prefix in assignment', () => {
     const node = parseWithExpressionTransform(
-      `{{ x = 1 }}`
+      `{{ x = 1 }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
-      children: [{ content: `_ctx.x` }, ` = 1`]
+      children: [{ content: `_ctx.x` }, ` = 1`],
     })
   })
 
   test('should prefix in assignment pattern', () => {
     const node = parseWithExpressionTransform(
-      `{{ { x, y: [z] } = obj }}`
+      `{{ { x, y: [z] } = obj }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
       type: NodeTypes.COMPOUND_EXPRESSION,
@@ -406,47 +406,47 @@ describe('compiler: expression transform', () => {
         `, y: [`,
         { content: `_ctx.z` },
         `] } = `,
-        { content: `_ctx.obj` }
-      ]
+        { content: `_ctx.obj` },
+      ],
     })
   })
 
   // #8295
   test('should treat floating point number literals as constant', () => {
     const node = parseWithExpressionTransform(
-      `{{ [1, 2.1] }}`
+      `{{ [1, 2.1] }}`,
     ) as InterpolationNode
     expect(node.content).toMatchObject({
-      constType: ConstantTypes.CAN_STRINGIFY
+      constType: ConstantTypes.CAN_STRINGIFY,
     })
   })
 
   describe('ES Proposals support', () => {
     test('bigInt', () => {
       const node = parseWithExpressionTransform(
-        `{{ 13000n }}`
+        `{{ 13000n }}`,
       ) as InterpolationNode
       expect(node.content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
         content: `13000n`,
         isStatic: false,
-        constType: ConstantTypes.CAN_STRINGIFY
+        constType: ConstantTypes.CAN_STRINGIFY,
       })
     })
 
     test('nullish coalescing', () => {
       const node = parseWithExpressionTransform(
-        `{{ a ?? b }}`
+        `{{ a ?? b }}`,
       ) as InterpolationNode
       expect(node.content).toMatchObject({
         type: NodeTypes.COMPOUND_EXPRESSION,
-        children: [{ content: `_ctx.a` }, ` ?? `, { content: `_ctx.b` }]
+        children: [{ content: `_ctx.a` }, ` ?? `, { content: `_ctx.b` }],
       })
     })
 
     test('optional chaining', () => {
       const node = parseWithExpressionTransform(
-        `{{ a?.b?.c }}`
+        `{{ a?.b?.c }}`,
       ) as InterpolationNode
       expect(node.content).toMatchObject({
         type: NodeTypes.COMPOUND_EXPRESSION,
@@ -455,8 +455,8 @@ describe('compiler: expression transform', () => {
           `?.`,
           { content: `b` },
           `?.`,
-          { content: `c` }
-        ]
+          { content: `c` },
+        ],
       })
     })
 
@@ -467,14 +467,18 @@ describe('compiler: expression transform', () => {
           [
             'pipelineOperator',
             {
-              proposal: 'minimal'
-            }
-          ]
-        ]
+              proposal: 'minimal',
+            },
+          ],
+        ],
       }) as InterpolationNode
       expect(node.content).toMatchObject({
         type: NodeTypes.COMPOUND_EXPRESSION,
-        children: [{ content: `_ctx.a` }, ` |> `, { content: `_ctx.uppercase` }]
+        children: [
+          { content: `_ctx.a` },
+          ` |> `,
+          { content: `_ctx.uppercase` },
+        ],
       })
     })
   })
@@ -488,23 +492,23 @@ describe('compiler: expression transform', () => {
       options: BindingTypes.OPTIONS,
       reactive: BindingTypes.SETUP_REACTIVE_CONST,
       literal: BindingTypes.LITERAL_CONST,
-      isNaN: BindingTypes.SETUP_REF
+      isNaN: BindingTypes.SETUP_REF,
     }
 
     function compileWithBindingMetadata(
       template: string,
-      options?: CompilerOptions
+      options?: CompilerOptions,
     ) {
       return baseCompile(template, {
         prefixIdentifiers: true,
         bindingMetadata,
-        ...options
+        ...options,
       })
     }
 
     test('non-inline mode', () => {
       const { code } = compileWithBindingMetadata(
-        `<div>{{ props }} {{ setup }} {{ data }} {{ options }} {{ isNaN }}</div>`
+        `<div>{{ props }} {{ setup }} {{ data }} {{ options }} {{ isNaN }}</div>`,
       )
       expect(code).toMatch(`$props.props`)
       expect(code).toMatch(`$setup.setup`)
@@ -521,7 +525,7 @@ describe('compiler: expression transform', () => {
           for (const x in list) {
             log(x)
           }
-        }"/>`
+        }"/>`,
       )
       expect(code).not.toMatch(`_ctx.x`)
       expect(code).toMatchSnapshot()
@@ -533,7 +537,7 @@ describe('compiler: expression transform', () => {
           for (const x of list) {
             log(x)
           }
-        }"/>`
+        }"/>`,
       )
       expect(code).not.toMatch(`_ctx.x`)
       expect(code).toMatchSnapshot()
@@ -545,7 +549,7 @@ describe('compiler: expression transform', () => {
           for (let i = 0; i < list.length; i++) {
             log(i)
           }
-        }"/>`
+        }"/>`,
       )
       expect(code).not.toMatch(`_ctx.i`)
       expect(code).toMatchSnapshot()
@@ -554,7 +558,7 @@ describe('compiler: expression transform', () => {
     test('inline mode', () => {
       const { code } = compileWithBindingMetadata(
         `<div>{{ props }} {{ setup }} {{ setupConst }} {{ data }} {{ options }} {{ isNaN }}</div>`,
-        { inline: true }
+        { inline: true },
       )
       expect(code).toMatch(`__props.props`)
       expect(code).toMatch(`_unref(setup)`)
@@ -567,12 +571,12 @@ describe('compiler: expression transform', () => {
 
     test('literal const handling', () => {
       const { code } = compileWithBindingMetadata(`<div>{{ literal }}</div>`, {
-        inline: true
+        inline: true,
       })
       expect(code).toMatch(`toDisplayString(literal)`)
       // #7973 should skip patch for literal const
       expect(code).not.toMatch(
-        `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
+        `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`,
       )
     })
 
@@ -581,17 +585,17 @@ describe('compiler: expression transform', () => {
       expect(code).toMatch(`toDisplayString($setup.literal)`)
       // #7973 should skip patch for literal const
       expect(code).not.toMatch(
-        `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
+        `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`,
       )
     })
 
     test('reactive const handling', () => {
       const { code } = compileWithBindingMetadata(`<div>{{ reactive }}</div>`, {
-        inline: true
+        inline: true,
       })
       // #7973 should not skip patch for reactive const
       expect(code).toMatch(
-        `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
+        `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`,
       )
     })
   })
index f9fa9d211723c44c3826fac5fa7912258bff7dc4..f8809ab6a7bea83ba1b02f132383fd0826a16d00 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  CompilerOptions,
+  type CompilerOptions,
+  type ElementNode,
+  ErrorCodes,
+  NodeTypes,
   baseParse as parse,
   transform,
-  ElementNode,
-  NodeTypes,
-  ErrorCodes
 } from '../../src'
 import { transformElement } from '../../src/transforms/transformElement'
 import { transformOn } from '../../src/transforms/vOn'
@@ -19,13 +19,13 @@ function parseWithSlots(template: string, options: CompilerOptions = {}) {
     nodeTransforms: [
       ...(options.prefixIdentifiers ? [transformExpression] : []),
       transformSlotOutlet,
-      transformElement
+      transformElement,
     ],
     directiveTransforms: {
       on: transformOn,
-      bind: transformBind
+      bind: transformBind,
     },
-    ...options
+    ...options,
   })
   return ast
 }
@@ -36,7 +36,7 @@ describe('compiler: transform <slot> outlets', () => {
     expect((ast.children[0] as ElementNode).codegenNode).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: RENDER_SLOT,
-      arguments: [`$slots`, `"default"`]
+      arguments: [`$slots`, `"default"`],
     })
   })
 
@@ -45,7 +45,7 @@ describe('compiler: transform <slot> outlets', () => {
     expect((ast.children[0] as ElementNode).codegenNode).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: RENDER_SLOT,
-      arguments: [`$slots`, `"foo"`]
+      arguments: [`$slots`, `"foo"`],
     })
   })
 
@@ -59,15 +59,15 @@ describe('compiler: transform <slot> outlets', () => {
         {
           type: NodeTypes.SIMPLE_EXPRESSION,
           content: `foo`,
-          isStatic: false
-        }
-      ]
+          isStatic: false,
+        },
+      ],
     })
   })
 
   test('dynamically named slot outlet w/ prefixIdentifiers: true', () => {
     const ast = parseWithSlots(`<slot :name="foo + bar" />`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((ast.children[0] as ElementNode).codegenNode).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
@@ -80,23 +80,23 @@ describe('compiler: transform <slot> outlets', () => {
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: `_ctx.foo`,
-              isStatic: false
+              isStatic: false,
             },
             ` + `,
             {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: `_ctx.bar`,
-              isStatic: false
-            }
-          ]
-        }
-      ]
+              isStatic: false,
+            },
+          ],
+        },
+      ],
     })
   })
 
   test('default slot outlet with props', () => {
     const ast = parseWithSlots(
-      `<slot foo="bar" :baz="qux" :foo-bar="foo-bar" />`
+      `<slot foo="bar" :baz="qux" :foo-bar="foo-bar" />`,
     )
     expect((ast.children[0] as ElementNode).codegenNode).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
@@ -110,36 +110,36 @@ describe('compiler: transform <slot> outlets', () => {
             {
               key: {
                 content: `foo`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `bar`,
-                isStatic: true
-              }
+                isStatic: true,
+              },
             },
             {
               key: {
                 content: `baz`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `qux`,
-                isStatic: false
-              }
+                isStatic: false,
+              },
             },
             {
               key: {
                 content: `fooBar`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `foo-bar`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -158,26 +158,26 @@ describe('compiler: transform <slot> outlets', () => {
             {
               key: {
                 content: `foo`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `bar`,
-                isStatic: true
-              }
+                isStatic: true,
+              },
             },
             {
               key: {
                 content: `baz`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `qux`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -196,26 +196,26 @@ describe('compiler: transform <slot> outlets', () => {
             {
               key: {
                 content: `foo`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `bar`,
-                isStatic: true
-              }
+                isStatic: true,
+              },
             },
             {
               key: {
                 content: `baz`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `qux`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -234,11 +234,11 @@ describe('compiler: transform <slot> outlets', () => {
           returns: [
             {
               type: NodeTypes.ELEMENT,
-              tag: `div`
-            }
-          ]
-        }
-      ]
+              tag: `div`,
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -257,11 +257,11 @@ describe('compiler: transform <slot> outlets', () => {
           returns: [
             {
               type: NodeTypes.ELEMENT,
-              tag: `div`
-            }
-          ]
-        }
-      ]
+              tag: `div`,
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -279,14 +279,14 @@ describe('compiler: transform <slot> outlets', () => {
             {
               key: {
                 content: `foo`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `bar`,
-                isStatic: false
-              }
-            }
-          ]
+                isStatic: false,
+              },
+            },
+          ],
         },
         {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
@@ -294,11 +294,11 @@ describe('compiler: transform <slot> outlets', () => {
           returns: [
             {
               type: NodeTypes.ELEMENT,
-              tag: `div`
-            }
-          ]
-        }
-      ]
+              tag: `div`,
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -316,14 +316,14 @@ describe('compiler: transform <slot> outlets', () => {
             {
               key: {
                 content: `foo`,
-                isStatic: true
+                isStatic: true,
               },
               value: {
                 content: `bar`,
-                isStatic: false
-              }
-            }
-          ]
+                isStatic: false,
+              },
+            },
+          ],
         },
         {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
@@ -331,11 +331,11 @@ describe('compiler: transform <slot> outlets', () => {
           returns: [
             {
               type: NodeTypes.ELEMENT,
-              tag: `div`
-            }
-          ]
-        }
-      ]
+              tag: `div`,
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -344,11 +344,11 @@ describe('compiler: transform <slot> outlets', () => {
     expect((ast.children[0] as ElementNode).codegenNode).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: RENDER_SLOT,
-      arguments: [`$slots`, `"default"`, `{}`, `undefined`, `true`]
+      arguments: [`$slots`, `"default"`, `{}`, `undefined`, `true`],
     })
     const fallback = parseWithSlots(`<slot>fallback</slot>`, {
       slotted: false,
-      scopeId: 'foo'
+      scopeId: 'foo',
     })
 
     const child = {
@@ -357,14 +357,14 @@ describe('compiler: transform <slot> outlets', () => {
       returns: [
         {
           type: NodeTypes.TEXT,
-          content: `fallback`
-        }
-      ]
+          content: `fallback`,
+        },
+      ],
     }
     expect((fallback.children[0] as ElementNode).codegenNode).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: RENDER_SLOT,
-      arguments: [`$slots`, `"default"`, `{}`, child, `true`]
+      arguments: [`$slots`, `"default"`, `{}`, child, `true`],
     })
   })
 
@@ -379,14 +379,14 @@ describe('compiler: transform <slot> outlets', () => {
         start: {
           offset: index,
           line: 1,
-          column: index + 1
+          column: index + 1,
         },
         end: {
           offset: index + 5,
           line: 1,
-          column: index + 6
-        }
-      }
+          column: index + 6,
+        },
+      },
     })
   })
 })
index 6e321d145e5bd156f799cdc62ca57a39e9a80726..1a6d6916a73cafdf566216256457ca1f31b23f09 100644 (file)
@@ -1,11 +1,11 @@
 import {
-  CompilerOptions,
-  baseParse as parse,
-  transform,
+  type CompilerOptions,
+  type ElementNode,
+  type ForNode,
   NodeTypes,
   generate,
-  ForNode,
-  ElementNode
+  baseParse as parse,
+  transform,
 } from '../../src'
 import { transformFor } from '../../src/transforms/vFor'
 import { transformText } from '../../src/transforms/transformText'
@@ -22,9 +22,9 @@ function transformWithTextOpt(template: string, options: CompilerOptions = {}) {
       transformFor,
       ...(options.prefixIdentifiers ? [transformExpression] : []),
       transformElement,
-      transformText
+      transformText,
     ],
-    ...options
+    ...options,
   })
   return ast
 }
@@ -35,8 +35,8 @@ describe('compiler: transform text', () => {
     expect(root.children[0]).toMatchObject({
       type: NodeTypes.INTERPOLATION,
       content: {
-        content: `foo`
-      }
+        content: `foo`,
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -51,8 +51,8 @@ describe('compiler: transform text', () => {
         ` + `,
         { type: NodeTypes.TEXT, content: ` bar ` },
         ` + `,
-        { type: NodeTypes.INTERPOLATION, content: { content: `baz` } }
-      ]
+        { type: NodeTypes.INTERPOLATION, content: { content: `baz` } },
+      ],
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -75,12 +75,12 @@ describe('compiler: transform text', () => {
               ` + `,
               { type: NodeTypes.TEXT, content: ` bar ` },
               ` + `,
-              { type: NodeTypes.INTERPOLATION, content: { content: `baz` } }
-            ]
+              { type: NodeTypes.INTERPOLATION, content: { content: `baz` } },
+            ],
           },
-          genFlagText(PatchFlags.TEXT)
-        ]
-      }
+          genFlagText(PatchFlags.TEXT),
+        ],
+      },
     })
     expect(root.children[2].type).toBe(NodeTypes.ELEMENT)
     expect(generate(root).code).toMatchSnapshot()
@@ -99,11 +99,11 @@ describe('compiler: transform text', () => {
         arguments: [
           {
             type: NodeTypes.TEXT,
-            content: `hello`
-          }
+            content: `hello`,
+          },
           // should have no flag
-        ]
-      }
+        ],
+      },
     })
     expect(root.children[2].type).toBe(NodeTypes.ELEMENT)
     expect(generate(root).code).toMatchSnapshot()
@@ -111,7 +111,7 @@ describe('compiler: transform text', () => {
 
   test('consecutive text mixed with elements', () => {
     const root = transformWithTextOpt(
-      `<div/>{{ foo }} bar {{ baz }}<div/>hello<div/>`
+      `<div/>{{ foo }} bar {{ baz }}<div/>hello<div/>`,
     )
     expect(root.children.length).toBe(5)
     expect(root.children[0].type).toBe(NodeTypes.ELEMENT)
@@ -128,12 +128,12 @@ describe('compiler: transform text', () => {
               ` + `,
               { type: NodeTypes.TEXT, content: ` bar ` },
               ` + `,
-              { type: NodeTypes.INTERPOLATION, content: { content: `baz` } }
-            ]
+              { type: NodeTypes.INTERPOLATION, content: { content: `baz` } },
+            ],
           },
-          genFlagText(PatchFlags.TEXT)
-        ]
-      }
+          genFlagText(PatchFlags.TEXT),
+        ],
+      },
     })
     expect(root.children[2].type).toBe(NodeTypes.ELEMENT)
     expect(root.children[3]).toMatchObject({
@@ -144,10 +144,10 @@ describe('compiler: transform text', () => {
         arguments: [
           {
             type: NodeTypes.TEXT,
-            content: `hello`
-          }
-        ]
-      }
+            content: `hello`,
+          },
+        ],
+      },
     })
     expect(root.children[4].type).toBe(NodeTypes.ELEMENT)
     expect(generate(root).code).toMatchSnapshot()
@@ -155,21 +155,21 @@ describe('compiler: transform text', () => {
 
   test('<template v-for>', () => {
     const root = transformWithTextOpt(
-      `<template v-for="i in list">foo</template>`
+      `<template v-for="i in list">foo</template>`,
     )
     expect(root.children[0].type).toBe(NodeTypes.FOR)
     const forNode = root.children[0] as ForNode
     // should convert template v-for text children because they are inside
     // fragments
     expect(forNode.children[0]).toMatchObject({
-      type: NodeTypes.TEXT_CALL
+      type: NodeTypes.TEXT_CALL,
     })
     expect(generate(root).code).toMatchSnapshot()
   })
 
   test('with prefixIdentifiers: true', () => {
     const root = transformWithTextOpt(`{{ foo }} bar {{ baz + qux }}`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(root.children.length).toBe(1)
     expect(root.children[0]).toMatchObject({
@@ -183,15 +183,15 @@ describe('compiler: transform text', () => {
           type: NodeTypes.INTERPOLATION,
           content: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [{ content: `_ctx.baz` }, ` + `, { content: `_ctx.qux` }]
-          }
-        }
-      ]
+            children: [{ content: `_ctx.baz` }, ` + `, { content: `_ctx.qux` }],
+          },
+        },
+      ],
     })
     expect(
       generate(root, {
-        prefixIdentifiers: true
-      }).code
+        prefixIdentifiers: true,
+      }).code,
     ).toMatchSnapshot()
   })
 
@@ -210,12 +210,12 @@ describe('compiler: transform text', () => {
             type: NodeTypes.INTERPOLATION,
             content: {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: 'foo'
-            }
+              content: 'foo',
+            },
           },
-          genFlagText(PatchFlags.TEXT)
-        ]
-      }
+          genFlagText(PatchFlags.TEXT),
+        ],
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
index 0ae247c2f5012806be6b1ada88f6de69623f14bf..84b9ee8ca47c8ce1bd0017f7ad91627a097ba222 100644 (file)
@@ -1,37 +1,37 @@
 import {
-  baseParse as parse,
-  transform,
-  ElementNode,
-  ObjectExpression,
-  CompilerOptions,
+  type CallExpression,
+  type CompilerOptions,
+  type ElementNode,
   ErrorCodes,
-  VNodeCall,
   NodeTypes,
-  CallExpression
+  type ObjectExpression,
+  type VNodeCall,
+  baseParse as parse,
+  transform,
 } from '../../src'
 import { transformBind } from '../../src/transforms/vBind'
 import { transformElement } from '../../src/transforms/transformElement'
 import {
   CAMELIZE,
+  NORMALIZE_PROPS,
   helperNameMap,
-  NORMALIZE_PROPS
 } from '../../src/runtimeHelpers'
 import { transformExpression } from '../../src/transforms/transformExpression'
 
 function parseWithVBind(
   template: string,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ): ElementNode {
   const ast = parse(template)
   transform(ast, {
     nodeTransforms: [
       ...(options.prefixIdentifiers ? [transformExpression] : []),
-      transformElement
+      transformElement,
     ],
     directiveTransforms: {
-      bind: transformBind
+      bind: transformBind,
     },
-    ...options
+    ...options,
   })
   return ast.children[0] as ElementNode
 }
@@ -47,13 +47,13 @@ describe('compiler: transform v-bind', () => {
         loc: {
           start: {
             line: 1,
-            column: 13
+            column: 13,
           },
           end: {
             line: 1,
-            column: 15
-          }
-        }
+            column: 15,
+          },
+        },
       },
       value: {
         content: `id`,
@@ -61,14 +61,14 @@ describe('compiler: transform v-bind', () => {
         loc: {
           start: {
             line: 1,
-            column: 17
+            column: 17,
           },
           end: {
             line: 1,
-            column: 19
-          }
-        }
-      }
+            column: 19,
+          },
+        },
+      },
     })
   })
 
@@ -81,17 +81,17 @@ describe('compiler: transform v-bind', () => {
         isStatic: true,
         loc: {
           start: { line: 1, column: 13, offset: 12 },
-          end: { line: 1, column: 15, offset: 14 }
-        }
+          end: { line: 1, column: 15, offset: 14 },
+        },
       },
       value: {
         content: `id`,
         isStatic: false,
         loc: {
           start: { line: 1, column: 13, offset: 12 },
-          end: { line: 1, column: 15, offset: 14 }
-        }
-      }
+          end: { line: 1, column: 15, offset: 14 },
+        },
+      },
     })
   })
 
@@ -101,12 +101,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `id`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `id`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -123,16 +123,16 @@ describe('compiler: transform v-bind', () => {
             {
               key: {
                 content: `id || ""`,
-                isStatic: false
+                isStatic: false,
               },
               value: {
                 content: `id`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -145,23 +145,23 @@ describe('compiler: transform v-bind', () => {
       loc: {
         start: {
           line: 1,
-          column: 6
+          column: 6,
         },
         end: {
           line: 1,
-          column: 19
-        }
-      }
+          column: 19,
+        },
+      },
     })
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `arg`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: ``,
-        isStatic: true
-      }
+        isStatic: true,
+      },
     })
   })
 
@@ -171,12 +171,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `fooBar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `id`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -186,12 +186,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `fooBar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `fooBar`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -208,22 +208,22 @@ describe('compiler: transform v-bind', () => {
             {
               key: {
                 content: `_${helperNameMap[CAMELIZE]}(foo || "")`,
-                isStatic: false
+                isStatic: false,
               },
               value: {
                 content: `id`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
   test('.camel modifier w/ dynamic arg + prefixIdentifiers', () => {
     const node = parseWithVBind(`<div v-bind:[foo(bar)].camel="id"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     const props = (node.codegenNode as VNodeCall).props as CallExpression
     expect(props).toMatchObject({
@@ -243,17 +243,17 @@ describe('compiler: transform v-bind', () => {
                   { content: `_ctx.bar` },
                   `)`,
                   `) || ""`,
-                  `)`
-                ]
+                  `)`,
+                ],
               },
               value: {
                 content: `_ctx.id`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -263,12 +263,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `.fooBar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `id`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -278,12 +278,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `.fooBar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `fooBar`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -300,22 +300,22 @@ describe('compiler: transform v-bind', () => {
             {
               key: {
                 content: '`.${fooBar || ""}`',
-                isStatic: false
+                isStatic: false,
               },
               value: {
                 content: `id`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
   test('.prop modifier w/ dynamic arg + prefixIdentifiers', () => {
     const node = parseWithVBind(`<div v-bind:[foo(bar)].prop="id"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     const props = (node.codegenNode as VNodeCall).props as CallExpression
     expect(props).toMatchObject({
@@ -335,17 +335,17 @@ describe('compiler: transform v-bind', () => {
                   { content: `_ctx.bar` },
                   `)`,
                   `) || ""`,
-                  `)`
-                ]
+                  `)`,
+                ],
               },
               value: {
                 content: `_ctx.id`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
   })
 
@@ -355,12 +355,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `.fooBar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `id`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -370,12 +370,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `.fooBar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `fooBar`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -385,12 +385,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `^foo-bar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `id`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -400,12 +400,12 @@ describe('compiler: transform v-bind', () => {
     expect(props.properties[0]).toMatchObject({
       key: {
         content: `^foo-bar`,
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: `fooBar`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 })
index c5132b68dc8942a29df5955001ca163143b909cc..fb3d7dc7fb89b467abed3fa67e0eae6f938ead8b 100644 (file)
@@ -7,23 +7,23 @@ import { transformElement } from '../../src/transforms/transformElement'
 import { transformSlotOutlet } from '../../src/transforms/transformSlotOutlet'
 import { transformExpression } from '../../src/transforms/transformExpression'
 import {
-  ForNode,
+  ConstantTypes,
+  type ElementNode,
+  type ForCodegenNode,
+  type ForNode,
+  type InterpolationNode,
   NodeTypes,
-  SimpleExpressionNode,
-  ElementNode,
-  InterpolationNode,
-  ForCodegenNode,
-  ConstantTypes
+  type SimpleExpressionNode,
 } from '../../src/ast'
 import { ErrorCodes } from '../../src/errors'
-import { CompilerOptions, generate } from '../../src'
+import { type CompilerOptions, generate } from '../../src'
 import { FRAGMENT, RENDER_LIST, RENDER_SLOT } from '../../src/runtimeHelpers'
 import { PatchFlags } from '@vue/shared'
 import { createObjectMatcher, genFlagText } from '../testUtils'
 
 function parseWithForTransform(
   template: string,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ) {
   const ast = parse(template, options)
   transform(ast, {
@@ -32,16 +32,16 @@ function parseWithForTransform(
       transformFor,
       ...(options.prefixIdentifiers ? [transformExpression] : []),
       transformSlotOutlet,
-      transformElement
+      transformElement,
     ],
     directiveTransforms: {
-      bind: transformBind
+      bind: transformBind,
     },
-    ...options
+    ...options,
   })
   return {
     root: ast,
-    node: ast.children[0] as ForNode & { codegenNode: ForCodegenNode }
+    node: ast.children[0] as ForNode & { codegenNode: ForCodegenNode },
   }
 }
 
@@ -49,7 +49,7 @@ describe('compiler: v-for', () => {
   describe('transform', () => {
     test('number expression', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="index in 5" />'
+        '<span v-for="index in 5" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).toBeUndefined()
@@ -59,7 +59,7 @@ describe('compiler: v-for', () => {
 
     test('value', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="(item) in items" />'
+        '<span v-for="(item) in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).toBeUndefined()
@@ -69,31 +69,31 @@ describe('compiler: v-for', () => {
 
     test('object de-structured value', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="({ id, value }) in items" />'
+        '<span v-for="({ id, value }) in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).toBeUndefined()
       expect((forNode.valueAlias as SimpleExpressionNode).content).toBe(
-        '{ id, value }'
+        '{ id, value }',
       )
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
     })
 
     test('array de-structured value', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="([ id, value ]) in items" />'
+        '<span v-for="([ id, value ]) in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).toBeUndefined()
       expect((forNode.valueAlias as SimpleExpressionNode).content).toBe(
-        '[ id, value ]'
+        '[ id, value ]',
       )
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
     })
 
     test('value and key', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="(item, key) in items" />'
+        '<span v-for="(item, key) in items" />',
       )
       expect(forNode.keyAlias).not.toBeUndefined()
       expect((forNode.keyAlias as SimpleExpressionNode).content).toBe('key')
@@ -104,13 +104,13 @@ describe('compiler: v-for', () => {
 
     test('value, key and index', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="(value, key, index) in items" />'
+        '<span v-for="(value, key, index) in items" />',
       )
       expect(forNode.keyAlias).not.toBeUndefined()
       expect((forNode.keyAlias as SimpleExpressionNode).content).toBe('key')
       expect(forNode.objectIndexAlias).not.toBeUndefined()
       expect((forNode.objectIndexAlias as SimpleExpressionNode).content).toBe(
-        'index'
+        'index',
       )
       expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('value')
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
@@ -118,12 +118,12 @@ describe('compiler: v-for', () => {
 
     test('skipped key', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="(value,,index) in items" />'
+        '<span v-for="(value,,index) in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).not.toBeUndefined()
       expect((forNode.objectIndexAlias as SimpleExpressionNode).content).toBe(
-        'index'
+        'index',
       )
       expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('value')
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
@@ -131,12 +131,12 @@ describe('compiler: v-for', () => {
 
     test('skipped value and key', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="(,,index) in items" />'
+        '<span v-for="(,,index) in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).not.toBeUndefined()
       expect((forNode.objectIndexAlias as SimpleExpressionNode).content).toBe(
-        'index'
+        'index',
       )
       expect(forNode.valueAlias).toBeUndefined()
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
@@ -144,7 +144,7 @@ describe('compiler: v-for', () => {
 
     test('unbracketed value', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="item in items" />'
+        '<span v-for="item in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).toBeUndefined()
@@ -154,7 +154,7 @@ describe('compiler: v-for', () => {
 
     test('unbracketed value and key', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="item, key in items" />'
+        '<span v-for="item, key in items" />',
       )
       expect(forNode.keyAlias).not.toBeUndefined()
       expect((forNode.keyAlias as SimpleExpressionNode).content).toBe('key')
@@ -165,13 +165,13 @@ describe('compiler: v-for', () => {
 
     test('unbracketed value, key and index', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="value, key, index in items" />'
+        '<span v-for="value, key, index in items" />',
       )
       expect(forNode.keyAlias).not.toBeUndefined()
       expect((forNode.keyAlias as SimpleExpressionNode).content).toBe('key')
       expect(forNode.objectIndexAlias).not.toBeUndefined()
       expect((forNode.objectIndexAlias as SimpleExpressionNode).content).toBe(
-        'index'
+        'index',
       )
       expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('value')
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
@@ -179,12 +179,12 @@ describe('compiler: v-for', () => {
 
     test('unbracketed skipped key', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for="value, , index in items" />'
+        '<span v-for="value, , index in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).not.toBeUndefined()
       expect((forNode.objectIndexAlias as SimpleExpressionNode).content).toBe(
-        'index'
+        'index',
       )
       expect((forNode.valueAlias as SimpleExpressionNode).content).toBe('value')
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
@@ -192,12 +192,12 @@ describe('compiler: v-for', () => {
 
     test('unbracketed skipped value and key', () => {
       const { node: forNode } = parseWithForTransform(
-        '<span v-for=", , index in items" />'
+        '<span v-for=", , index in items" />',
       )
       expect(forNode.keyAlias).toBeUndefined()
       expect(forNode.objectIndexAlias).not.toBeUndefined()
       expect((forNode.objectIndexAlias as SimpleExpressionNode).content).toBe(
-        'index'
+        'index',
       )
       expect(forNode.valueAlias).toBeUndefined()
       expect((forNode.source as SimpleExpressionNode).content).toBe('items')
@@ -212,8 +212,8 @@ describe('compiler: v-for', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_FOR_NO_EXPRESSION
-        })
+          code: ErrorCodes.X_V_FOR_NO_EXPRESSION,
+        }),
       )
     })
 
@@ -224,8 +224,8 @@ describe('compiler: v-for', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
-        })
+          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION,
+        }),
       )
     })
 
@@ -236,8 +236,8 @@ describe('compiler: v-for', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
-        })
+          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION,
+        }),
       )
     })
 
@@ -248,8 +248,8 @@ describe('compiler: v-for', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
-        })
+          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION,
+        }),
       )
     })
 
@@ -260,8 +260,8 @@ describe('compiler: v-for', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION
-        })
+          code: ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION,
+        }),
       )
     })
 
@@ -272,14 +272,14 @@ describe('compiler: v-for', () => {
       <template v-for="item in items">
         <div :key="item.id"/>
       </template>`,
-        { onError }
+        { onError },
       )
 
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT
-        })
+          code: ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT,
+        }),
       )
 
       // should not warn on nested v-for keys
@@ -288,7 +288,7 @@ describe('compiler: v-for', () => {
       <template v-for="item in items">
         <div v-for="c in item.children" :key="c.id"/>
       </template>`,
-        { onError }
+        { onError },
       )
       expect(onError).toHaveBeenCalledTimes(1)
     })
@@ -315,7 +315,7 @@ describe('compiler: v-for', () => {
       expect(forNode.source.loc.start.column).toBe(itemsOffset + 1)
       expect(forNode.source.loc.end.line).toBe(1)
       expect(forNode.source.loc.end.column).toBe(
-        itemsOffset + 1 + `items`.length
+        itemsOffset + 1 + `items`.length,
       )
     })
 
@@ -339,7 +339,7 @@ describe('compiler: v-for', () => {
       expect(forNode.source.loc.start.column).toBe(itemsOffset + 1)
       expect(forNode.source.loc.end.line).toBe(1)
       expect(forNode.source.loc.end.column).toBe(
-        itemsOffset + 1 + `items`.length
+        itemsOffset + 1 + `items`.length,
       )
     })
 
@@ -363,7 +363,7 @@ describe('compiler: v-for', () => {
       expect(forNode.source.loc.start.column).toBe(itemsOffset + 1)
       expect(forNode.source.loc.end.line).toBe(1)
       expect(forNode.source.loc.end.column).toBe(
-        itemsOffset + 1 + `items`.length
+        itemsOffset + 1 + `items`.length,
       )
     })
 
@@ -405,7 +405,7 @@ describe('compiler: v-for', () => {
       expect(forNode.source.loc.start.column).toBe(itemsOffset + 1)
       expect(forNode.source.loc.end.line).toBe(1)
       expect(forNode.source.loc.end.column).toBe(
-        itemsOffset + 1 + `items`.length
+        itemsOffset + 1 + `items`.length,
       )
     })
 
@@ -438,7 +438,7 @@ describe('compiler: v-for', () => {
       expect(forNode.source.loc.start.column).toBe(itemsOffset + 1)
       expect(forNode.source.loc.end.line).toBe(1)
       expect(forNode.source.loc.end.column).toBe(
-        itemsOffset + 1 + `items`.length
+        itemsOffset + 1 + `items`.length,
       )
     })
   })
@@ -446,18 +446,18 @@ describe('compiler: v-for', () => {
   describe('prefixIdentifiers: true', () => {
     test('should prefix v-for source', () => {
       const { node } = parseWithForTransform(`<div v-for="i in list"/>`, {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
       expect(node.source).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `_ctx.list`
+        content: `_ctx.list`,
       })
     })
 
     test('should prefix v-for source w/ complex expression', () => {
       const { node } = parseWithForTransform(
         `<div v-for="i in list.concat([foo])"/>`,
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       expect(node.source).toMatchObject({
         type: NodeTypes.COMPOUND_EXPRESSION,
@@ -467,31 +467,31 @@ describe('compiler: v-for', () => {
           { content: `concat` },
           `([`,
           { content: `_ctx.foo` },
-          `])`
-        ]
+          `])`,
+        ],
       })
     })
 
     test('should not prefix v-for alias', () => {
       const { node } = parseWithForTransform(
         `<div v-for="i in list">{{ i }}{{ j }}</div>`,
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       const div = node.children[0] as ElementNode
       expect((div.children[0] as InterpolationNode).content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `i`
+        content: `i`,
       })
       expect((div.children[1] as InterpolationNode).content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `_ctx.j`
+        content: `_ctx.j`,
       })
     })
 
     test('should not prefix v-for aliases (multiple)', () => {
       const { node } = parseWithForTransform(
         `<div v-for="(i, j, k) in list">{{ i + j + k }}{{ l }}</div>`,
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       const div = node.children[0] as ElementNode
       expect((div.children[0] as InterpolationNode).content).toMatchObject({
@@ -501,23 +501,23 @@ describe('compiler: v-for', () => {
           ` + `,
           { content: `j` },
           ` + `,
-          { content: `k` }
-        ]
+          { content: `k` },
+        ],
       })
       expect((div.children[1] as InterpolationNode).content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `_ctx.l`
+        content: `_ctx.l`,
       })
     })
 
     test('should prefix id outside of v-for', () => {
       const { node } = parseWithForTransform(
         `<div><div v-for="i in list" />{{ i }}</div>`,
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       expect((node.children[1] as InterpolationNode).content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `_ctx.i`
+        content: `_ctx.i`,
       })
     })
 
@@ -526,7 +526,7 @@ describe('compiler: v-for', () => {
         `<div v-for="i in list">
           <div v-for="i in list">{{ i + j }}</div>{{ i }}
         </div>`,
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       const outerDiv = node.children[0] as ElementNode
       const innerFor = outerDiv.children[0] as ForNode
@@ -534,7 +534,7 @@ describe('compiler: v-for', () => {
         .children[0] as InterpolationNode
       expect(innerExp.content).toMatchObject({
         type: NodeTypes.COMPOUND_EXPRESSION,
-        children: [{ content: 'i' }, ` + `, { content: `_ctx.j` }]
+        children: [{ content: 'i' }, ` + `, { content: `_ctx.j` }],
       })
 
       // when an inner v-for shadows a variable of an outer v-for and exit,
@@ -542,7 +542,7 @@ describe('compiler: v-for', () => {
       const outerExp = outerDiv.children[1] as InterpolationNode
       expect(outerExp.content).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `i`
+        content: `i`,
       })
     })
 
@@ -551,7 +551,7 @@ describe('compiler: v-for', () => {
         `<div v-for="({ foo = bar, baz: [qux = quux] }) in list">
           {{ foo + bar + baz + qux + quux }}
         </div>`,
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       expect(node.valueAlias!).toMatchObject({
         type: NodeTypes.COMPOUND_EXPRESSION,
@@ -564,8 +564,8 @@ describe('compiler: v-for', () => {
           { content: `qux` },
           ` = `,
           { content: `_ctx.quux` },
-          `] }`
-        ]
+          `] }`,
+        ],
       })
       const div = node.children[0] as ElementNode
       expect((div.children[0] as InterpolationNode).content).toMatchObject({
@@ -579,17 +579,17 @@ describe('compiler: v-for', () => {
           ` + `,
           { content: `qux` },
           ` + `,
-          { content: `_ctx.quux` }
-        ]
+          { content: `_ctx.quux` },
+        ],
       })
     })
 
     test('element v-for key expression prefixing', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
         '<div v-for="item in items" :key="itemKey(item)">test</div>',
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       const innerBlock = codegenNode.children.arguments[1].returns
       expect(innerBlock).toMatchObject({
@@ -604,20 +604,20 @@ describe('compiler: v-for', () => {
               `(`,
               // should NOT prefix in scope variables
               { content: `item` },
-              `)`
-            ]
-          }
-        })
+              `)`,
+            ],
+          },
+        }),
       })
     })
 
     // #2085
     test('template v-for key expression prefixing', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
         '<template v-for="item in items" :key="itemKey(item)">test</template>',
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       const innerBlock = codegenNode.children.arguments[1].returns
       expect(innerBlock).toMatchObject({
@@ -632,19 +632,19 @@ describe('compiler: v-for', () => {
               `(`,
               // should NOT prefix in scope variables
               { content: `item` },
-              `)`
-            ]
-          }
-        })
+              `)`,
+            ],
+          },
+        }),
       })
     })
 
     test('template v-for key no prefixing on attribute key', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
         '<template v-for="item in items" key="key">test</template>',
-        { prefixIdentifiers: true }
+        { prefixIdentifiers: true },
       )
       const innerBlock = codegenNode.children.arguments[1].returns
       expect(innerBlock).toMatchObject({
@@ -653,9 +653,9 @@ describe('compiler: v-for', () => {
         props: createObjectMatcher({
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
-            content: 'key'
-          }
-        })
+            content: 'key',
+          },
+        }),
       })
     })
   })
@@ -665,7 +665,7 @@ describe('compiler: v-for', () => {
       node: ForCodegenNode,
       keyed: boolean = false,
       customReturn: boolean = false,
-      disableTracking: boolean = true
+      disableTracking: boolean = true,
     ) {
       expect(node).toMatchObject({
         type: NodeTypes.VNODE_CALL,
@@ -687,32 +687,34 @@ describe('compiler: v-for', () => {
                 ? {}
                 : {
                     type: NodeTypes.VNODE_CALL,
-                    isBlock: disableTracking
-                  }
-            }
-          ]
-        }
+                    isBlock: disableTracking,
+                  },
+            },
+          ],
+        },
       })
       const renderListArgs = node.children.arguments
       return {
         source: renderListArgs[0] as SimpleExpressionNode,
         params: (renderListArgs[1] as any).params,
         returns: (renderListArgs[1] as any).returns,
-        innerVNodeCall: customReturn ? null : (renderListArgs[1] as any).returns
+        innerVNodeCall: customReturn
+          ? null
+          : (renderListArgs[1] as any).returns,
       }
     }
 
     test('basic v-for', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<span v-for="(item) in items" />')
       expect(assertSharedCodegen(codegenNode)).toMatchObject({
         source: { content: `items` },
         params: [{ content: `item` }],
         innerVNodeCall: {
-          tag: `"span"`
-        }
+          tag: `"span"`,
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -720,11 +722,11 @@ describe('compiler: v-for', () => {
     test('value + key + index', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<span v-for="(item, key, index) in items" />')
       expect(assertSharedCodegen(codegenNode)).toMatchObject({
         source: { content: `items` },
-        params: [{ content: `item` }, { content: `key` }, { content: `index` }]
+        params: [{ content: `item` }, { content: `key` }, { content: `index` }],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -732,11 +734,11 @@ describe('compiler: v-for', () => {
     test('skipped value', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<span v-for="(, key, index) in items" />')
       expect(assertSharedCodegen(codegenNode)).toMatchObject({
         source: { content: `items` },
-        params: [{ content: `_` }, { content: `key` }, { content: `index` }]
+        params: [{ content: `_` }, { content: `key` }, { content: `index` }],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -744,11 +746,11 @@ describe('compiler: v-for', () => {
     test('skipped key', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<span v-for="(item,,index) in items" />')
       expect(assertSharedCodegen(codegenNode)).toMatchObject({
         source: { content: `items` },
-        params: [{ content: `item` }, { content: `__` }, { content: `index` }]
+        params: [{ content: `item` }, { content: `__` }, { content: `index` }],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -756,11 +758,11 @@ describe('compiler: v-for', () => {
     test('skipped value & key', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<span v-for="(,,index) in items" />')
       expect(assertSharedCodegen(codegenNode)).toMatchObject({
         source: { content: `items` },
-        params: [{ content: `_` }, { content: `__` }, { content: `index` }]
+        params: [{ content: `_` }, { content: `__` }, { content: `index` }],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -768,9 +770,9 @@ describe('compiler: v-for', () => {
     test('v-for with constant expression', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<p v-for="item in 10">{{item}}</p>', {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
 
       expect(
@@ -778,8 +780,8 @@ describe('compiler: v-for', () => {
           codegenNode,
           false /* keyed */,
           false /* customReturn */,
-          false /* disableTracking */
-        )
+          false /* disableTracking */,
+        ),
       ).toMatchObject({
         source: { content: `10`, constType: ConstantTypes.CAN_STRINGIFY },
         params: [{ content: `item` }],
@@ -793,11 +795,11 @@ describe('compiler: v-for', () => {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: 'item',
               isStatic: false,
-              constType: ConstantTypes.NOT_CONSTANT
-            }
+              constType: ConstantTypes.NOT_CONSTANT,
+            },
           },
-          patchFlag: genFlagText(PatchFlags.TEXT)
-        }
+          patchFlag: genFlagText(PatchFlags.TEXT),
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -805,9 +807,9 @@ describe('compiler: v-for', () => {
     test('template v-for', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
-        '<template v-for="item in items">hello<span/></template>'
+        '<template v-for="item in items">hello<span/></template>',
       )
       expect(assertSharedCodegen(codegenNode)).toMatchObject({
         source: { content: `items` },
@@ -818,10 +820,10 @@ describe('compiler: v-for', () => {
           isBlock: true,
           children: [
             { type: NodeTypes.TEXT, content: `hello` },
-            { type: NodeTypes.ELEMENT, tag: `span` }
+            { type: NodeTypes.ELEMENT, tag: `span` },
           ],
-          patchFlag: genFlagText(PatchFlags.STABLE_FRAGMENT)
-        }
+          patchFlag: genFlagText(PatchFlags.STABLE_FRAGMENT),
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -829,19 +831,19 @@ describe('compiler: v-for', () => {
     test('template v-for w/ <slot/>', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
-        '<template v-for="item in items"><slot/></template>'
+        '<template v-for="item in items"><slot/></template>',
       )
       expect(
-        assertSharedCodegen(codegenNode, false, true /* custom return */)
+        assertSharedCodegen(codegenNode, false, true /* custom return */),
       ).toMatchObject({
         source: { content: `items` },
         params: [{ content: `item` }],
         returns: {
           type: NodeTypes.JS_CALL_EXPRESSION,
-          callee: RENDER_SLOT
-        }
+          callee: RENDER_SLOT,
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -850,9 +852,9 @@ describe('compiler: v-for', () => {
     test('template v-for key injection with single child', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
-        '<template v-for="item in items" :key="item.id"><span :id="item.id" /></template>'
+        '<template v-for="item in items" :key="item.id"><span :id="item.id" /></template>',
       )
       expect(assertSharedCodegen(codegenNode, true)).toMatchObject({
         source: { content: `items` },
@@ -862,9 +864,9 @@ describe('compiler: v-for', () => {
           tag: `"span"`,
           props: createObjectMatcher({
             key: '[item.id]',
-            id: '[item.id]'
-          })
-        }
+            id: '[item.id]',
+          }),
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -872,17 +874,17 @@ describe('compiler: v-for', () => {
     test('v-for on <slot/>', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<slot v-for="item in items"></slot>')
       expect(
-        assertSharedCodegen(codegenNode, false, true /* custom return */)
+        assertSharedCodegen(codegenNode, false, true /* custom return */),
       ).toMatchObject({
         source: { content: `items` },
         params: [{ content: `item` }],
         returns: {
           type: NodeTypes.JS_CALL_EXPRESSION,
-          callee: RENDER_SLOT
-        }
+          callee: RENDER_SLOT,
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -890,7 +892,7 @@ describe('compiler: v-for', () => {
     test('keyed v-for', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<span v-for="(item) in items" :key="item" />')
       expect(assertSharedCodegen(codegenNode, true)).toMatchObject({
         source: { content: `items` },
@@ -898,9 +900,9 @@ describe('compiler: v-for', () => {
         innerVNodeCall: {
           tag: `"span"`,
           props: createObjectMatcher({
-            key: `[item]`
-          })
-        }
+            key: `[item]`,
+          }),
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -908,9 +910,9 @@ describe('compiler: v-for', () => {
     test('keyed template v-for', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(
-        '<template v-for="item in items" :key="item">hello<span/></template>'
+        '<template v-for="item in items" :key="item">hello<span/></template>',
       )
       expect(assertSharedCodegen(codegenNode, true)).toMatchObject({
         source: { content: `items` },
@@ -918,14 +920,14 @@ describe('compiler: v-for', () => {
         innerVNodeCall: {
           tag: FRAGMENT,
           props: createObjectMatcher({
-            key: `[item]`
+            key: `[item]`,
           }),
           children: [
             { type: NodeTypes.TEXT, content: `hello` },
-            { type: NodeTypes.ELEMENT, tag: `span` }
+            { type: NodeTypes.ELEMENT, tag: `span` },
           ],
-          patchFlag: genFlagText(PatchFlags.STABLE_FRAGMENT)
-        }
+          patchFlag: genFlagText(PatchFlags.STABLE_FRAGMENT),
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -933,7 +935,7 @@ describe('compiler: v-for', () => {
     test('v-if + v-for', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(`<div v-if="ok" v-for="i in list"/>`)
       expect(codegenNode).toMatchObject({
         type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
@@ -941,7 +943,7 @@ describe('compiler: v-for', () => {
         consequent: {
           type: NodeTypes.VNODE_CALL,
           props: createObjectMatcher({
-            key: `[0]`
+            key: `[0]`,
           }),
           isBlock: true,
           disableTracking: true,
@@ -957,12 +959,12 @@ describe('compiler: v-for', () => {
                 returns: {
                   type: NodeTypes.VNODE_CALL,
                   tag: `"div"`,
-                  isBlock: true
-                }
-              }
-            ]
-          }
-        }
+                  isBlock: true,
+                },
+              },
+            ],
+          },
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -971,7 +973,7 @@ describe('compiler: v-for', () => {
     test('v-if + v-for on <template>', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform(`<template v-if="ok" v-for="i in list"/>`)
       expect(codegenNode).toMatchObject({
         type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
@@ -979,7 +981,7 @@ describe('compiler: v-for', () => {
         consequent: {
           type: NodeTypes.VNODE_CALL,
           props: createObjectMatcher({
-            key: `[0]`
+            key: `[0]`,
           }),
           isBlock: true,
           disableTracking: true,
@@ -995,12 +997,12 @@ describe('compiler: v-for', () => {
                 returns: {
                   type: NodeTypes.VNODE_CALL,
                   tag: FRAGMENT,
-                  isBlock: true
-                }
-              }
-            ]
-          }
-        }
+                  isBlock: true,
+                },
+              },
+            ],
+          },
+        },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -1008,12 +1010,12 @@ describe('compiler: v-for', () => {
     test('v-for on element with custom directive', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithForTransform('<div v-for="i in list" v-foo/>')
       const { returns } = assertSharedCodegen(codegenNode, false, true)
       expect(returns).toMatchObject({
         type: NodeTypes.VNODE_CALL,
-        directives: { type: NodeTypes.JS_ARRAY_EXPRESSION }
+        directives: { type: NodeTypes.JS_ARRAY_EXPRESSION },
       })
       expect(generate(root).code).toMatchSnapshot()
     })
index 39fa13f00cf52ab6e49e955d3d88f6f8dd452c7c..2c2fedab0d5850cc718a668b046646998c0ebe4f 100644 (file)
@@ -4,26 +4,26 @@ import { transformIf } from '../../src/transforms/vIf'
 import { transformElement } from '../../src/transforms/transformElement'
 import { transformSlotOutlet } from '../../src/transforms/transformSlotOutlet'
 import {
-  CommentNode,
-  ConditionalExpression,
-  ElementNode,
+  type CommentNode,
+  type ConditionalExpression,
+  type ElementNode,
   ElementTypes,
-  IfBranchNode,
-  IfConditionalExpression,
-  IfNode,
+  type IfBranchNode,
+  type IfConditionalExpression,
+  type IfNode,
   NodeTypes,
-  SimpleExpressionNode,
-  TextNode,
-  VNodeCall
+  type SimpleExpressionNode,
+  type TextNode,
+  type VNodeCall,
 } from '../../src/ast'
 import { ErrorCodes } from '../../src/errors'
-import { CompilerOptions, generate, TO_HANDLERS } from '../../src'
+import { type CompilerOptions, TO_HANDLERS, generate } from '../../src'
 import {
   CREATE_COMMENT,
   FRAGMENT,
   MERGE_PROPS,
   NORMALIZE_PROPS,
-  RENDER_SLOT
+  RENDER_SLOT,
 } from '../../src/runtimeHelpers'
 import { createObjectMatcher } from '../testUtils'
 
@@ -31,12 +31,12 @@ function parseWithIfTransform(
   template: string,
   options: CompilerOptions = {},
   returnIndex: number = 0,
-  childrenLen: number = 1
+  childrenLen: number = 1,
 ) {
   const ast = parse(template, options)
   transform(ast, {
     nodeTransforms: [transformIf, transformSlotOutlet, transformElement],
-    ...options
+    ...options,
   })
   if (!options.onError) {
     expect(ast.children.length).toBe(childrenLen)
@@ -48,7 +48,7 @@ function parseWithIfTransform(
     root: ast,
     node: ast.children[returnIndex] as IfNode & {
       codegenNode: IfConditionalExpression
-    }
+    },
   }
 }
 
@@ -59,7 +59,7 @@ describe('compiler: v-if', () => {
       expect(node.type).toBe(NodeTypes.IF)
       expect(node.branches.length).toBe(1)
       expect((node.branches[0].condition as SimpleExpressionNode).content).toBe(
-        `ok`
+        `ok`,
       )
       expect(node.branches[0].children.length).toBe(1)
       expect(node.branches[0].children[0].type).toBe(NodeTypes.ELEMENT)
@@ -68,12 +68,12 @@ describe('compiler: v-if', () => {
 
     test('template v-if', () => {
       const { node } = parseWithIfTransform(
-        `<template v-if="ok"><div/>hello<p/></template>`
+        `<template v-if="ok"><div/>hello<p/></template>`,
       )
       expect(node.type).toBe(NodeTypes.IF)
       expect(node.branches.length).toBe(1)
       expect((node.branches[0].condition as SimpleExpressionNode).content).toBe(
-        `ok`
+        `ok`,
       )
       expect(node.branches[0].children.length).toBe(3)
       expect(node.branches[0].children[0].type).toBe(NodeTypes.ELEMENT)
@@ -89,16 +89,16 @@ describe('compiler: v-if', () => {
       expect(node.type).toBe(NodeTypes.IF)
       expect(node.branches.length).toBe(1)
       expect((node.branches[0].children[0] as ElementNode).tag).toBe(
-        `Component`
+        `Component`,
       )
       expect((node.branches[0].children[0] as ElementNode).tagType).toBe(
-        ElementTypes.COMPONENT
+        ElementTypes.COMPONENT,
       )
       // #2058 since a component may fail to resolve and fallback to a plain
       // element, it still needs to be made a block
       expect(
         ((node.branches[0].children[0] as ElementNode)!
-          .codegenNode as VNodeCall)!.isBlock
+          .codegenNode as VNodeCall)!.isBlock,
       ).toBe(true)
     })
 
@@ -122,7 +122,7 @@ describe('compiler: v-if', () => {
 
     test('v-if + v-else-if', () => {
       const { node } = parseWithIfTransform(
-        `<div v-if="ok"/><p v-else-if="orNot"/>`
+        `<div v-if="ok"/><p v-else-if="orNot"/>`,
       )
       expect(node.type).toBe(NodeTypes.IF)
       expect(node.branches.length).toBe(2)
@@ -142,7 +142,7 @@ describe('compiler: v-if', () => {
 
     test('v-if + v-else-if + v-else', () => {
       const { node } = parseWithIfTransform(
-        `<div v-if="ok"/><p v-else-if="orNot"/><template v-else>fine</template>`
+        `<div v-if="ok"/><p v-else-if="orNot"/><template v-else>fine</template>`,
       )
       expect(node.type).toBe(NodeTypes.IF)
       expect(node.branches.length).toBe(3)
@@ -202,11 +202,11 @@ describe('compiler: v-if', () => {
 
     test('should prefix v-if condition', () => {
       const { node } = parseWithIfTransform(`<div v-if="ok"/>`, {
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
       expect(node.branches[0].condition).toMatchObject({
         type: NodeTypes.SIMPLE_EXPRESSION,
-        content: `_ctx.ok`
+        content: `_ctx.ok`,
       })
     })
   })
@@ -219,32 +219,32 @@ describe('compiler: v-if', () => {
       expect(onError.mock.calls[0]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: node1.loc
-        }
+          loc: node1.loc,
+        },
       ])
 
       const { node: node2 } = parseWithIfTransform(
         `<div/><div v-else/>`,
         { onError },
-        1
+        1,
       )
       expect(onError.mock.calls[1]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: node2.loc
-        }
+          loc: node2.loc,
+        },
       ])
 
       const { node: node3 } = parseWithIfTransform(
         `<div/>foo<div v-else/>`,
         { onError },
-        2
+        2,
       )
       expect(onError.mock.calls[2]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: node3.loc
-        }
+          loc: node3.loc,
+        },
       ])
     })
 
@@ -252,52 +252,52 @@ describe('compiler: v-if', () => {
       const onError = vi.fn()
 
       const { node: node1 } = parseWithIfTransform(`<div v-else-if="foo"/>`, {
-        onError
+        onError,
       })
       expect(onError.mock.calls[0]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: node1.loc
-        }
+          loc: node1.loc,
+        },
       ])
 
       const { node: node2 } = parseWithIfTransform(
         `<div/><div v-else-if="foo"/>`,
         { onError },
-        1
+        1,
       )
       expect(onError.mock.calls[1]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: node2.loc
-        }
+          loc: node2.loc,
+        },
       ])
 
       const { node: node3 } = parseWithIfTransform(
         `<div/>foo<div v-else-if="foo"/>`,
         { onError },
-        2
+        2,
       )
       expect(onError.mock.calls[2]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: node3.loc
-        }
+          loc: node3.loc,
+        },
       ])
 
       const {
-        node: { branches }
+        node: { branches },
       } = parseWithIfTransform(
         `<div v-if="notOk"/><div v-else/><div v-else-if="ok"/>`,
         { onError },
-        0
+        0,
       )
 
       expect(onError.mock.calls[3]).toMatchObject([
         {
           code: ErrorCodes.X_V_ELSE_NO_ADJACENT_IF,
-          loc: branches[branches.length - 1].loc
-        }
+          loc: branches[branches.length - 1].loc,
+        },
       ])
     })
 
@@ -306,21 +306,21 @@ describe('compiler: v-if', () => {
       // dynamic
       parseWithIfTransform(
         `<div v-if="ok" :key="a + 1" /><div v-else :key="a + 1" />`,
-        { onError }
+        { onError },
       )
       expect(onError.mock.calls[0]).toMatchObject([
         {
-          code: ErrorCodes.X_V_IF_SAME_KEY
-        }
+          code: ErrorCodes.X_V_IF_SAME_KEY,
+        },
       ])
       // static
       parseWithIfTransform(`<div v-if="ok" key="1" /><div v-else key="1" />`, {
-        onError
+        onError,
       })
       expect(onError.mock.calls[1]).toMatchObject([
         {
-          code: ErrorCodes.X_V_IF_SAME_KEY
-        }
+          code: ErrorCodes.X_V_IF_SAME_KEY,
+        },
       ])
     })
   })
@@ -329,63 +329,63 @@ describe('compiler: v-if', () => {
     function assertSharedCodegen(
       node: IfConditionalExpression,
       depth: number = 0,
-      hasElse: boolean = false
+      hasElse: boolean = false,
     ) {
       expect(node).toMatchObject({
         type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
         test: {
-          content: `ok`
+          content: `ok`,
         },
         consequent: {
           type: NodeTypes.VNODE_CALL,
-          isBlock: true
+          isBlock: true,
         },
         alternate:
           depth < 1
             ? hasElse
               ? {
                   type: NodeTypes.VNODE_CALL,
-                  isBlock: true
+                  isBlock: true,
                 }
               : {
                   type: NodeTypes.JS_CALL_EXPRESSION,
-                  callee: CREATE_COMMENT
+                  callee: CREATE_COMMENT,
                 }
             : {
                 type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
                 test: {
-                  content: `orNot`
+                  content: `orNot`,
                 },
                 consequent: {
                   type: NodeTypes.VNODE_CALL,
-                  isBlock: true
+                  isBlock: true,
                 },
                 alternate: hasElse
                   ? {
                       type: NodeTypes.VNODE_CALL,
-                      isBlock: true
+                      isBlock: true,
                     }
                   : {
                       type: NodeTypes.JS_CALL_EXPRESSION,
-                      callee: CREATE_COMMENT
-                    }
-              }
+                      callee: CREATE_COMMENT,
+                    },
+              },
       })
     }
 
     test('basic v-if', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok"/>`)
       assertSharedCodegen(codegenNode)
       expect(codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       expect(codegenNode.alternate).toMatchObject({
         type: NodeTypes.JS_CALL_EXPRESSION,
-        callee: CREATE_COMMENT
+        callee: CREATE_COMMENT,
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -393,7 +393,7 @@ describe('compiler: v-if', () => {
     test('template v-if', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<template v-if="ok"><div/>hello<p/></template>`)
       assertSharedCodegen(codegenNode)
       expect(codegenNode.consequent).toMatchObject({
@@ -402,12 +402,12 @@ describe('compiler: v-if', () => {
         children: [
           { type: NodeTypes.ELEMENT, tag: 'div' },
           { type: NodeTypes.TEXT, content: `hello` },
-          { type: NodeTypes.ELEMENT, tag: 'p' }
-        ]
+          { type: NodeTypes.ELEMENT, tag: 'p' },
+        ],
       })
       expect(codegenNode.alternate).toMatchObject({
         type: NodeTypes.JS_CALL_EXPRESSION,
-        callee: CREATE_COMMENT
+        callee: CREATE_COMMENT,
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -415,12 +415,12 @@ describe('compiler: v-if', () => {
     test('template v-if w/ single <slot/> child', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<template v-if="ok"><slot/></template>`)
       expect(codegenNode.consequent).toMatchObject({
         type: NodeTypes.JS_CALL_EXPRESSION,
         callee: RENDER_SLOT,
-        arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })]
+        arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -428,12 +428,12 @@ describe('compiler: v-if', () => {
     test('v-if on <slot/>', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<slot v-if="ok"></slot>`)
       expect(codegenNode.consequent).toMatchObject({
         type: NodeTypes.JS_CALL_EXPRESSION,
         callee: RENDER_SLOT,
-        arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })]
+        arguments: ['$slots', '"default"', createObjectMatcher({ key: `[0]` })],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -441,16 +441,16 @@ describe('compiler: v-if', () => {
     test('v-if + v-else', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok"/><p v-else/>`)
       assertSharedCodegen(codegenNode, 0, true)
       expect(codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       expect(codegenNode.alternate).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[1]` })
+        props: createObjectMatcher({ key: `[1]` }),
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -458,17 +458,17 @@ describe('compiler: v-if', () => {
     test('v-if + v-else-if', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok"/><p v-else-if="orNot" />`)
       assertSharedCodegen(codegenNode, 1)
       expect(codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       const branch2 = codegenNode.alternate as ConditionalExpression
       expect(branch2.consequent).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[1]` })
+        props: createObjectMatcher({ key: `[1]` }),
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -476,19 +476,19 @@ describe('compiler: v-if', () => {
     test('v-if + v-else-if + v-else', () => {
       const {
         root,
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(
-        `<div v-if="ok"/><p v-else-if="orNot"/><template v-else>fine</template>`
+        `<div v-if="ok"/><p v-else-if="orNot"/><template v-else>fine</template>`,
       )
       assertSharedCodegen(codegenNode, 1, true)
       expect(codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       const branch2 = codegenNode.alternate as ConditionalExpression
       expect(branch2.consequent).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[1]` })
+        props: createObjectMatcher({ key: `[1]` }),
       })
       expect(branch2.alternate).toMatchObject({
         tag: FRAGMENT,
@@ -496,9 +496,9 @@ describe('compiler: v-if', () => {
         children: [
           {
             type: NodeTypes.TEXT,
-            content: `fine`
-          }
-        ]
+            content: `fine`,
+          },
+        ],
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -508,7 +508,7 @@ describe('compiler: v-if', () => {
         `<div v-if="ok"/><p v-if="orNot"/>`,
         {},
         0 /* returnIndex, just give the default value */,
-        2 /* childrenLen */
+        2 /* childrenLen */,
       )
 
       const ifNode = root.children[0] as IfNode & {
@@ -516,14 +516,14 @@ describe('compiler: v-if', () => {
       }
       expect(ifNode.codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       const ifNode2 = root.children[1] as IfNode & {
         codegenNode: IfConditionalExpression
       }
       expect(ifNode2.codegenNode.consequent).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[1]` })
+        props: createObjectMatcher({ key: `[1]` }),
       })
       expect(generate(root).code).toMatchSnapshot()
     })
@@ -533,41 +533,41 @@ describe('compiler: v-if', () => {
         `<div v-if="ok"/><p v-else/><div v-if="another"/><p v-else-if="orNot"/><p v-else/>`,
         {},
         0 /* returnIndex, just give the default value */,
-        2 /* childrenLen */
+        2 /* childrenLen */,
       )
       const ifNode = root.children[0] as IfNode & {
         codegenNode: IfConditionalExpression
       }
       expect(ifNode.codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       expect(ifNode.codegenNode.alternate).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[1]` })
+        props: createObjectMatcher({ key: `[1]` }),
       })
       const ifNode2 = root.children[1] as IfNode & {
         codegenNode: IfConditionalExpression
       }
       expect(ifNode2.codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[2]` })
+        props: createObjectMatcher({ key: `[2]` }),
       })
       const branch = ifNode2.codegenNode.alternate as IfConditionalExpression
       expect(branch.consequent).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[3]` })
+        props: createObjectMatcher({ key: `[3]` }),
       })
       expect(branch.alternate).toMatchObject({
         tag: `"p"`,
-        props: createObjectMatcher({ key: `[4]` })
+        props: createObjectMatcher({ key: `[4]` }),
       })
       expect(generate(root).code).toMatchSnapshot()
     })
 
     test('key injection (only v-bind)', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok" v-bind="obj"/>`)
       const branch1 = codegenNode.consequent as VNodeCall
       expect(branch1.props).toMatchObject({
@@ -577,15 +577,18 @@ describe('compiler: v-if', () => {
           {
             type: NodeTypes.JS_CALL_EXPRESSION,
             callee: MERGE_PROPS,
-            arguments: [createObjectMatcher({ key: `[0]` }), { content: `obj` }]
-          }
-        ]
+            arguments: [
+              createObjectMatcher({ key: `[0]` }),
+              { content: `obj` },
+            ],
+          },
+        ],
       })
     })
 
     test('key injection (before v-bind)', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok" id="foo" v-bind="obj"/>`)
       const branch1 = codegenNode.consequent as VNodeCall
       expect(branch1.props).toMatchObject({
@@ -594,16 +597,16 @@ describe('compiler: v-if', () => {
         arguments: [
           createObjectMatcher({
             key: '[0]',
-            id: 'foo'
+            id: 'foo',
           }),
-          { content: `obj` }
-        ]
+          { content: `obj` },
+        ],
       })
     })
 
     test('key injection (after v-bind)', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok" v-bind="obj" id="foo"/>`)
       const branch1 = codegenNode.consequent as VNodeCall
       expect(branch1.props).toMatchObject({
@@ -613,15 +616,15 @@ describe('compiler: v-if', () => {
           createObjectMatcher({ key: `[0]` }),
           { content: `obj` },
           createObjectMatcher({
-            id: 'foo'
-          })
-        ]
+            id: 'foo',
+          }),
+        ],
       })
     })
 
     test('key injection (w/ custom directive)', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok" v-foo />`)
       const branch1 = codegenNode.consequent as VNodeCall
       expect(branch1.directives).not.toBeUndefined()
@@ -631,7 +634,7 @@ describe('compiler: v-if', () => {
     // #6631
     test('avoid duplicate keys', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(`<div v-if="ok" key="custom_key" v-bind="obj"/>`)
       const branch1 = codegenNode.consequent as VNodeCall
       expect(branch1.props).toMatchObject({
@@ -639,31 +642,31 @@ describe('compiler: v-if', () => {
         callee: MERGE_PROPS,
         arguments: [
           createObjectMatcher({
-            key: 'custom_key'
+            key: 'custom_key',
           }),
-          { content: `obj` }
-        ]
+          { content: `obj` },
+        ],
       })
     })
 
     test('with spaces between branches', () => {
       const {
-        node: { codegenNode }
+        node: { codegenNode },
       } = parseWithIfTransform(
-        `<div v-if="ok"/> <div v-else-if="no"/> <div v-else/>`
+        `<div v-if="ok"/> <div v-else-if="no"/> <div v-else/>`,
       )
       expect(codegenNode.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[0]` })
+        props: createObjectMatcher({ key: `[0]` }),
       })
       const branch = codegenNode.alternate as ConditionalExpression
       expect(branch.consequent).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[1]` })
+        props: createObjectMatcher({ key: `[1]` }),
       })
       expect(branch.alternate).toMatchObject({
         tag: `"div"`,
-        props: createObjectMatcher({ key: `[2]` })
+        props: createObjectMatcher({ key: `[2]` }),
       })
     })
 
@@ -729,7 +732,7 @@ describe('compiler: v-if', () => {
             <p/>
           </template>
         `,
-        { comments: true }
+        { comments: true },
       )
       __DEV__ = true
     })
@@ -737,21 +740,21 @@ describe('compiler: v-if', () => {
 
   test('v-on with v-if', () => {
     const {
-      node: { codegenNode }
+      node: { codegenNode },
     } = parseWithIfTransform(
-      `<button v-on="{ click: clickEvent }" v-if="true">w/ v-if</button>`
+      `<button v-on="{ click: clickEvent }" v-if="true">w/ v-if</button>`,
     )
 
     expect((codegenNode.consequent as any).props.type).toBe(
-      NodeTypes.JS_CALL_EXPRESSION
+      NodeTypes.JS_CALL_EXPRESSION,
     )
     expect((codegenNode.consequent as any).props.callee).toBe(MERGE_PROPS)
     expect(
       (codegenNode.consequent as any).props.arguments[0].properties[0].value
-        .content
+        .content,
     ).toBe('0')
     expect((codegenNode.consequent as any).props.arguments[1].callee).toBe(
-      TO_HANDLERS
+      TO_HANDLERS,
     )
   })
 })
index 1b259f7ca684e5ac3fe296ee642e37c5cfe2c041..85769e6e97735da5b8f6198b96e28d9bf93aff14 100644 (file)
@@ -4,7 +4,7 @@ describe('compiler: v-memo transform', () => {
   function compile(content: string) {
     return baseCompile(`<div>${content}</div>`, {
       mode: 'module',
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     }).code
   }
 
@@ -12,8 +12,8 @@ describe('compiler: v-memo transform', () => {
     expect(
       baseCompile(`<div v-memo="[x]"></div>`, {
         mode: 'module',
-        prefixIdentifiers: true
-      }).code
+        prefixIdentifiers: true,
+      }).code,
     ).toMatchSnapshot()
   })
 
@@ -29,8 +29,8 @@ describe('compiler: v-memo transform', () => {
     expect(
       compile(
         `<div v-if="ok" v-memo="[x]"><span>foo</span>bar</div>
-        <Comp v-else v-memo="[x]"></Comp>`
-      )
+        <Comp v-else v-memo="[x]"></Comp>`,
+      ),
     ).toMatchSnapshot()
   })
 
@@ -39,8 +39,8 @@ describe('compiler: v-memo transform', () => {
       compile(
         `<div v-for="{ x, y } in list" :key="x" v-memo="[x, y === z]">
           <span>foobar</span>
-        </div>`
-      )
+        </div>`,
+      ),
     ).toMatchSnapshot()
   })
 
@@ -49,8 +49,8 @@ describe('compiler: v-memo transform', () => {
       compile(
         `<template v-for="{ x, y } in list" :key="x" v-memo="[x, y === z]">
           <span>foobar</span>
-        </template>`
-      )
+        </template>`,
+      ),
     ).toMatchSnapshot()
   })
 })
index ef3485fba05b892036caa4d9cd65b8eb74145df7..5d94aca27778e7cce041c318878961bf8f0b9308 100644 (file)
@@ -1,17 +1,17 @@
 import {
+  BindingTypes,
+  type CompilerOptions,
+  type ComponentNode,
+  type ElementNode,
+  type ForNode,
+  NORMALIZE_PROPS,
+  NodeTypes,
+  type ObjectExpression,
+  type PlainElementNode,
+  type VNodeCall,
+  generate,
   baseParse as parse,
   transform,
-  generate,
-  ElementNode,
-  ObjectExpression,
-  CompilerOptions,
-  ForNode,
-  PlainElementNode,
-  ComponentNode,
-  NodeTypes,
-  VNodeCall,
-  NORMALIZE_PROPS,
-  BindingTypes
 } from '../../src'
 import { ErrorCodes } from '../../src/errors'
 import { transformModel } from '../../src/transforms/vModel'
@@ -19,7 +19,7 @@ import { transformElement } from '../../src/transforms/transformElement'
 import { transformExpression } from '../../src/transforms/transformExpression'
 import { transformFor } from '../../src/transforms/vFor'
 import { trackSlotScopes } from '../../src/transforms/vSlot'
-import { CallExpression } from '@babel/types'
+import type { CallExpression } from '@babel/types'
 
 function parseWithVModel(template: string, options: CompilerOptions = {}) {
   const ast = parse(template)
@@ -29,13 +29,13 @@ function parseWithVModel(template: string, options: CompilerOptions = {}) {
       transformFor,
       transformExpression,
       transformElement,
-      trackSlotScopes
+      trackSlotScopes,
     ],
     directiveTransforms: {
       ...options.directiveTransforms,
-      model: transformModel
+      model: transformModel,
     },
-    ...options
+    ...options,
   })
 
   return ast
@@ -51,29 +51,29 @@ describe('compiler: transform v-model', () => {
     expect(props[0]).toMatchObject({
       key: {
         content: 'modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: 'model',
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
 
     expect(props[1]).toMatchObject({
       key: {
         content: 'onUpdate:modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
           '$event => ((',
           {
             content: 'model',
-            isStatic: false
+            isStatic: false,
           },
-          ') = $event)'
-        ]
-      }
+          ') = $event)',
+        ],
+      },
     })
 
     expect(generate(root).code).toMatchSnapshot()
@@ -81,7 +81,7 @@ describe('compiler: transform v-model', () => {
 
   test('simple expression (with prefixIdentifiers)', () => {
     const root = parseWithVModel('<input v-model="model" />', {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     const node = root.children[0] as ElementNode
     const props = ((node.codegenNode as VNodeCall).props as ObjectExpression)
@@ -90,29 +90,29 @@ describe('compiler: transform v-model', () => {
     expect(props[0]).toMatchObject({
       key: {
         content: 'modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: '_ctx.model',
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
 
     expect(props[1]).toMatchObject({
       key: {
         content: 'onUpdate:modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
           '$event => ((',
           {
             content: '_ctx.model',
-            isStatic: false
+            isStatic: false,
           },
-          ') = $event)'
-        ]
-      }
+          ') = $event)',
+        ],
+      },
     })
 
     expect(generate(root, { mode: 'module' }).code).toMatchSnapshot()
@@ -128,29 +128,29 @@ describe('compiler: transform v-model', () => {
     expect(props[0]).toMatchObject({
       key: {
         content: 'modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: '\n model\n.\nfoo \n',
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
 
     expect(props[1]).toMatchObject({
       key: {
         content: 'onUpdate:modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
           '$event => ((',
           {
             content: '\n model\n.\nfoo \n',
-            isStatic: false
+            isStatic: false,
           },
-          ') = $event)'
-        ]
-      }
+          ') = $event)',
+        ],
+      },
     })
 
     expect(generate(root).code).toMatchSnapshot()
@@ -165,29 +165,29 @@ describe('compiler: transform v-model', () => {
     expect(props[0]).toMatchObject({
       key: {
         content: 'modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: 'model[index]',
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
 
     expect(props[1]).toMatchObject({
       key: {
         content: 'onUpdate:modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
           '$event => ((',
           {
             content: 'model[index]',
-            isStatic: false
+            isStatic: false,
           },
-          ') = $event)'
-        ]
-      }
+          ') = $event)',
+        ],
+      },
     })
 
     expect(generate(root).code).toMatchSnapshot()
@@ -195,7 +195,7 @@ describe('compiler: transform v-model', () => {
 
   test('compound expression (with prefixIdentifiers)', () => {
     const root = parseWithVModel('<input v-model="model[index]" />', {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     const node = root.children[0] as ElementNode
     const props = ((node.codegenNode as VNodeCall).props as ObjectExpression)
@@ -204,28 +204,28 @@ describe('compiler: transform v-model', () => {
     expect(props[0]).toMatchObject({
       key: {
         content: 'modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
           {
             content: '_ctx.model',
-            isStatic: false
+            isStatic: false,
           },
           '[',
           {
             content: '_ctx.index',
-            isStatic: false
+            isStatic: false,
           },
-          ']'
-        ]
-      }
+          ']',
+        ],
+      },
     })
 
     expect(props[1]).toMatchObject({
       key: {
         content: 'onUpdate:modelValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
@@ -234,19 +234,19 @@ describe('compiler: transform v-model', () => {
             children: [
               {
                 content: '_ctx.model',
-                isStatic: false
+                isStatic: false,
               },
               '[',
               {
                 content: '_ctx.index',
-                isStatic: false
+                isStatic: false,
               },
-              ']'
-            ]
+              ']',
+            ],
           },
-          ') = $event)'
-        ]
-      }
+          ') = $event)',
+        ],
+      },
     })
 
     expect(generate(root, { mode: 'module' }).code).toMatchSnapshot()
@@ -260,29 +260,29 @@ describe('compiler: transform v-model', () => {
     expect(props[0]).toMatchObject({
       key: {
         content: 'foo-value',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         content: 'model',
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
 
     expect(props[1]).toMatchObject({
       key: {
         content: 'onUpdate:fooValue',
-        isStatic: true
+        isStatic: true,
       },
       value: {
         children: [
           '$event => ((',
           {
             content: 'model',
-            isStatic: false
+            isStatic: false,
           },
-          ') = $event)'
-        ]
-      }
+          ') = $event)',
+        ],
+      },
     })
 
     expect(generate(root).code).toMatchSnapshot()
@@ -304,12 +304,12 @@ describe('compiler: transform v-model', () => {
             {
               key: {
                 content: 'value',
-                isStatic: false
+                isStatic: false,
               },
               value: {
                 content: 'model',
-                isStatic: false
-              }
+                isStatic: false,
+              },
             },
             {
               key: {
@@ -317,24 +317,24 @@ describe('compiler: transform v-model', () => {
                   '"onUpdate:" + ',
                   {
                     content: 'value',
-                    isStatic: false
-                  }
-                ]
+                    isStatic: false,
+                  },
+                ],
               },
               value: {
                 children: [
                   '$event => ((',
                   {
                     content: 'model',
-                    isStatic: false
+                    isStatic: false,
                   },
-                  ') = $event)'
-                ]
-              }
-            }
-          ]
-        }
-      ]
+                  ') = $event)',
+                ],
+              },
+            },
+          ],
+        },
+      ],
     })
 
     expect(generate(root).code).toMatchSnapshot()
@@ -342,7 +342,7 @@ describe('compiler: transform v-model', () => {
 
   test('with dynamic argument (with prefixIdentifiers)', () => {
     const root = parseWithVModel('<input v-model:[value]="model" />', {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     const node = root.children[0] as ElementNode
     const props = (node.codegenNode as VNodeCall)
@@ -358,12 +358,12 @@ describe('compiler: transform v-model', () => {
             {
               key: {
                 content: '_ctx.value',
-                isStatic: false
+                isStatic: false,
               },
               value: {
                 content: '_ctx.model',
-                isStatic: false
-              }
+                isStatic: false,
+              },
             },
             {
               key: {
@@ -371,24 +371,24 @@ describe('compiler: transform v-model', () => {
                   '"onUpdate:" + ',
                   {
                     content: '_ctx.value',
-                    isStatic: false
-                  }
-                ]
+                    isStatic: false,
+                  },
+                ],
               },
               value: {
                 children: [
                   '$event => ((',
                   {
                     content: '_ctx.model',
-                    isStatic: false
+                    isStatic: false,
                   },
-                  ') = $event)'
-                ]
-              }
-            }
-          ]
-        }
-      ]
+                  ') = $event)',
+                ],
+              },
+            },
+          ],
+        },
+      ],
     })
 
     expect(generate(root, { mode: 'module' }).code).toMatchSnapshot()
@@ -397,7 +397,7 @@ describe('compiler: transform v-model', () => {
   test('should cache update handler w/ cacheHandlers: true', () => {
     const root = parseWithVModel('<input v-model="foo" />', {
       prefixIdentifiers: true,
-      cacheHandlers: true
+      cacheHandlers: true,
     })
     expect(root.cached).toBe(1)
     const codegen = (root.children[0] as PlainElementNode)
@@ -405,7 +405,7 @@ describe('compiler: transform v-model', () => {
     // should not list cached prop in dynamicProps
     expect(codegen.dynamicProps).toBe(`["modelValue"]`)
     expect((codegen.props as ObjectExpression).properties[1].value.type).toBe(
-      NodeTypes.JS_CACHE_EXPRESSION
+      NodeTypes.JS_CACHE_EXPRESSION,
     )
   })
 
@@ -414,8 +414,8 @@ describe('compiler: transform v-model', () => {
       '<input v-for="i in list" v-model="foo[i]" />',
       {
         prefixIdentifiers: true,
-        cacheHandlers: true
-      }
+        cacheHandlers: true,
+      },
     )
     expect(root.cached).toBe(0)
     const codegen = (
@@ -423,14 +423,14 @@ describe('compiler: transform v-model', () => {
     ).codegenNode as VNodeCall
     expect(codegen.dynamicProps).toBe(`["modelValue", "onUpdate:modelValue"]`)
     expect(
-      (codegen.props as ObjectExpression).properties[1].value.type
+      (codegen.props as ObjectExpression).properties[1].value.type,
     ).not.toBe(NodeTypes.JS_CACHE_EXPRESSION)
   })
 
   test('should not cache update handler if it inside v-once', () => {
     const root = parseWithVModel('<div v-once><input v-model="foo" /></div>', {
       prefixIdentifiers: true,
-      cacheHandlers: true
+      cacheHandlers: true,
     })
     expect(root.cached).not.toBe(2)
     expect(root.cached).toBe(1)
@@ -440,8 +440,8 @@ describe('compiler: transform v-model', () => {
     const root = parseWithVModel(
       '<Comp v-slot="{ foo }"><input v-model="foo.bar"/></Comp>',
       {
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     const codegen = (
       (root.children[0] as ComponentNode).children[0] as PlainElementNode
@@ -451,7 +451,7 @@ describe('compiler: transform v-model', () => {
 
   test('should generate modelModifiers for component v-model', () => {
     const root = parseWithVModel('<Comp v-model.trim.bar-baz="foo" />', {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     const vnodeCall = (root.children[0] as ComponentNode)
       .codegenNode as VNodeCall
@@ -462,9 +462,12 @@ describe('compiler: transform v-model', () => {
         { key: { content: `onUpdate:modelValue` } },
         {
           key: { content: 'modelModifiers' },
-          value: { content: `{ trim: true, "bar-baz": true }`, isStatic: false }
-        }
-      ]
+          value: {
+            content: `{ trim: true, "bar-baz": true }`,
+            isStatic: false,
+          },
+        },
+      ],
     })
     // should NOT include modelModifiers in dynamicPropNames because it's never
     // gonna change
@@ -475,8 +478,8 @@ describe('compiler: transform v-model', () => {
     const root = parseWithVModel(
       '<Comp v-model:foo.trim="foo" v-model:bar.number="bar" />',
       {
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     const vnodeCall = (root.children[0] as ComponentNode)
       .codegenNode as VNodeCall
@@ -487,20 +490,20 @@ describe('compiler: transform v-model', () => {
         { key: { content: `onUpdate:foo` } },
         {
           key: { content: 'fooModifiers' },
-          value: { content: `{ trim: true }`, isStatic: false }
+          value: { content: `{ trim: true }`, isStatic: false },
         },
         { key: { content: `bar` } },
         { key: { content: `onUpdate:bar` } },
         {
           key: { content: 'barModifiers' },
-          value: { content: `{ number: true }`, isStatic: false }
-        }
-      ]
+          value: { content: `{ number: true }`, isStatic: false },
+        },
+      ],
     })
     // should NOT include modelModifiers in dynamicPropNames because it's never
     // gonna change
     expect(vnodeCall.dynamicProps).toBe(
-      `["foo", "onUpdate:foo", "bar", "onUpdate:bar"]`
+      `["foo", "onUpdate:foo", "bar", "onUpdate:bar"]`,
     )
   })
 
@@ -512,8 +515,8 @@ describe('compiler: transform v-model', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_MODEL_NO_EXPRESSION
-        })
+          code: ErrorCodes.X_V_MODEL_NO_EXPRESSION,
+        }),
       )
     })
 
@@ -524,8 +527,8 @@ describe('compiler: transform v-model', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION
-        })
+          code: ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION,
+        }),
       )
     })
 
@@ -536,8 +539,8 @@ describe('compiler: transform v-model', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION
-        })
+          code: ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION,
+        }),
       )
     })
 
@@ -552,14 +555,14 @@ describe('compiler: transform v-model', () => {
       const onError = vi.fn()
       parseWithVModel('<span v-for="i in list" v-model="i" />', {
         onError,
-        prefixIdentifiers: true
+        prefixIdentifiers: true,
       })
 
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE
-        })
+          code: ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE,
+        }),
       )
     })
 
@@ -568,15 +571,15 @@ describe('compiler: transform v-model', () => {
       parseWithVModel('<div v-model="p" />', {
         onError,
         bindingMetadata: {
-          p: BindingTypes.PROPS
-        }
+          p: BindingTypes.PROPS,
+        },
       })
 
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: ErrorCodes.X_V_MODEL_ON_PROPS
-        })
+          code: ErrorCodes.X_V_MODEL_ON_PROPS,
+        }),
       )
     })
   })
index 746cfc2a01de288406d1e4d144dbe7ea311e9a79..9f5e0094878eaf8955ad6b72f93fc9b1312e8c6a 100644 (file)
@@ -1,14 +1,14 @@
 import {
-  baseParse as parse,
-  CompilerOptions,
-  ElementNode,
+  type CompilerOptions,
+  type ElementNode,
   ErrorCodes,
+  NodeTypes,
+  type ObjectExpression,
   TO_HANDLER_KEY,
+  type VNodeCall,
   helperNameMap,
-  NodeTypes,
-  ObjectExpression,
+  baseParse as parse,
   transform,
-  VNodeCall
 } from '../../src'
 import { transformOn } from '../../src/transforms/vOn'
 import { transformElement } from '../../src/transforms/transformElement'
@@ -19,13 +19,13 @@ function parseWithVOn(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms: [transformExpression, transformElement],
     directiveTransforms: {
-      on: transformOn
+      on: transformOn,
     },
-    ...options
+    ...options,
   })
   return {
     root: ast,
-    node: ast.children[0] as ElementNode
+    node: ast.children[0] as ElementNode,
   }
 }
 
@@ -41,13 +41,13 @@ describe('compiler: transform v-on', () => {
             loc: {
               start: {
                 line: 1,
-                column: 11
+                column: 11,
               },
               end: {
                 line: 1,
-                column: 16
-              }
-            }
+                column: 16,
+              },
+            },
           },
           value: {
             content: `onClick`,
@@ -55,16 +55,16 @@ describe('compiler: transform v-on', () => {
             loc: {
               start: {
                 line: 1,
-                column: 18
+                column: 18,
               },
               end: {
                 line: 1,
-                column: 25
-              }
-            }
-          }
-        }
-      ]
+                column: 25,
+              },
+            },
+          },
+        },
+      ],
     })
   })
 
@@ -78,22 +78,22 @@ describe('compiler: transform v-on', () => {
             children: [
               `_${helperNameMap[TO_HANDLER_KEY]}(`,
               { content: `event` },
-              `)`
-            ]
+              `)`,
+            ],
           },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `handler`,
-            isStatic: false
-          }
-        }
-      ]
+            isStatic: false,
+          },
+        },
+      ],
     })
   })
 
   test('dynamic arg with prefixing', () => {
     const { node } = parseWithVOn(`<div v-on:[event]="handler"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -103,22 +103,22 @@ describe('compiler: transform v-on', () => {
             children: [
               `_${helperNameMap[TO_HANDLER_KEY]}(`,
               { content: `_ctx.event` },
-              `)`
-            ]
+              `)`,
+            ],
           },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `_ctx.handler`,
-            isStatic: false
-          }
-        }
-      ]
+            isStatic: false,
+          },
+        },
+      ],
     })
   })
 
   test('dynamic arg with complex exp prefixing', () => {
     const { node } = parseWithVOn(`<div v-on:[event(foo)]="handler"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -131,16 +131,16 @@ describe('compiler: transform v-on', () => {
               `(`,
               { content: `_ctx.foo` },
               `)`,
-              `)`
-            ]
+              `)`,
+            ],
           },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `_ctx.handler`,
-            isStatic: false
-          }
-        }
-      ]
+            isStatic: false,
+          },
+        },
+      ],
     })
   })
 
@@ -152,10 +152,10 @@ describe('compiler: transform v-on', () => {
           key: { content: `onClick` },
           value: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [`$event => (`, { content: `i++` }, `)`]
-          }
-        }
-      ]
+            children: [`$event => (`, { content: `i++` }, `)`],
+          },
+        },
+      ],
     })
   })
 
@@ -170,10 +170,10 @@ describe('compiler: transform v-on', () => {
             // should wrap with `{` for multiple statements
             // in this case the return value is discarded and the behavior is
             // consistent with 2.x
-            children: [`$event => {`, { content: `foo();bar()` }, `}`]
-          }
-        }
-      ]
+            children: [`$event => {`, { content: `foo();bar()` }, `}`],
+          },
+        },
+      ],
     })
   })
 
@@ -188,16 +188,16 @@ describe('compiler: transform v-on', () => {
             // should wrap with `{` for multiple statements
             // in this case the return value is discarded and the behavior is
             // consistent with 2.x
-            children: [`$event => {`, { content: `\nfoo();\nbar()\n` }, `}`]
-          }
-        }
-      ]
+            children: [`$event => {`, { content: `\nfoo();\nbar()\n` }, `}`],
+          },
+        },
+      ],
     })
   })
 
   test('inline statement w/ prefixIdentifiers: true', () => {
     const { node } = parseWithVOn(`<div @click="foo($event)"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -214,20 +214,20 @@ describe('compiler: transform v-on', () => {
                   `(`,
                   // should NOT prefix $event
                   { content: `$event` },
-                  `)`
-                ]
+                  `)`,
+                ],
               },
-              `)`
-            ]
-          }
-        }
-      ]
+              `)`,
+            ],
+          },
+        },
+      ],
     })
   })
 
   test('multiple inline statements w/ prefixIdentifiers: true', () => {
     const { node } = parseWithVOn(`<div @click="foo($event);bar()"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -245,14 +245,14 @@ describe('compiler: transform v-on', () => {
                   { content: `$event` },
                   `);`,
                   { content: `_ctx.bar` },
-                  `()`
-                ]
+                  `()`,
+                ],
               },
-              `}`
-            ]
-          }
-        }
-      ]
+              `}`,
+            ],
+          },
+        },
+      ],
     })
   })
 
@@ -264,10 +264,10 @@ describe('compiler: transform v-on', () => {
           key: { content: `onClick` },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
-            content: `$event => foo($event)`
-          }
-        }
-      ]
+            content: `$event => foo($event)`,
+          },
+        },
+      ],
     })
   })
 
@@ -279,10 +279,10 @@ describe('compiler: transform v-on', () => {
           key: { content: `onClick` },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
-            content: `(e: any): any => foo(e)`
-          }
-        }
-      ]
+            content: `(e: any): any => foo(e)`,
+          },
+        },
+      ],
     })
   })
 
@@ -292,7 +292,7 @@ describe('compiler: transform v-on', () => {
       $event => {
         foo($event)
       }
-    "/>`
+    "/>`,
     )
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -304,10 +304,10 @@ describe('compiler: transform v-on', () => {
       $event => {
         foo($event)
       }
-    `
-          }
-        }
-      ]
+    `,
+          },
+        },
+      ],
     })
   })
 
@@ -317,7 +317,7 @@ describe('compiler: transform v-on', () => {
       function($event) {
         foo($event)
       }
-    "/>`
+    "/>`,
     )
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -329,10 +329,10 @@ describe('compiler: transform v-on', () => {
       function($event) {
         foo($event)
       }
-    `
-          }
-        }
-      ]
+    `,
+          },
+        },
+      ],
     })
   })
 
@@ -344,16 +344,16 @@ describe('compiler: transform v-on', () => {
           key: { content: `onClick` },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
-            content: `a['b' + c]`
-          }
-        }
-      ]
+            content: `a['b' + c]`,
+          },
+        },
+      ],
     })
   })
 
   test('complex member expression w/ prefixIdentifiers: true', () => {
     const { node } = parseWithVOn(`<div @click="a['b' + c]"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -365,17 +365,17 @@ describe('compiler: transform v-on', () => {
               { content: `_ctx.a` },
               `['b' + `,
               { content: `_ctx.c` },
-              `]`
-            ]
-          }
-        }
-      ]
+              `]`,
+            ],
+          },
+        },
+      ],
     })
   })
 
   test('function expression w/ prefixIdentifiers: true', () => {
     const { node } = parseWithVOn(`<div @click="e => foo(e)"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
@@ -389,11 +389,11 @@ describe('compiler: transform v-on', () => {
               { content: `_ctx.foo` },
               `(`,
               { content: `e` },
-              `)`
-            ]
-          }
-        }
-      ]
+              `)`,
+            ],
+          },
+        },
+      ],
     })
   })
 
@@ -405,13 +405,13 @@ describe('compiler: transform v-on', () => {
       loc: {
         start: {
           line: 1,
-          column: 6
+          column: 6,
         },
         end: {
           line: 1,
-          column: 16
-        }
-      }
+          column: 16,
+        },
+      },
     })
   })
 
@@ -427,13 +427,13 @@ describe('compiler: transform v-on', () => {
       properties: [
         {
           key: {
-            content: `onFooBar`
+            content: `onFooBar`,
           },
           value: {
-            content: `onMount`
-          }
-        }
-      ]
+            content: `onMount`,
+          },
+        },
+      ],
     })
   })
 
@@ -445,39 +445,39 @@ describe('compiler: transform v-on', () => {
       loc: {
         start: {
           line: 1,
-          column: 11
+          column: 11,
         },
         end: {
           line: 1,
-          column: 24
-        }
-      }
+          column: 24,
+        },
+      },
     })
   })
 
   test('vue: prefixed events', () => {
     const { node } = parseWithVOn(
-      `<div v-on:vue:mounted="onMount" @vue:before-update="onBeforeUpdate" />`
+      `<div v-on:vue:mounted="onMount" @vue:before-update="onBeforeUpdate" />`,
     )
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       properties: [
         {
           key: {
-            content: `onVnodeMounted`
+            content: `onVnodeMounted`,
           },
           value: {
-            content: `onMount`
-          }
+            content: `onMount`,
+          },
         },
         {
           key: {
-            content: `onVnodeBeforeUpdate`
+            content: `onVnodeBeforeUpdate`,
           },
           value: {
-            content: `onBeforeUpdate`
-          }
-        }
-      ]
+            content: `onBeforeUpdate`,
+          },
+        },
+      ],
     })
   })
 
@@ -485,35 +485,35 @@ describe('compiler: transform v-on', () => {
     test('empty handler', () => {
       const { root, node } = parseWithVOn(`<div v-on:click.prevent />`, {
         prefixIdentifiers: true,
-        cacheHandlers: true
+        cacheHandlers: true,
       })
       expect(root.cached).toBe(1)
       const vnodeCall = node.codegenNode as VNodeCall
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
         value: {
           type: NodeTypes.SIMPLE_EXPRESSION,
-          content: `() => {}`
-        }
+          content: `() => {}`,
+        },
       })
     })
 
     test('member expression handler', () => {
       const { root, node } = parseWithVOn(`<div v-on:click="foo" />`, {
         prefixIdentifiers: true,
-        cacheHandlers: true
+        cacheHandlers: true,
       })
       expect(root.cached).toBe(1)
       const vnodeCall = node.codegenNode as VNodeCall
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
@@ -522,23 +522,23 @@ describe('compiler: transform v-on', () => {
           children: [
             `(...args) => (`,
             { content: `_ctx.foo && _ctx.foo(...args)` },
-            `)`
-          ]
-        }
+            `)`,
+          ],
+        },
       })
     })
 
     test('compound member expression handler', () => {
       const { root, node } = parseWithVOn(`<div v-on:click="foo.bar" />`, {
         prefixIdentifiers: true,
-        cacheHandlers: true
+        cacheHandlers: true,
       })
       expect(root.cached).toBe(1)
       const vnodeCall = node.codegenNode as VNodeCall
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
@@ -555,12 +555,12 @@ describe('compiler: transform v-on', () => {
                 { content: `_ctx.foo` },
                 `.`,
                 { content: `bar` },
-                `(...args)`
-              ]
+                `(...args)`,
+              ],
             },
-            `)`
-          ]
-        }
+            `)`,
+          ],
+        },
       })
     })
 
@@ -568,7 +568,7 @@ describe('compiler: transform v-on', () => {
       const { root } = parseWithVOn(`<comp v-on:click="foo" />`, {
         prefixIdentifiers: true,
         cacheHandlers: true,
-        isNativeTag: tag => tag === 'div'
+        isNativeTag: tag => tag === 'div',
       })
       expect(root.cached).toBe(0)
     })
@@ -578,8 +578,8 @@ describe('compiler: transform v-on', () => {
         `<div v-once><div v-on:click="foo"/></div>`,
         {
           prefixIdentifiers: true,
-          cacheHandlers: true
-        }
+          cacheHandlers: true,
+        },
       )
       expect(root.cached).not.toBe(2)
       expect(root.cached).toBe(1)
@@ -588,21 +588,21 @@ describe('compiler: transform v-on', () => {
     test('inline function expression handler', () => {
       const { root, node } = parseWithVOn(`<div v-on:click="() => foo()" />`, {
         prefixIdentifiers: true,
-        cacheHandlers: true
+        cacheHandlers: true,
       })
       expect(root.cached).toBe(1)
       const vnodeCall = node.codegenNode as VNodeCall
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
         value: {
           type: NodeTypes.COMPOUND_EXPRESSION,
-          children: [`() => `, { content: `_ctx.foo` }, `()`]
-        }
+          children: [`() => `, { content: `_ctx.foo` }, `()`],
+        },
       })
     })
 
@@ -611,22 +611,22 @@ describe('compiler: transform v-on', () => {
         `<div v-on:click="async () => await foo()" />`,
         {
           prefixIdentifiers: true,
-          cacheHandlers: true
-        }
+          cacheHandlers: true,
+        },
       )
       expect(root.cached).toBe(1)
       const vnodeCall = node.codegenNode as VNodeCall
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
         value: {
           type: NodeTypes.COMPOUND_EXPRESSION,
-          children: [`async () => await `, { content: `_ctx.foo` }, `()`]
-        }
+          children: [`async () => await `, { content: `_ctx.foo` }, `()`],
+        },
       })
     })
 
@@ -635,15 +635,15 @@ describe('compiler: transform v-on', () => {
         `<div v-on:click="async function () { await foo() } " />`,
         {
           prefixIdentifiers: true,
-          cacheHandlers: true
-        }
+          cacheHandlers: true,
+        },
       )
       expect(root.cached).toBe(1)
       const vnodeCall = node.codegenNode as VNodeCall
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
@@ -652,16 +652,16 @@ describe('compiler: transform v-on', () => {
           children: [
             `async function () { await `,
             { content: `_ctx.foo` },
-            `() } `
-          ]
-        }
+            `() } `,
+          ],
+        },
       })
     })
 
     test('inline statement handler', () => {
       const { root, node } = parseWithVOn(`<div v-on:click="foo++" />`, {
         prefixIdentifiers: true,
-        cacheHandlers: true
+        cacheHandlers: true,
       })
       expect(root.cached).toBe(1)
       expect(root.cached).toBe(1)
@@ -669,7 +669,7 @@ describe('compiler: transform v-on', () => {
       // should not treat cached handler as dynamicProp, so no flags
       expect(vnodeCall.patchFlag).toBeUndefined()
       expect(
-        (vnodeCall.props as ObjectExpression).properties[0].value
+        (vnodeCall.props as ObjectExpression).properties[0].value,
       ).toMatchObject({
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
@@ -678,9 +678,9 @@ describe('compiler: transform v-on', () => {
           children: [
             `$event => (`,
             { children: [{ content: `_ctx.foo` }, `++`] },
-            `)`
-          ]
-        }
+            `)`,
+          ],
+        },
       })
     })
   })
index 553ac1dfac4951e85b3b6f64e5e9f559ea0b7678..30149c62df6ae2a504803fe1f5c213eb3cd1d000 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  baseParse as parse,
-  transform,
+  type CompilerOptions,
   NodeTypes,
   generate,
-  CompilerOptions,
-  getBaseTransformPreset
+  getBaseTransformPreset,
+  baseParse as parse,
+  transform,
 } from '../../src'
 import { RENDER_SLOT, SET_BLOCK_TRACKING } from '../../src/runtimeHelpers'
 
@@ -14,7 +14,7 @@ function transformWithOnce(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms,
     directiveTransforms,
-    ...options
+    ...options,
   })
   return ast
 }
@@ -29,8 +29,8 @@ describe('compiler: v-once transform', () => {
       index: 0,
       value: {
         type: NodeTypes.VNODE_CALL,
-        tag: `"div"`
-      }
+        tag: `"div"`,
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -44,8 +44,8 @@ describe('compiler: v-once transform', () => {
       index: 0,
       value: {
         type: NodeTypes.VNODE_CALL,
-        tag: `"div"`
-      }
+        tag: `"div"`,
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -59,8 +59,8 @@ describe('compiler: v-once transform', () => {
       index: 0,
       value: {
         type: NodeTypes.VNODE_CALL,
-        tag: `_component_Comp`
-      }
+        tag: `_component_Comp`,
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -74,8 +74,8 @@ describe('compiler: v-once transform', () => {
       index: 0,
       value: {
         type: NodeTypes.JS_CALL_EXPRESSION,
-        callee: RENDER_SLOT
-      }
+        callee: RENDER_SLOT,
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -90,7 +90,7 @@ describe('compiler: v-once transform', () => {
   // cached nodes should be ignored by hoistStatic transform
   test('with hoistStatic: true', () => {
     const root = transformWithOnce(`<div><div v-once /></div>`, {
-      hoistStatic: true
+      hoistStatic: true,
     })
     expect(root.cached).toBe(1)
     expect(root.helpers).toContain(SET_BLOCK_TRACKING)
@@ -100,8 +100,8 @@ describe('compiler: v-once transform', () => {
       index: 0,
       value: {
         type: NodeTypes.VNODE_CALL,
-        tag: `"div"`
-      }
+        tag: `"div"`,
+      },
     })
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -119,14 +119,14 @@ describe('compiler: v-once transform', () => {
           type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
           consequent: {
             type: NodeTypes.VNODE_CALL,
-            tag: `"div"`
+            tag: `"div"`,
           },
           alternate: {
             type: NodeTypes.VNODE_CALL,
-            tag: `"p"`
-          }
-        }
-      }
+            tag: `"p"`,
+          },
+        },
+      },
     })
   })
 
@@ -138,8 +138,8 @@ describe('compiler: v-once transform', () => {
       type: NodeTypes.FOR,
       // should cache the entire v-for expression, not just a single branch
       codegenNode: {
-        type: NodeTypes.JS_CACHE_EXPRESSION
-      }
+        type: NodeTypes.JS_CACHE_EXPRESSION,
+      },
     })
   })
 })
index 03ce2fa610e4a789f78e673652251fd604715043..aa7b600ccbebf9354bbe0823a3968631d4a6c1d3 100644 (file)
@@ -1,18 +1,18 @@
 import {
-  CompilerOptions,
+  type CompilerOptions,
+  type ComponentNode,
+  type ElementNode,
+  ErrorCodes,
+  type ForNode,
+  NodeTypes,
+  type ObjectExpression,
+  type RenderSlotCall,
+  type SimpleExpressionNode,
+  type SlotsExpression,
+  type VNodeCall,
+  generate,
   baseParse as parse,
   transform,
-  generate,
-  ElementNode,
-  NodeTypes,
-  ErrorCodes,
-  ForNode,
-  ComponentNode,
-  VNodeCall,
-  SlotsExpression,
-  ObjectExpression,
-  SimpleExpressionNode,
-  RenderSlotCall
 } from '../../src'
 import { transformElement } from '../../src/transforms/transformElement'
 import { transformOn } from '../../src/transforms/vOn'
@@ -21,7 +21,7 @@ import { transformExpression } from '../../src/transforms/transformExpression'
 import { transformSlotOutlet } from '../../src/transforms/transformSlotOutlet'
 import {
   trackSlotScopes,
-  trackVForSlotScopes
+  trackVForSlotScopes,
 } from '../../src/transforms/vSlot'
 import { CREATE_SLOTS, RENDER_LIST } from '../../src/runtimeHelpers'
 import { createObjectMatcher, genFlagText } from '../testUtils'
@@ -31,7 +31,7 @@ import { transformIf } from '../../src/transforms/vIf'
 
 function parseWithSlots(template: string, options: CompilerOptions = {}) {
   const ast = parse(template, {
-    whitespace: options.whitespace
+    whitespace: options.whitespace,
   })
   transform(ast, {
     nodeTransforms: [
@@ -42,13 +42,13 @@ function parseWithSlots(template: string, options: CompilerOptions = {}) {
         : []),
       transformSlotOutlet,
       transformElement,
-      trackSlotScopes
+      trackSlotScopes,
     ],
     directiveTransforms: {
       on: transformOn,
-      bind: transformBind
+      bind: transformBind,
     },
-    ...options
+    ...options,
   })
   return {
     root: ast,
@@ -56,7 +56,7 @@ function parseWithSlots(template: string, options: CompilerOptions = {}) {
       ast.children[0].type === NodeTypes.ELEMENT
         ? ((ast.children[0].codegenNode as VNodeCall)
             .children as SlotsExpression)
-        : null
+        : null,
   }
 }
 
@@ -70,25 +70,25 @@ function createSlotMatcher(obj: Record<string, any>, isDynamic = false) {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             isStatic: !/^\[/.test(key),
-            content: key.replace(/^\[|\]$/g, '')
+            content: key.replace(/^\[|\]$/g, ''),
           },
-          value: obj[key]
+          value: obj[key],
         } as any
       })
       .concat({
         key: { content: `_` },
         value: {
           content: isDynamic ? `2 /* DYNAMIC */` : `1 /* STABLE */`,
-          isStatic: false
-        }
-      })
+          isStatic: false,
+        },
+      }),
   }
 }
 
 describe('compiler: transform component slots', () => {
   test('implicit default slot', () => {
     const { root, slots } = parseWithSlots(`<Comp><div/></Comp>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(slots).toMatchObject(
       createSlotMatcher({
@@ -98,11 +98,11 @@ describe('compiler: transform component slots', () => {
           returns: [
             {
               type: NodeTypes.ELEMENT,
-              tag: `div`
-            }
-          ]
-        }
-      })
+              tag: `div`,
+            },
+          ],
+        },
+      }),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -110,7 +110,7 @@ describe('compiler: transform component slots', () => {
   test('on-component default slot', () => {
     const { root, slots } = parseWithSlots(
       `<Comp v-slot="{ foo }">{{ foo }}{{ bar }}</Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject(
       createSlotMatcher({
@@ -118,24 +118,24 @@ describe('compiler: transform component slots', () => {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
           params: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [`{ `, { content: `foo` }, ` }`]
+            children: [`{ `, { content: `foo` }, ` }`],
           },
           returns: [
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `foo`
-              }
+                content: `foo`,
+              },
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `_ctx.bar`
-              }
-            }
-          ]
-        }
-      })
+                content: `_ctx.bar`,
+              },
+            },
+          ],
+        },
+      }),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -143,7 +143,7 @@ describe('compiler: transform component slots', () => {
   test('on component named slot', () => {
     const { root, slots } = parseWithSlots(
       `<Comp v-slot:named="{ foo }">{{ foo }}{{ bar }}</Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject(
       createSlotMatcher({
@@ -151,24 +151,24 @@ describe('compiler: transform component slots', () => {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
           params: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [`{ `, { content: `foo` }, ` }`]
+            children: [`{ `, { content: `foo` }, ` }`],
           },
           returns: [
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `foo`
-              }
+                content: `foo`,
+              },
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `_ctx.bar`
-              }
-            }
-          ]
-        }
-      })
+                content: `_ctx.bar`,
+              },
+            },
+          ],
+        },
+      }),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -183,7 +183,7 @@ describe('compiler: transform component slots', () => {
           {{ foo }}{{ bar }}
         </template>
       </Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject(
       createSlotMatcher({
@@ -191,45 +191,45 @@ describe('compiler: transform component slots', () => {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
           params: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [`{ `, { content: `foo` }, ` }`]
+            children: [`{ `, { content: `foo` }, ` }`],
           },
           returns: [
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `foo`
-              }
+                content: `foo`,
+              },
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `_ctx.bar`
-              }
-            }
-          ]
+                content: `_ctx.bar`,
+              },
+            },
+          ],
         },
         two: {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
           params: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [`{ `, { content: `bar` }, ` }`]
+            children: [`{ `, { content: `bar` }, ` }`],
           },
           returns: [
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `_ctx.foo`
-              }
+                content: `_ctx.foo`,
+              },
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `bar`
-              }
-            }
-          ]
-        }
-      })
+                content: `bar`,
+              },
+            },
+          ],
+        },
+      }),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -237,7 +237,7 @@ describe('compiler: transform component slots', () => {
   test('on component dynamically named slot', () => {
     const { root, slots } = parseWithSlots(
       `<Comp v-slot:[named]="{ foo }">{{ foo }}{{ bar }}</Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject(
       createSlotMatcher(
@@ -246,26 +246,26 @@ describe('compiler: transform component slots', () => {
             type: NodeTypes.JS_FUNCTION_EXPRESSION,
             params: {
               type: NodeTypes.COMPOUND_EXPRESSION,
-              children: [`{ `, { content: `foo` }, ` }`]
+              children: [`{ `, { content: `foo` }, ` }`],
             },
             returns: [
               {
                 type: NodeTypes.INTERPOLATION,
                 content: {
-                  content: `foo`
-                }
+                  content: `foo`,
+                },
               },
               {
                 type: NodeTypes.INTERPOLATION,
                 content: {
-                  content: `_ctx.bar`
-                }
-              }
-            ]
-          }
+                  content: `_ctx.bar`,
+                },
+              },
+            ],
+          },
         },
-        true
-      )
+        true,
+      ),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -274,7 +274,7 @@ describe('compiler: transform component slots', () => {
     const { root, slots } = parseWithSlots(
       `<Comp>
         <template #one>foo</template>bar<span/>
-      </Comp>`
+      </Comp>`,
     )
     expect(slots).toMatchObject(
       createSlotMatcher({
@@ -284,9 +284,9 @@ describe('compiler: transform component slots', () => {
           returns: [
             {
               type: NodeTypes.TEXT,
-              content: `foo`
-            }
-          ]
+              content: `foo`,
+            },
+          ],
         },
         default: {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
@@ -294,15 +294,15 @@ describe('compiler: transform component slots', () => {
           returns: [
             {
               type: NodeTypes.TEXT,
-              content: `bar`
+              content: `bar`,
             },
             {
               type: NodeTypes.ELEMENT,
-              tag: `span`
-            }
-          ]
-        }
-      })
+              tag: `span`,
+            },
+          ],
+        },
+      }),
     )
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -317,7 +317,7 @@ describe('compiler: transform component slots', () => {
           {{ foo }}{{ bar }}
         </template>
       </Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject(
       createSlotMatcher(
@@ -326,47 +326,47 @@ describe('compiler: transform component slots', () => {
             type: NodeTypes.JS_FUNCTION_EXPRESSION,
             params: {
               type: NodeTypes.COMPOUND_EXPRESSION,
-              children: [`{ `, { content: `foo` }, ` }`]
+              children: [`{ `, { content: `foo` }, ` }`],
             },
             returns: [
               {
                 type: NodeTypes.INTERPOLATION,
                 content: {
-                  content: `foo`
-                }
+                  content: `foo`,
+                },
               },
               {
                 type: NodeTypes.INTERPOLATION,
                 content: {
-                  content: `_ctx.bar`
-                }
-              }
-            ]
+                  content: `_ctx.bar`,
+                },
+              },
+            ],
           },
           '[_ctx.two]': {
             type: NodeTypes.JS_FUNCTION_EXPRESSION,
             params: {
               type: NodeTypes.COMPOUND_EXPRESSION,
-              children: [`{ `, { content: `bar` }, ` }`]
+              children: [`{ `, { content: `bar` }, ` }`],
             },
             returns: [
               {
                 type: NodeTypes.INTERPOLATION,
                 content: {
-                  content: `_ctx.foo`
-                }
+                  content: `_ctx.foo`,
+                },
               },
               {
                 type: NodeTypes.INTERPOLATION,
                 content: {
-                  content: `bar`
-                }
-              }
-            ]
-          }
+                  content: `bar`,
+                },
+              },
+            ],
+          },
         },
-        true
-      )
+        true,
+      ),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -381,7 +381,7 @@ describe('compiler: transform component slots', () => {
           {{ foo }}{{ bar }}{{ baz }}
         </template>
       </Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject(
       createSlotMatcher({
@@ -389,7 +389,7 @@ describe('compiler: transform component slots', () => {
           type: NodeTypes.JS_FUNCTION_EXPRESSION,
           params: {
             type: NodeTypes.COMPOUND_EXPRESSION,
-            children: [`{ `, { content: `foo` }, ` }`]
+            children: [`{ `, { content: `foo` }, ` }`],
           },
           returns: [
             {
@@ -404,63 +404,63 @@ describe('compiler: transform component slots', () => {
                       type: NodeTypes.JS_FUNCTION_EXPRESSION,
                       params: {
                         type: NodeTypes.COMPOUND_EXPRESSION,
-                        children: [`{ `, { content: `bar` }, ` }`]
+                        children: [`{ `, { content: `bar` }, ` }`],
                       },
                       returns: [
                         {
                           type: NodeTypes.INTERPOLATION,
                           content: {
-                            content: `foo`
-                          }
+                            content: `foo`,
+                          },
                         },
                         {
                           type: NodeTypes.INTERPOLATION,
                           content: {
-                            content: `bar`
-                          }
+                            content: `bar`,
+                          },
                         },
                         {
                           type: NodeTypes.INTERPOLATION,
                           content: {
-                            content: `_ctx.baz`
-                          }
-                        }
-                      ]
-                    }
+                            content: `_ctx.baz`,
+                          },
+                        },
+                      ],
+                    },
                   },
-                  true
+                  true,
                 ),
                 // nested slot should be forced dynamic, since scope variables
                 // are not tracked as dependencies of the slot.
-                patchFlag: genFlagText(PatchFlags.DYNAMIC_SLOTS)
-              }
+                patchFlag: genFlagText(PatchFlags.DYNAMIC_SLOTS),
+              },
             },
             // test scope
             {
               type: NodeTypes.TEXT,
-              content: ` `
+              content: ` `,
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `foo`
-              }
+                content: `foo`,
+              },
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `_ctx.bar`
-              }
+                content: `_ctx.bar`,
+              },
             },
             {
               type: NodeTypes.INTERPOLATION,
               content: {
-                content: `_ctx.baz`
-              }
-            }
-          ]
-        }
-      })
+                content: `_ctx.baz`,
+              },
+            },
+          ],
+        },
+      }),
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -469,13 +469,13 @@ describe('compiler: transform component slots', () => {
     const { root } = parseWithSlots(
       `<div v-for="i in list">
         <Comp v-slot="bar">foo</Comp>
-      </div>`
+      </div>`,
     )
     const div = ((root.children[0] as ForNode).children[0] as ElementNode)
       .codegenNode as any
     const comp = div.children[0]
     expect(comp.codegenNode.patchFlag).toBe(
-      genFlagText(PatchFlags.DYNAMIC_SLOTS)
+      genFlagText(PatchFlags.DYNAMIC_SLOTS),
     )
   })
 
@@ -504,14 +504,14 @@ describe('compiler: transform component slots', () => {
       `<div v-for="i in list">
         <Comp v-slot="bar">foo</Comp>
       </div>`,
-      false
+      false,
     )
 
     assertDynamicSlots(
       `<div v-for="i in list">
         <Comp v-slot="bar">{{ i }}</Comp>
       </div>`,
-      true
+      true,
     )
 
     // reference the component's own slot variable should not force dynamic slots
@@ -519,14 +519,14 @@ describe('compiler: transform component slots', () => {
       `<Comp v-slot="foo">
         <Comp v-slot="bar">{{ bar }}</Comp>
       </Comp>`,
-      false
+      false,
     )
 
     assertDynamicSlots(
       `<Comp v-slot="foo">
         <Comp v-slot="bar">{{ foo }}</Comp>
       </Comp>`,
-      true
+      true,
     )
 
     // #2564
@@ -534,14 +534,14 @@ describe('compiler: transform component slots', () => {
       `<div v-for="i in list">
         <Comp v-slot="bar"><button @click="fn(i)" /></Comp>
       </div>`,
-      true
+      true,
     )
 
     assertDynamicSlots(
       `<div v-for="i in list">
         <Comp v-slot="bar"><button @click="fn()" /></Comp>
       </div>`,
-      false
+      false,
     )
   })
 
@@ -549,14 +549,14 @@ describe('compiler: transform component slots', () => {
     const { root, slots } = parseWithSlots(
       `<Comp>
         <template #one v-if="ok">hello</template>
-      </Comp>`
+      </Comp>`,
     )
     expect(slots).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: CREATE_SLOTS,
       arguments: [
         createObjectMatcher({
-          _: `[2 /* DYNAMIC */]`
+          _: `[2 /* DYNAMIC */]`,
         }),
         {
           type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -568,21 +568,21 @@ describe('compiler: transform component slots', () => {
                 name: `one`,
                 fn: {
                   type: NodeTypes.JS_FUNCTION_EXPRESSION,
-                  returns: [{ type: NodeTypes.TEXT, content: `hello` }]
+                  returns: [{ type: NodeTypes.TEXT, content: `hello` }],
                 },
-                key: `0`
+                key: `0`,
               }),
               alternate: {
                 content: `undefined`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
     expect((root as any).children[0].codegenNode.patchFlag).toMatch(
-      PatchFlags.DYNAMIC_SLOTS + ''
+      PatchFlags.DYNAMIC_SLOTS + '',
     )
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -592,14 +592,14 @@ describe('compiler: transform component slots', () => {
       `<Comp>
         <template #one="props" v-if="ok">{{ props }}</template>
       </Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: CREATE_SLOTS,
       arguments: [
         createObjectMatcher({
-          _: `[2 /* DYNAMIC */]`
+          _: `[2 /* DYNAMIC */]`,
         }),
         {
           type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -615,23 +615,23 @@ describe('compiler: transform component slots', () => {
                   returns: [
                     {
                       type: NodeTypes.INTERPOLATION,
-                      content: { content: `props` }
-                    }
-                  ]
+                      content: { content: `props` },
+                    },
+                  ],
                 },
-                key: `0`
+                key: `0`,
               }),
               alternate: {
                 content: `undefined`,
-                isStatic: false
-              }
-            }
-          ]
-        }
-      ]
+                isStatic: false,
+              },
+            },
+          ],
+        },
+      ],
     })
     expect((root as any).children[0].codegenNode.patchFlag).toMatch(
-      PatchFlags.DYNAMIC_SLOTS + ''
+      PatchFlags.DYNAMIC_SLOTS + '',
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -642,14 +642,14 @@ describe('compiler: transform component slots', () => {
         <template #one v-if="ok">foo</template>
         <template #two="props" v-else-if="orNot">bar</template>
         <template #one v-else>baz</template>
-      </Comp>`
+      </Comp>`,
     )
     expect(slots).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: CREATE_SLOTS,
       arguments: [
         createObjectMatcher({
-          _: `[2 /* DYNAMIC */]`
+          _: `[2 /* DYNAMIC */]`,
         }),
         {
           type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -662,9 +662,9 @@ describe('compiler: transform component slots', () => {
                 fn: {
                   type: NodeTypes.JS_FUNCTION_EXPRESSION,
                   params: undefined,
-                  returns: [{ type: NodeTypes.TEXT, content: `foo` }]
+                  returns: [{ type: NodeTypes.TEXT, content: `foo` }],
                 },
-                key: `0`
+                key: `0`,
               }),
               alternate: {
                 type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
@@ -674,27 +674,27 @@ describe('compiler: transform component slots', () => {
                   fn: {
                     type: NodeTypes.JS_FUNCTION_EXPRESSION,
                     params: { content: `props` },
-                    returns: [{ type: NodeTypes.TEXT, content: `bar` }]
+                    returns: [{ type: NodeTypes.TEXT, content: `bar` }],
                   },
-                  key: `1`
+                  key: `1`,
                 }),
                 alternate: createObjectMatcher({
                   name: `one`,
                   fn: {
                     type: NodeTypes.JS_FUNCTION_EXPRESSION,
                     params: undefined,
-                    returns: [{ type: NodeTypes.TEXT, content: `baz` }]
+                    returns: [{ type: NodeTypes.TEXT, content: `baz` }],
                   },
-                  key: `2`
-                })
-              }
-            }
-          ]
-        }
-      ]
+                  key: `2`,
+                }),
+              },
+            },
+          ],
+        },
+      ],
     })
     expect((root as any).children[0].codegenNode.patchFlag).toMatch(
-      PatchFlags.DYNAMIC_SLOTS + ''
+      PatchFlags.DYNAMIC_SLOTS + '',
     )
     expect(generate(root).code).toMatchSnapshot()
   })
@@ -704,14 +704,14 @@ describe('compiler: transform component slots', () => {
       `<Comp>
         <template v-for="name in list" #[name]>{{ name }}</template>
       </Comp>`,
-      { prefixIdentifiers: true }
+      { prefixIdentifiers: true },
     )
     expect(slots).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
       callee: CREATE_SLOTS,
       arguments: [
         createObjectMatcher({
-          _: `[2 /* DYNAMIC */]`
+          _: `[2 /* DYNAMIC */]`,
         }),
         {
           type: NodeTypes.JS_ARRAY_EXPRESSION,
@@ -731,20 +731,20 @@ describe('compiler: transform component slots', () => {
                       returns: [
                         {
                           type: NodeTypes.INTERPOLATION,
-                          content: { content: `name`, isStatic: false }
-                        }
-                      ]
-                    }
-                  })
-                }
-              ]
-            }
-          ]
-        }
-      ]
+                          content: { content: `name`, isStatic: false },
+                        },
+                      ],
+                    },
+                  }),
+                },
+              ],
+            },
+          ],
+        },
+      ],
     })
     expect((root as any).children[0].codegenNode.patchFlag).toMatch(
-      PatchFlags.DYNAMIC_SLOTS + ''
+      PatchFlags.DYNAMIC_SLOTS + '',
     )
     expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
   })
@@ -755,13 +755,13 @@ describe('compiler: transform component slots', () => {
       properties: [
         {
           key: { content: `default` },
-          value: { type: NodeTypes.JS_FUNCTION_EXPRESSION }
+          value: { type: NodeTypes.JS_FUNCTION_EXPRESSION },
         },
         {
           key: { content: `_` },
-          value: { content: `3 /* FORWARDED */` }
-        }
-      ]
+          value: { content: `3 /* FORWARDED */` },
+        },
+      ],
     }
     test('<slot> tag only', () => {
       const { slots } = parseWithSlots(`<Comp><slot/></Comp>`)
@@ -780,7 +780,7 @@ describe('compiler: transform component slots', () => {
 
     test('<slot> tag w/ template', () => {
       const { slots } = parseWithSlots(
-        `<Comp><template #default><slot/></template></Comp>`
+        `<Comp><template #default><slot/></template></Comp>`,
       )
       expect(slots).toMatchObject(toMatch)
     })
@@ -793,7 +793,7 @@ describe('compiler: transform component slots', () => {
     // # fix: #6900
     test('consistent behavior of @xxx:modelValue and @xxx:model-value', () => {
       const { root: rootUpper } = parseWithSlots(
-        `<div><slot @foo:modelValue="handler" /></div>`
+        `<div><slot @foo:modelValue="handler" /></div>`,
       )
       const slotNodeUpper = (rootUpper.codegenNode! as VNodeCall)
         .children as ElementNode[]
@@ -805,19 +805,19 @@ describe('compiler: transform component slots', () => {
           {
             key: {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: 'onFoo:modelValue'
+              content: 'onFoo:modelValue',
             },
             value: {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: `handler`,
-              isStatic: false
-            }
-          }
-        ]
+              isStatic: false,
+            },
+          },
+        ],
       })
 
       const { root } = parseWithSlots(
-        `<div><slot @foo:model-Value="handler" /></div>`
+        `<div><slot @foo:model-Value="handler" /></div>`,
       )
       const slotNode = (root.codegenNode! as VNodeCall)
         .children as ElementNode[]
@@ -828,15 +828,15 @@ describe('compiler: transform component slots', () => {
           {
             key: {
               type: NodeTypes.SIMPLE_EXPRESSION,
-              content: 'onFoo:modelValue'
+              content: 'onFoo:modelValue',
             },
             value: {
               type: NodeTypes.SIMPLE_EXPRESSION,
               content: `handler`,
-              isStatic: false
-            }
-          }
-        ]
+              isStatic: false,
+            },
+          },
+        ],
       })
     })
   })
@@ -853,14 +853,14 @@ describe('compiler: transform component slots', () => {
           start: {
             offset: index,
             line: 1,
-            column: index + 1
+            column: index + 1,
           },
           end: {
             offset: index + 3,
             line: 1,
-            column: index + 4
-          }
-        }
+            column: index + 4,
+          },
+        },
       })
     })
 
@@ -875,14 +875,14 @@ describe('compiler: transform component slots', () => {
           start: {
             offset: index,
             line: 1,
-            column: index + 1
+            column: index + 1,
           },
           end: {
             offset: index + 4,
             line: 1,
-            column: index + 5
-          }
-        }
+            column: index + 5,
+          },
+        },
       })
     })
 
@@ -897,14 +897,14 @@ describe('compiler: transform component slots', () => {
           start: {
             offset: index,
             line: 1,
-            column: index + 1
+            column: index + 1,
           },
           end: {
             offset: index + 4,
             line: 1,
-            column: index + 5
-          }
-        }
+            column: index + 5,
+          },
+        },
       })
     })
 
@@ -919,14 +919,14 @@ describe('compiler: transform component slots', () => {
           start: {
             offset: index,
             line: 1,
-            column: index + 1
+            column: index + 1,
           },
           end: {
             offset: index + 6,
             line: 1,
-            column: index + 7
-          }
-        }
+            column: index + 7,
+          },
+        },
       })
     })
   })
@@ -940,11 +940,11 @@ describe('compiler: transform component slots', () => {
       </Comp>
       `
       const { root } = parseWithSlots(source, {
-        whitespace: 'preserve'
+        whitespace: 'preserve',
       })
 
       expect(
-        `Extraneous children found when component already has explicitly named default slot.`
+        `Extraneous children found when component already has explicitly named default slot.`,
       ).not.toHaveBeenWarned()
       expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
     })
@@ -957,11 +957,11 @@ describe('compiler: transform component slots', () => {
       </Comp>
       `
       const { root } = parseWithSlots(source, {
-        whitespace: 'preserve'
+        whitespace: 'preserve',
       })
 
       expect(
-        `Extraneous children found when component already has explicitly named default slot.`
+        `Extraneous children found when component already has explicitly named default slot.`,
       ).not.toHaveBeenWarned()
       expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
     })
@@ -974,7 +974,7 @@ describe('compiler: transform component slots', () => {
       </Comp>
       `
       const { root } = parseWithSlots(source, {
-        whitespace: 'preserve'
+        whitespace: 'preserve',
       })
 
       // slots is vnodeCall's children as an ObjectExpression
@@ -984,7 +984,7 @@ describe('compiler: transform component slots', () => {
       // should be: header, footer, _ (no default)
       expect(slots.length).toBe(3)
       expect(
-        slots.some(p => (p.key as SimpleExpressionNode).content === 'default')
+        slots.some(p => (p.key as SimpleExpressionNode).content === 'default'),
       ).toBe(false)
 
       expect(generate(root, { prefixIdentifiers: true }).code).toMatchSnapshot()
index 6ef65af6365a2ea5e3385de64dcbc01abf741cea..506aa86982e9929fd0abf3f164c70b6a38bfb131 100644 (file)
@@ -1,10 +1,10 @@
-import { TransformContext } from '../src'
-import { Position } from '../src/ast'
+import type { TransformContext } from '../src'
+import type { Position } from '../src/ast'
 import {
   advancePositionWithClone,
-  isMemberExpressionNode,
   isMemberExpressionBrowser,
-  toValidAssetId
+  isMemberExpressionNode,
+  toValidAssetId,
 } from '../src/utils'
 
 function p(line: number, column: number, offset: number): Position {
@@ -108,6 +108,6 @@ test('toValidAssetId', () => {
   expect(toValidAssetId('div', 'filter')).toBe('_filter_div')
   expect(toValidAssetId('foo-bar', 'component')).toBe('_component_foo_bar')
   expect(toValidAssetId('test-测试-1', 'component')).toBe(
-    '_component_test_2797935797_1'
+    '_component_test_2797935797_1',
   )
 })
index 203fa8b2c6b0c1b32b0ab9905d10a1d002150fdf..3f92a99fcbbd6c7ee0b1e1e2aafaaeb8eab05012 100644 (file)
@@ -1,20 +1,20 @@
 import { isString } from '@vue/shared'
 import {
-  RENDER_SLOT,
-  CREATE_SLOTS,
-  RENDER_LIST,
+  CREATE_BLOCK,
+  CREATE_ELEMENT_BLOCK,
+  CREATE_ELEMENT_VNODE,
+  type CREATE_SLOTS,
+  CREATE_VNODE,
+  type FRAGMENT,
   OPEN_BLOCK,
-  FRAGMENT,
+  type RENDER_LIST,
+  type RENDER_SLOT,
   WITH_DIRECTIVES,
-  WITH_MEMO,
-  CREATE_VNODE,
-  CREATE_ELEMENT_VNODE,
-  CREATE_BLOCK,
-  CREATE_ELEMENT_BLOCK
+  type WITH_MEMO,
 } from './runtimeHelpers'
-import { PropsExpression } from './transforms/transformElement'
-import { ImportItem, TransformContext } from './transform'
-import { Node as BabelNode } from '@babel/types'
+import type { PropsExpression } from './transforms/transformElement'
+import type { ImportItem, TransformContext } from './transform'
+import type { Node as BabelNode } from '@babel/types'
 
 // Vue template is a platform-agnostic superset of HTML (syntax only).
 // More namespaces can be declared by platform specific compilers.
@@ -23,7 +23,7 @@ export type Namespace = number
 export enum Namespaces {
   HTML,
   SVG,
-  MATH_ML
+  MATH_ML,
 }
 
 export enum NodeTypes {
@@ -57,14 +57,14 @@ export enum NodeTypes {
   JS_IF_STATEMENT,
   JS_ASSIGNMENT_EXPRESSION,
   JS_SEQUENCE_EXPRESSION,
-  JS_RETURN_STATEMENT
+  JS_RETURN_STATEMENT,
 }
 
 export enum ElementTypes {
   ELEMENT,
   COMPONENT,
   SLOT,
-  TEMPLATE
+  TEMPLATE,
 }
 
 export interface Node {
@@ -219,7 +219,7 @@ export enum ConstantTypes {
   NOT_CONSTANT = 0,
   CAN_SKIP_PATCH,
   CAN_HOIST,
-  CAN_STRINGIFY
+  CAN_STRINGIFY,
 }
 
 export interface SimpleExpressionNode extends Node {
@@ -495,7 +495,7 @@ export interface RenderSlotCall extends CallExpression {
         string,
         string | ExpressionNode,
         PropsExpression | '{}',
-        TemplateChildNode[]
+        TemplateChildNode[],
       ]
 }
 
@@ -582,12 +582,12 @@ export interface ForIteratorExpression extends FunctionExpression {
 export const locStub: SourceLocation = {
   start: { line: 1, column: 1, offset: 0 },
   end: { line: 1, column: 1, offset: 0 },
-  source: ''
+  source: '',
 }
 
 export function createRoot(
   children: TemplateChildNode[],
-  source = ''
+  source = '',
 ): RootNode {
   return {
     type: NodeTypes.ROOT,
@@ -601,7 +601,7 @@ export function createRoot(
     cached: 0,
     temps: 0,
     codegenNode: undefined,
-    loc: locStub
+    loc: locStub,
   }
 }
 
@@ -616,7 +616,7 @@ export function createVNodeCall(
   isBlock: VNodeCall['isBlock'] = false,
   disableTracking: VNodeCall['disableTracking'] = false,
   isComponent: VNodeCall['isComponent'] = false,
-  loc = locStub
+  loc = locStub,
 ): VNodeCall {
   if (context) {
     if (isBlock) {
@@ -641,41 +641,41 @@ export function createVNodeCall(
     isBlock,
     disableTracking,
     isComponent,
-    loc
+    loc,
   }
 }
 
 export function createArrayExpression(
   elements: ArrayExpression['elements'],
-  loc: SourceLocation = locStub
+  loc: SourceLocation = locStub,
 ): ArrayExpression {
   return {
     type: NodeTypes.JS_ARRAY_EXPRESSION,
     loc,
-    elements
+    elements,
   }
 }
 
 export function createObjectExpression(
   properties: ObjectExpression['properties'],
-  loc: SourceLocation = locStub
+  loc: SourceLocation = locStub,
 ): ObjectExpression {
   return {
     type: NodeTypes.JS_OBJECT_EXPRESSION,
     loc,
-    properties
+    properties,
   }
 }
 
 export function createObjectProperty(
   key: Property['key'] | string,
-  value: Property['value']
+  value: Property['value'],
 ): Property {
   return {
     type: NodeTypes.JS_PROPERTY,
     loc: locStub,
     key: isString(key) ? createSimpleExpression(key, true) : key,
-    value
+    value,
   }
 }
 
@@ -683,38 +683,38 @@ export function createSimpleExpression(
   content: SimpleExpressionNode['content'],
   isStatic: SimpleExpressionNode['isStatic'] = false,
   loc: SourceLocation = locStub,
-  constType: ConstantTypes = ConstantTypes.NOT_CONSTANT
+  constType: ConstantTypes = ConstantTypes.NOT_CONSTANT,
 ): SimpleExpressionNode {
   return {
     type: NodeTypes.SIMPLE_EXPRESSION,
     loc,
     content,
     isStatic,
-    constType: isStatic ? ConstantTypes.CAN_STRINGIFY : constType
+    constType: isStatic ? ConstantTypes.CAN_STRINGIFY : constType,
   }
 }
 
 export function createInterpolation(
   content: InterpolationNode['content'] | string,
-  loc: SourceLocation
+  loc: SourceLocation,
 ): InterpolationNode {
   return {
     type: NodeTypes.INTERPOLATION,
     loc,
     content: isString(content)
       ? createSimpleExpression(content, false, loc)
-      : content
+      : content,
   }
 }
 
 export function createCompoundExpression(
   children: CompoundExpressionNode['children'],
-  loc: SourceLocation = locStub
+  loc: SourceLocation = locStub,
 ): CompoundExpressionNode {
   return {
     type: NodeTypes.COMPOUND_EXPRESSION,
     loc,
-    children
+    children,
   }
 }
 
@@ -725,13 +725,13 @@ type InferCodegenNodeType<T> = T extends typeof RENDER_SLOT
 export function createCallExpression<T extends CallExpression['callee']>(
   callee: T,
   args: CallExpression['arguments'] = [],
-  loc: SourceLocation = locStub
+  loc: SourceLocation = locStub,
 ): InferCodegenNodeType<T> {
   return {
     type: NodeTypes.JS_CALL_EXPRESSION,
     loc,
     callee,
-    arguments: args
+    arguments: args,
   } as InferCodegenNodeType<T>
 }
 
@@ -740,7 +740,7 @@ export function createFunctionExpression(
   returns: FunctionExpression['returns'] = undefined,
   newline: boolean = false,
   isSlot: boolean = false,
-  loc: SourceLocation = locStub
+  loc: SourceLocation = locStub,
 ): FunctionExpression {
   return {
     type: NodeTypes.JS_FUNCTION_EXPRESSION,
@@ -748,7 +748,7 @@ export function createFunctionExpression(
     returns,
     newline,
     isSlot,
-    loc
+    loc,
   }
 }
 
@@ -756,7 +756,7 @@ export function createConditionalExpression(
   test: ConditionalExpression['test'],
   consequent: ConditionalExpression['consequent'],
   alternate: ConditionalExpression['alternate'],
-  newline = true
+  newline = true,
 ): ConditionalExpression {
   return {
     type: NodeTypes.JS_CONDITIONAL_EXPRESSION,
@@ -764,87 +764,87 @@ export function createConditionalExpression(
     consequent,
     alternate,
     newline,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createCacheExpression(
   index: number,
   value: JSChildNode,
-  isVNode: boolean = false
+  isVNode: boolean = false,
 ): CacheExpression {
   return {
     type: NodeTypes.JS_CACHE_EXPRESSION,
     index,
     value,
     isVNode,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createBlockStatement(
-  body: BlockStatement['body']
+  body: BlockStatement['body'],
 ): BlockStatement {
   return {
     type: NodeTypes.JS_BLOCK_STATEMENT,
     body,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createTemplateLiteral(
-  elements: TemplateLiteral['elements']
+  elements: TemplateLiteral['elements'],
 ): TemplateLiteral {
   return {
     type: NodeTypes.JS_TEMPLATE_LITERAL,
     elements,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createIfStatement(
   test: IfStatement['test'],
   consequent: IfStatement['consequent'],
-  alternate?: IfStatement['alternate']
+  alternate?: IfStatement['alternate'],
 ): IfStatement {
   return {
     type: NodeTypes.JS_IF_STATEMENT,
     test,
     consequent,
     alternate,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createAssignmentExpression(
   left: AssignmentExpression['left'],
-  right: AssignmentExpression['right']
+  right: AssignmentExpression['right'],
 ): AssignmentExpression {
   return {
     type: NodeTypes.JS_ASSIGNMENT_EXPRESSION,
     left,
     right,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createSequenceExpression(
-  expressions: SequenceExpression['expressions']
+  expressions: SequenceExpression['expressions'],
 ): SequenceExpression {
   return {
     type: NodeTypes.JS_SEQUENCE_EXPRESSION,
     expressions,
-    loc: locStub
+    loc: locStub,
   }
 }
 
 export function createReturnStatement(
-  returns: ReturnStatement['returns']
+  returns: ReturnStatement['returns'],
 ): ReturnStatement {
   return {
     type: NodeTypes.JS_RETURN_STATEMENT,
     returns,
-    loc: locStub
+    loc: locStub,
   }
 }
 
@@ -858,7 +858,7 @@ export function getVNodeBlockHelper(ssr: boolean, isComponent: boolean) {
 
 export function convertToBlock(
   node: VNodeCall,
-  { helper, removeHelper, inSSR }: TransformContext
+  { helper, removeHelper, inSSR }: TransformContext,
 ) {
   if (!node.isBlock) {
     node.isBlock = true
index c00c18b3fed30494a66072eab86d4b5c26d9d420..e0e0ef2222bf81206bbe5beaed4f537c5dfa18b8 100644 (file)
@@ -1,12 +1,12 @@
 // should only use types from @babel/types
 // do not import runtime methods
 import type {
+  BlockStatement,
+  Function,
   Identifier,
   Node,
-  Function,
   ObjectProperty,
-  BlockStatement,
-  Program
+  Program,
 } from '@babel/types'
 import { walk } from 'estree-walker'
 
@@ -17,11 +17,11 @@ export function walkIdentifiers(
     parent: Node,
     parentStack: Node[],
     isReference: boolean,
-    isLocal: boolean
+    isLocal: boolean,
   ) => void,
   includeAll = false,
   parentStack: Node[] = [],
-  knownIds: Record<string, number> = Object.create(null)
+  knownIds: Record<string, number> = Object.create(null),
 ) {
   if (__BROWSER__) {
     return
@@ -61,7 +61,7 @@ export function walkIdentifiers(
           // walk function expressions and add its arguments to known identifiers
           // so that we don't prefix them
           walkFunctionParams(node, id =>
-            markScopeIdentifier(node, id, knownIds)
+            markScopeIdentifier(node, id, knownIds),
           )
         }
       } else if (node.type === 'BlockStatement') {
@@ -70,7 +70,7 @@ export function walkIdentifiers(
         } else {
           // #3445 record block-level local variables
           walkBlockDeclarations(node, id =>
-            markScopeIdentifier(node, id, knownIds)
+            markScopeIdentifier(node, id, knownIds),
           )
         }
       }
@@ -85,14 +85,14 @@ export function walkIdentifiers(
           }
         }
       }
-    }
+    },
   })
 }
 
 export function isReferencedIdentifier(
   id: Identifier,
   parent: Node | null,
-  parentStack: Node[]
+  parentStack: Node[],
 ) {
   if (__BROWSER__) {
     return false
@@ -127,7 +127,7 @@ export function isReferencedIdentifier(
 
 export function isInDestructureAssignment(
   parent: Node,
-  parentStack: Node[]
+  parentStack: Node[],
 ): boolean {
   if (
     parent &&
@@ -148,7 +148,7 @@ export function isInDestructureAssignment(
 
 export function walkFunctionParams(
   node: Function,
-  onIdent: (id: Identifier) => void
+  onIdent: (id: Identifier) => void,
 ) {
   for (const p of node.params) {
     for (const id of extractIdentifiers(p)) {
@@ -159,7 +159,7 @@ export function walkFunctionParams(
 
 export function walkBlockDeclarations(
   block: BlockStatement | Program,
-  onIdent: (node: Identifier) => void
+  onIdent: (node: Identifier) => void,
 ) {
   for (const stmt of block.body) {
     if (stmt.type === 'VariableDeclaration') {
@@ -194,7 +194,7 @@ export function walkBlockDeclarations(
 
 export function extractIdentifiers(
   param: Node,
-  nodes: Identifier[] = []
+  nodes: Identifier[] = [],
 ): Identifier[] {
   switch (param.type) {
     case 'Identifier':
@@ -248,7 +248,7 @@ function markKnownIds(name: string, knownIds: Record<string, number>) {
 function markScopeIdentifier(
   node: Node & { scopeIds?: Set<string> },
   child: Identifier,
-  knownIds: Record<string, number>
+  knownIds: Record<string, number>,
 ) {
   const { name } = child
   if (node.scopeIds && node.scopeIds.has(name)) {
@@ -453,7 +453,7 @@ export const TS_NODE_TYPES = [
   'TSTypeAssertion', // (<number>foo)
   'TSNonNullExpression', // foo!
   'TSInstantiationExpression', // foo<string>
-  'TSSatisfiesExpression' // foo satisfies T
+  'TSSatisfiesExpression', // foo satisfies T
 ]
 
 export function unwrapTSNode(node: Node): Node {
index 890ef9bfda4211a8ecc58c163d0e1ae40f239a71..4447e67aafad145e088d1aeba61b59f610ba2b29 100644 (file)
@@ -1,60 +1,60 @@
-import { CodegenOptions } from './options'
+import type { CodegenOptions } from './options'
 import {
-  RootNode,
-  TemplateChildNode,
-  TextNode,
-  CommentNode,
-  ExpressionNode,
+  type ArrayExpression,
+  type AssignmentExpression,
+  type CacheExpression,
+  type CallExpression,
+  type CommentNode,
+  type CompoundExpressionNode,
+  type ConditionalExpression,
+  type ExpressionNode,
+  type FunctionExpression,
+  type IfStatement,
+  type InterpolationNode,
+  type JSChildNode,
   NodeTypes,
-  JSChildNode,
-  CallExpression,
-  ArrayExpression,
-  ObjectExpression,
-  Position,
-  InterpolationNode,
-  CompoundExpressionNode,
-  SimpleExpressionNode,
-  FunctionExpression,
-  ConditionalExpression,
-  CacheExpression,
-  locStub,
-  SSRCodegenNode,
-  TemplateLiteral,
-  IfStatement,
-  AssignmentExpression,
-  ReturnStatement,
-  VNodeCall,
-  SequenceExpression,
+  type ObjectExpression,
+  type Position,
+  type ReturnStatement,
+  type RootNode,
+  type SSRCodegenNode,
+  type SequenceExpression,
+  type SimpleExpressionNode,
+  type TemplateChildNode,
+  type TemplateLiteral,
+  type TextNode,
+  type VNodeCall,
   getVNodeBlockHelper,
-  getVNodeHelper
+  getVNodeHelper,
+  locStub,
 } from './ast'
-import { SourceMapGenerator, RawSourceMap } from 'source-map-js'
+import { type RawSourceMap, SourceMapGenerator } from 'source-map-js'
 import {
   advancePositionWithMutation,
   assert,
   isSimpleIdentifier,
-  toValidAssetId
+  toValidAssetId,
 } from './utils'
-import { isString, isArray, isSymbol } from '@vue/shared'
+import { isArray, isString, isSymbol } from '@vue/shared'
 import {
-  helperNameMap,
-  TO_DISPLAY_STRING,
+  CREATE_COMMENT,
+  CREATE_ELEMENT_VNODE,
+  CREATE_STATIC,
+  CREATE_TEXT,
   CREATE_VNODE,
+  OPEN_BLOCK,
+  POP_SCOPE_ID,
+  PUSH_SCOPE_ID,
   RESOLVE_COMPONENT,
   RESOLVE_DIRECTIVE,
+  RESOLVE_FILTER,
   SET_BLOCK_TRACKING,
-  CREATE_COMMENT,
-  CREATE_TEXT,
-  PUSH_SCOPE_ID,
-  POP_SCOPE_ID,
-  WITH_DIRECTIVES,
-  CREATE_ELEMENT_VNODE,
-  OPEN_BLOCK,
-  CREATE_STATIC,
+  TO_DISPLAY_STRING,
   WITH_CTX,
-  RESOLVE_FILTER
+  WITH_DIRECTIVES,
+  helperNameMap,
 } from './runtimeHelpers'
-import { ImportItem } from './transform'
+import type { ImportItem } from './transform'
 
 const PURE_ANNOTATION = `/*#__PURE__*/`
 
@@ -73,7 +73,7 @@ enum NewlineType {
   Start = 0,
   End = -1,
   None = -2,
-  Unknown = -3
+  Unknown = -3,
 }
 
 export interface CodegenContext
@@ -107,8 +107,8 @@ function createCodegenContext(
     ssrRuntimeModuleName = 'vue/server-renderer',
     ssr = false,
     isTS = false,
-    inSSR = false
-  }: CodegenOptions
+    inSSR = false,
+  }: CodegenOptions,
 ): CodegenContext {
   const context: CodegenContext = {
     mode,
@@ -158,7 +158,7 @@ function createCodegenContext(
             if (__TEST__ && code.includes('\n')) {
               throw new Error(
                 `CodegenContext.push() called newlineIndex: none, but contains` +
-                  `newlines: ${code.replace(/\n/g, '\\n')}`
+                  `newlines: ${code.replace(/\n/g, '\\n')}`,
               )
             }
             context.column += code.length
@@ -175,7 +175,7 @@ function createCodegenContext(
             ) {
               throw new Error(
                 `CodegenContext.push() called with newlineIndex: ${newlineIndex} ` +
-                  `but does not conform: ${code.replace(/\n/g, '\\n')}`
+                  `but does not conform: ${code.replace(/\n/g, '\\n')}`,
               )
             }
             context.line++
@@ -199,7 +199,7 @@ function createCodegenContext(
     },
     newline() {
       newline(context.indentLevel)
-    }
+    },
   }
 
   function newline(n: number) {
@@ -218,8 +218,8 @@ function createCodegenContext(
       generatedLine: context.line,
       generatedColumn: context.column - 1,
       source: filename,
-      // @ts-ignore it is possible to be null
-      name
+      // @ts-expect-error it is possible to be null
+      name,
     })
   }
 
@@ -237,7 +237,7 @@ export function generate(
   ast: RootNode,
   options: CodegenOptions & {
     onContextCreated?: (context: CodegenContext) => void
-  } = {}
+  } = {},
 ): CodegenResult {
   const context = createCodegenContext(ast, options)
   if (options.onContextCreated) options.onContextCreated(context)
@@ -249,7 +249,7 @@ export function generate(
     deindent,
     newline,
     scopeId,
-    ssr
+    ssr,
   } = context
 
   const helpers = Array.from(ast.helpers)
@@ -296,7 +296,7 @@ export function generate(
     if (hasHelpers) {
       push(
         `const { ${helpers.map(aliasHelper).join(', ')} } = _Vue\n`,
-        NewlineType.End
+        NewlineType.End,
       )
       newline()
     }
@@ -354,7 +354,7 @@ export function generate(
     ast,
     code: context.code,
     preamble: isSetupInlined ? preambleContext.code : ``,
-    map: context.map ? context.map.toJSON() : undefined
+    map: context.map ? context.map.toJSON() : undefined,
   }
 }
 
@@ -366,7 +366,7 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
     newline,
     runtimeModuleName,
     runtimeGlobalName,
-    ssrRuntimeModuleName
+    ssrRuntimeModuleName,
   } = context
   const VueBinding =
     !__BROWSER__ && ssr
@@ -381,7 +381,7 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
     if (!__BROWSER__ && prefixIdentifiers) {
       push(
         `const { ${helpers.map(aliasHelper).join(', ')} } = ${VueBinding}\n`,
-        NewlineType.End
+        NewlineType.End,
       )
     } else {
       // "with" mode.
@@ -396,7 +396,7 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
           CREATE_ELEMENT_VNODE,
           CREATE_COMMENT,
           CREATE_TEXT,
-          CREATE_STATIC
+          CREATE_STATIC,
         ]
           .filter(helper => helpers.includes(helper))
           .map(aliasHelper)
@@ -412,7 +412,7 @@ function genFunctionPreamble(ast: RootNode, context: CodegenContext) {
       `const { ${ast.ssrHelpers
         .map(aliasHelper)
         .join(', ')} } = require("${ssrRuntimeModuleName}")\n`,
-      NewlineType.End
+      NewlineType.End,
     )
   }
   genHoists(ast.hoists, context)
@@ -424,14 +424,14 @@ function genModulePreamble(
   ast: RootNode,
   context: CodegenContext,
   genScopeId: boolean,
-  inline?: boolean
+  inline?: boolean,
 ) {
   const {
     push,
     newline,
     optimizeImports,
     runtimeModuleName,
-    ssrRuntimeModuleName
+    ssrRuntimeModuleName,
   } = context
 
   if (genScopeId && ast.hoists.length) {
@@ -452,20 +452,20 @@ function genModulePreamble(
         `import { ${helpers
           .map(s => helperNameMap[s])
           .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`,
-        NewlineType.End
+        NewlineType.End,
       )
       push(
         `\n// Binding optimization for webpack code-split\nconst ${helpers
           .map(s => `_${helperNameMap[s]} = ${helperNameMap[s]}`)
           .join(', ')}\n`,
-        NewlineType.End
+        NewlineType.End,
       )
     } else {
       push(
         `import { ${helpers
           .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
           .join(', ')} } from ${JSON.stringify(runtimeModuleName)}\n`,
-        NewlineType.End
+        NewlineType.End,
       )
     }
   }
@@ -475,7 +475,7 @@ function genModulePreamble(
       `import { ${ast.ssrHelpers
         .map(s => `${helperNameMap[s]} as _${helperNameMap[s]}`)
         .join(', ')} } from "${ssrRuntimeModuleName}"\n`,
-      NewlineType.End
+      NewlineType.End,
     )
   }
 
@@ -495,14 +495,14 @@ function genModulePreamble(
 function genAssets(
   assets: string[],
   type: 'component' | 'directive' | 'filter',
-  { helper, push, newline, isTS }: CodegenContext
+  { helper, push, newline, isTS }: CodegenContext,
 ) {
   const resolver = helper(
     __COMPAT__ && type === 'filter'
       ? RESOLVE_FILTER
       : type === 'component'
         ? RESOLVE_COMPONENT
-        : RESOLVE_DIRECTIVE
+        : RESOLVE_DIRECTIVE,
   )
   for (let i = 0; i < assets.length; i++) {
     let id = assets[i]
@@ -514,7 +514,7 @@ function genAssets(
     push(
       `const ${toValidAssetId(id, type)} = ${resolver}(${JSON.stringify(id)}${
         maybeSelfReference ? `, true` : ``
-      })${isTS ? `!` : ``}`
+      })${isTS ? `!` : ``}`,
     )
     if (i < assets.length - 1) {
       newline()
@@ -535,8 +535,8 @@ function genHoists(hoists: (JSChildNode | null)[], context: CodegenContext) {
   if (genScopeId) {
     push(
       `const _withScopeId = n => (${helper(
-        PUSH_SCOPE_ID
-      )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`
+        PUSH_SCOPE_ID,
+      )}("${scopeId}"),n=n(),${helper(POP_SCOPE_ID)}(),n)`,
     )
     newline()
   }
@@ -548,7 +548,7 @@ function genHoists(hoists: (JSChildNode | null)[], context: CodegenContext) {
       push(
         `const _hoisted_${i + 1} = ${
           needScopeIdWrapper ? `${PURE_ANNOTATION} _withScopeId(() => ` : ``
-        }`
+        }`,
       )
       genNode(exp, context)
       if (needScopeIdWrapper) {
@@ -585,7 +585,7 @@ function isText(n: string | CodegenNode) {
 
 function genNodeListAsArray(
   nodes: (string | CodegenNode | TemplateChildNode[])[],
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   const multilines =
     nodes.length > 3 ||
@@ -601,7 +601,7 @@ function genNodeList(
   nodes: (string | symbol | CodegenNode | TemplateChildNode[])[],
   context: CodegenContext,
   multilines: boolean = false,
-  comma: boolean = true
+  comma: boolean = true,
 ) {
   const { push, newline } = context
   for (let i = 0; i < nodes.length; i++) {
@@ -641,7 +641,7 @@ function genNode(node: CodegenNode | symbol | string, context: CodegenContext) {
         assert(
           node.codegenNode != null,
           `Codegen node is missing for element/if/for node. ` +
-            `Apply appropriate transforms first.`
+            `Apply appropriate transforms first.`,
         )
       genNode(node.codegenNode!, context)
       break
@@ -722,7 +722,7 @@ function genNode(node: CodegenNode | symbol | string, context: CodegenContext) {
 
 function genText(
   node: TextNode | SimpleExpressionNode,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   context.push(JSON.stringify(node.content), NewlineType.Unknown, node)
 }
@@ -732,7 +732,7 @@ function genExpression(node: SimpleExpressionNode, context: CodegenContext) {
   context.push(
     isStatic ? JSON.stringify(content) : content,
     NewlineType.Unknown,
-    node
+    node,
   )
 }
 
@@ -746,7 +746,7 @@ function genInterpolation(node: InterpolationNode, context: CodegenContext) {
 
 function genCompoundExpression(
   node: CompoundExpressionNode,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   for (let i = 0; i < node.children!.length; i++) {
     const child = node.children![i]
@@ -760,7 +760,7 @@ function genCompoundExpression(
 
 function genExpressionAsPropertyKey(
   node: ExpressionNode,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   const { push } = context
   if (node.type === NodeTypes.COMPOUND_EXPRESSION) {
@@ -786,7 +786,7 @@ function genComment(node: CommentNode, context: CodegenContext) {
   push(
     `${helper(CREATE_COMMENT)}(${JSON.stringify(node.content)})`,
     NewlineType.Unknown,
-    node
+    node,
   )
 }
 
@@ -801,7 +801,7 @@ function genVNodeCall(node: VNodeCall, context: CodegenContext) {
     directives,
     isBlock,
     disableTracking,
-    isComponent
+    isComponent,
   } = node
   if (directives) {
     push(helper(WITH_DIRECTIVES) + `(`)
@@ -818,7 +818,7 @@ function genVNodeCall(node: VNodeCall, context: CodegenContext) {
   push(helper(callHelper) + `(`, NewlineType.None, node)
   genNodeList(
     genNullableArgs([tag, props, children, patchFlag, dynamicProps]),
-    context
+    context,
   )
   push(`)`)
   if (isBlock) {
@@ -887,7 +887,7 @@ function genArrayExpression(node: ArrayExpression, context: CodegenContext) {
 
 function genFunctionExpression(
   node: FunctionExpression,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   const { push, indent, deindent } = context
   const { params, returns, body, newline, isSlot } = node
@@ -932,7 +932,7 @@ function genFunctionExpression(
 
 function genConditionalExpression(
   node: ConditionalExpression,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   const { test, consequent, alternate, newline: needNewline } = node
   const { push, indent, deindent, newline } = context
@@ -1033,7 +1033,7 @@ function genIfStatement(node: IfStatement, context: CodegenContext) {
 
 function genAssignmentExpression(
   node: AssignmentExpression,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   genNode(node.left, context)
   context.push(` = `)
@@ -1042,7 +1042,7 @@ function genAssignmentExpression(
 
 function genSequenceExpression(
   node: SequenceExpression,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   context.push(`(`)
   genNodeList(node.expressions, context)
@@ -1051,7 +1051,7 @@ function genSequenceExpression(
 
 function genReturnStatement(
   { returns }: ReturnStatement,
-  context: CodegenContext
+  context: CodegenContext,
 ) {
   context.push(`return `)
   if (isArray(returns)) {
index eec0499876d87e8acc5cea31e5188f28026d6392..c148d4c196a9d4d0c7ba65d511b7ab5d27595232 100644 (file)
@@ -1,7 +1,7 @@
-import { SourceLocation } from '../ast'
-import { CompilerError } from '../errors'
-import { MergedParserOptions } from '../parser'
-import { TransformContext } from '../transform'
+import type { SourceLocation } from '../ast'
+import type { CompilerError } from '../errors'
+import type { MergedParserOptions } from '../parser'
+import type { TransformContext } from '../transform'
 
 export type CompilerCompatConfig = Partial<
   Record<CompilerDeprecationTypes, boolean | 'suppress-warning'>
@@ -21,7 +21,7 @@ export enum CompilerDeprecationTypes {
   COMPILER_V_IF_V_FOR_PRECEDENCE = 'COMPILER_V_IF_V_FOR_PRECEDENCE',
   COMPILER_NATIVE_TEMPLATE = 'COMPILER_NATIVE_TEMPLATE',
   COMPILER_INLINE_TEMPLATE = 'COMPILER_INLINE_TEMPLATE',
-  COMPILER_FILTERS = 'COMPILER_FILTER'
+  COMPILER_FILTERS = 'COMPILER_FILTER',
 }
 
 type DeprecationData = {
@@ -35,7 +35,7 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
       `Platform-native elements with "is" prop will no longer be ` +
       `treated as components in Vue 3 unless the "is" value is explicitly ` +
       `prefixed with "vue:".`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/custom-elements-interop.html`,
   },
 
   [CompilerDeprecationTypes.COMPILER_V_BIND_SYNC]: {
@@ -43,7 +43,7 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
       `.sync modifier for v-bind has been removed. Use v-model with ` +
       `argument instead. \`v-bind:${key}.sync\` should be changed to ` +
       `\`v-model:${key}\`.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`,
   },
 
   [CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER]: {
@@ -53,12 +53,12 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
       `that appears before v-bind in the case of conflict. ` +
       `To retain 2.x behavior, move v-bind to make it the first attribute. ` +
       `You can also suppress this warning if the usage is intended.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/v-bind.html`,
   },
 
   [CompilerDeprecationTypes.COMPILER_V_ON_NATIVE]: {
     message: `.native modifier for v-on has been removed as is no longer necessary.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/v-on-native-modifier-removed.html`,
   },
 
   [CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE]: {
@@ -68,18 +68,18 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
       `access to v-for scope variables. It is best to avoid the ambiguity ` +
       `with <template> tags or use a computed property that filters v-for ` +
       `data source.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/v-if-v-for.html`,
   },
 
   [CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE]: {
     message:
       `<template> with no special directives will render as a native template ` +
-      `element instead of its inner content in Vue 3.`
+      `element instead of its inner content in Vue 3.`,
   },
 
   [CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE]: {
     message: `"inline-template" has been removed in Vue 3.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/inline-template-attribute.html`,
   },
 
   [CompilerDeprecationTypes.COMPILER_FILTERS]: {
@@ -87,13 +87,13 @@ const deprecationData: Record<CompilerDeprecationTypes, DeprecationData> = {
       `filters have been removed in Vue 3. ` +
       `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
       `Use method calls or computed properties instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
-  }
+    link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`,
+  },
 }
 
 function getCompatValue(
   key: CompilerDeprecationTypes | 'MODE',
-  { compatConfig }: MergedParserOptions | TransformContext
+  { compatConfig }: MergedParserOptions | TransformContext,
 ) {
   const value = compatConfig && compatConfig[key]
   if (key === 'MODE') {
@@ -105,7 +105,7 @@ function getCompatValue(
 
 export function isCompatEnabled(
   key: CompilerDeprecationTypes,
-  context: MergedParserOptions | TransformContext
+  context: MergedParserOptions | TransformContext,
 ) {
   const mode = getCompatValue('MODE', context)
   const value = getCompatValue(key, context)
index 77331db4d806015759ec0c9b0b51d8b7e1328aef..86d11f52a600edd6de34dee5de5bc8f4d4ea5106 100644 (file)
@@ -1,17 +1,17 @@
 import { RESOLVE_FILTER } from '../runtimeHelpers'
 import {
-  ExpressionNode,
-  AttributeNode,
-  DirectiveNode,
+  type AttributeNode,
+  type DirectiveNode,
+  type ExpressionNode,
   NodeTypes,
-  SimpleExpressionNode
+  type SimpleExpressionNode,
 } from '../ast'
 import {
   CompilerDeprecationTypes,
   isCompatEnabled,
-  warnDeprecation
+  warnDeprecation,
 } from './compatConfig'
-import { NodeTransform, TransformContext } from '../transform'
+import type { NodeTransform, TransformContext } from '../transform'
 import { toValidAssetId } from '../utils'
 
 const validDivisionCharRE = /[\w).+\-_$\]]/
@@ -162,7 +162,7 @@ function parseFilter(node: SimpleExpressionNode, context: TransformContext) {
       warnDeprecation(
         CompilerDeprecationTypes.COMPILER_FILTERS,
         context,
-        node.loc
+        node.loc,
       )
     for (i = 0; i < filters.length; i++) {
       expression = wrapFilter(expression, filters[i], context)
@@ -174,7 +174,7 @@ function parseFilter(node: SimpleExpressionNode, context: TransformContext) {
 function wrapFilter(
   exp: string,
   filter: string,
-  context: TransformContext
+  context: TransformContext,
 ): string {
   context.helper(RESOLVE_FILTER)
   const i = filter.indexOf('(')
index d5a9b0194bebb0f405175f64de41464cc1d89447..854c2bc6d69be0c5f643e882d927ce63ed7a2b75 100644 (file)
@@ -1,9 +1,13 @@
-import { CompilerOptions } from './options'
+import type { CompilerOptions } from './options'
 import { baseParse } from './parser'
-import { transform, NodeTransform, DirectiveTransform } from './transform'
-import { generate, CodegenResult } from './codegen'
-import { RootNode } from './ast'
-import { isString, extend } from '@vue/shared'
+import {
+  type DirectiveTransform,
+  type NodeTransform,
+  transform,
+} from './transform'
+import { type CodegenResult, generate } from './codegen'
+import type { RootNode } from './ast'
+import { extend, isString } from '@vue/shared'
 import { transformIf } from './transforms/vIf'
 import { transformFor } from './transforms/vFor'
 import { transformExpression } from './transforms/transformExpression'
@@ -16,16 +20,16 @@ import { transformText } from './transforms/transformText'
 import { transformOnce } from './transforms/vOnce'
 import { transformModel } from './transforms/vModel'
 import { transformFilter } from './compat/transformFilter'
-import { defaultOnError, createCompilerError, ErrorCodes } from './errors'
+import { ErrorCodes, createCompilerError, defaultOnError } from './errors'
 import { transformMemo } from './transforms/vMemo'
 
 export type TransformPreset = [
   NodeTransform[],
-  Record<string, DirectiveTransform>
+  Record<string, DirectiveTransform>,
 ]
 
 export function getBaseTransformPreset(
-  prefixIdentifiers?: boolean
+  prefixIdentifiers?: boolean,
 ): TransformPreset {
   return [
     [
@@ -38,7 +42,7 @@ export function getBaseTransformPreset(
         ? [
             // order is important
             trackVForSlotScopes,
-            transformExpression
+            transformExpression,
           ]
         : __BROWSER__ && __DEV__
           ? [transformExpression]
@@ -46,13 +50,13 @@ export function getBaseTransformPreset(
       transformSlotOutlet,
       transformElement,
       trackSlotScopes,
-      transformText
+      transformText,
     ],
     {
       on: transformOn,
       bind: transformBind,
-      model: transformModel
-    }
+      model: transformModel,
+    },
   ]
 }
 
@@ -60,7 +64,7 @@ export function getBaseTransformPreset(
 // @vue/compiler-dom can export `compile` while re-exporting everything else.
 export function baseCompile(
   source: string | RootNode,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ): CodegenResult {
   const onError = options.onError || defaultOnError
   const isModuleMode = options.mode === 'module'
@@ -83,7 +87,7 @@ export function baseCompile(
   }
 
   const resolvedOptions = extend({}, options, {
-    prefixIdentifiers
+    prefixIdentifiers,
   })
   const ast = isString(source) ? baseParse(source, resolvedOptions) : source
   const [nodeTransforms, directiveTransforms] =
@@ -101,14 +105,14 @@ export function baseCompile(
     extend({}, resolvedOptions, {
       nodeTransforms: [
         ...nodeTransforms,
-        ...(options.nodeTransforms || []) // user transforms
+        ...(options.nodeTransforms || []), // user transforms
       ],
       directiveTransforms: extend(
         {},
         directiveTransforms,
-        options.directiveTransforms || {} // user transforms
-      )
-    })
+        options.directiveTransforms || {}, // user transforms
+      ),
+    }),
   )
 
   return generate(ast, resolvedOptions)
index c9047fc86e7188befb237c8d7bc22d0b02f7cd13..257bc64faaacdbfa1249ea51d1d87c0cc15e0014 100644 (file)
@@ -1,4 +1,4 @@
-import { SourceLocation } from './ast'
+import type { SourceLocation } from './ast'
 
 export interface CompilerError extends SyntaxError {
   code: number | string
@@ -25,7 +25,7 @@ export function createCompilerError<T extends number>(
   code: T,
   loc?: SourceLocation,
   messages?: { [code: number]: string },
-  additionalMessage?: string
+  additionalMessage?: string,
 ): InferCompilerError<T> {
   const msg =
     __DEV__ || !__BROWSER__
@@ -101,7 +101,7 @@ export enum ErrorCodes {
   // Special value for higher-order compilers to pick up the last code
   // to avoid collision of error codes. This should always be kept as the last
   // item.
-  __EXTEND_POINT__
+  __EXTEND_POINT__,
 }
 
 export const errorMessages: Record<ErrorCodes, string> = {
@@ -182,5 +182,5 @@ export const errorMessages: Record<ErrorCodes, string> = {
   [ErrorCodes.X_SCOPE_ID_NOT_SUPPORTED]: `"scopeId" option is only supported in module mode.`,
 
   // just to fulfill types
-  [ErrorCodes.__EXTEND_POINT__]: ``
+  [ErrorCodes.__EXTEND_POINT__]: ``,
 }
index 74ca59e69eee733e73dd5db360ca5ef3e2bc6811..ef4e54cf2d7175c5d680c38a112a25bb91ed163c 100644 (file)
@@ -8,7 +8,7 @@ export {
   type CodegenOptions,
   type HoistTransform,
   type BindingMetadata,
-  BindingTypes
+  BindingTypes,
 } from './options'
 export { baseParse } from './parser'
 export {
@@ -19,7 +19,7 @@ export {
   createStructuralDirectiveTransform,
   type NodeTransform,
   type StructuralDirectiveTransform,
-  type DirectiveTransform
+  type DirectiveTransform,
 } from './transform'
 export { generate, type CodegenContext, type CodegenResult } from './codegen'
 export {
@@ -27,7 +27,7 @@ export {
   errorMessages,
   createCompilerError,
   type CoreCompilerError,
-  type CompilerError
+  type CompilerError,
 } from './errors'
 
 export * from './ast'
@@ -45,20 +45,20 @@ export { processFor, createForLoopParams } from './transforms/vFor'
 export {
   transformExpression,
   processExpression,
-  stringifyExpression
+  stringifyExpression,
 } from './transforms/transformExpression'
 export {
   buildSlots,
   type SlotFnBuilder,
   trackVForSlotScopes,
-  trackSlotScopes
+  trackSlotScopes,
 } from './transforms/vSlot'
 export {
   transformElement,
   resolveComponentType,
   buildProps,
   buildDirectiveArgs,
-  type PropsExpression
+  type PropsExpression,
 } from './transforms/transformElement'
 export { processSlotOutlet } from './transforms/transformSlotOutlet'
 export { getConstantType } from './transforms/hoistStatic'
@@ -68,5 +68,5 @@ export { generateCodeFrame } from '@vue/shared'
 export {
   checkCompatEnabled,
   warnDeprecation,
-  CompilerDeprecationTypes
+  CompilerDeprecationTypes,
 } from './compat/compatConfig'
index 5710039ca10b08ebbca5a5d6edcea4b17e54665c..8a989a8c659f0d4925c13632ef60dcaefac21bed 100644 (file)
@@ -1,18 +1,18 @@
-import {
+import type {
   ElementNode,
   Namespace,
-  TemplateChildNode,
+  Namespaces,
   ParentNode,
-  Namespaces
+  TemplateChildNode,
 } from './ast'
-import { CompilerError } from './errors'
-import {
-  NodeTransform,
+import type { CompilerError } from './errors'
+import type {
   DirectiveTransform,
-  TransformContext
+  NodeTransform,
+  TransformContext,
 } from './transform'
-import { CompilerCompatOptions } from './compat/compatConfig'
-import { ParserPlugin } from '@babel/parser'
+import type { CompilerCompatOptions } from './compat/compatConfig'
+import type { ParserPlugin } from '@babel/parser'
 
 export interface ErrorHandlingOptions {
   onWarn?: (warning: CompilerError) => void
@@ -66,7 +66,7 @@ export interface ParserOptions
   getNamespace?: (
     tag: string,
     parent: ElementNode | undefined,
-    rootNamespace: Namespace
+    rootNamespace: Namespace,
   ) => Namespace
   /**
    * @default ['{{', '}}']
@@ -102,7 +102,7 @@ export interface ParserOptions
 export type HoistTransform = (
   children: TemplateChildNode[],
   context: TransformContext,
-  parent: ParentNode
+  parent: ParentNode,
 ) => void
 
 export enum BindingTypes {
@@ -148,7 +148,7 @@ export enum BindingTypes {
   /**
    * a literal constant, e.g. 'foo', 1, true
    */
-  LITERAL_CONST = 'literal-const'
+  LITERAL_CONST = 'literal-const',
 }
 
 export type BindingMetadata = {
index 923d161dd738f593baf1133dd40e103715d2a4ac..e73bffdeb3e8bb01dc8d4ae7a9fc026353d8a884 100644 (file)
@@ -1,20 +1,20 @@
 import {
-  AttributeNode,
+  type AttributeNode,
   ConstantTypes,
-  DirectiveNode,
-  ElementNode,
+  type DirectiveNode,
+  type ElementNode,
   ElementTypes,
-  ForParseResult,
+  type ForParseResult,
   Namespaces,
   NodeTypes,
-  RootNode,
-  SimpleExpressionNode,
-  SourceLocation,
-  TemplateChildNode,
+  type RootNode,
+  type SimpleExpressionNode,
+  type SourceLocation,
+  type TemplateChildNode,
   createRoot,
-  createSimpleExpression
+  createSimpleExpression,
 } from './ast'
-import { ParserOptions } from './options'
+import type { ParserOptions } from './options'
 import Tokenizer, {
   CharCodes,
   ParseMode,
@@ -22,33 +22,33 @@ import Tokenizer, {
   Sequences,
   State,
   isWhitespace,
-  toCharCodes
+  toCharCodes,
 } from './tokenizer'
 import {
-  CompilerCompatOptions,
+  type CompilerCompatOptions,
   CompilerDeprecationTypes,
   checkCompatEnabled,
   isCompatEnabled,
-  warnDeprecation
+  warnDeprecation,
 } from './compat/compatConfig'
 import { NO, extend } from '@vue/shared'
 import {
   ErrorCodes,
   createCompilerError,
   defaultOnError,
-  defaultOnWarn
+  defaultOnWarn,
 } from './errors'
 import {
   forAliasRE,
   isCoreComponent,
   isSimpleIdentifier,
-  isStaticArgOf
+  isStaticArgOf,
 } from './utils'
 import { decodeHTML } from 'entities/lib/decode.js'
 import {
+  type ParserOptions as BabelOptions,
   parse,
   parseExpression,
-  type ParserOptions as BabelOptions
 } from '@babel/parser'
 
 type OptionalOptions =
@@ -76,7 +76,7 @@ export const defaultParserOptions: MergedParserOptions = {
   onError: defaultOnError,
   onWarn: defaultOnWarn,
   comments: __DEV__,
-  prefixIdentifiers: false
+  prefixIdentifiers: false,
 }
 
 let currentOptions: MergedParserOptions = defaultParserOptions
@@ -129,7 +129,7 @@ const tokenizer = new Tokenizer(stack, {
     addNode({
       type: NodeTypes.INTERPOLATION,
       content: createExp(exp, false, getLoc(innerStart, innerEnd)),
-      loc: getLoc(start, end)
+      loc: getLoc(start, end),
     })
   },
 
@@ -143,7 +143,7 @@ const tokenizer = new Tokenizer(stack, {
       props: [],
       children: [],
       loc: getLoc(start - 1, end),
-      codegenNode: undefined
+      codegenNode: undefined,
     }
   },
 
@@ -191,7 +191,7 @@ const tokenizer = new Tokenizer(stack, {
       name: getSlice(start, end),
       nameLoc: getLoc(start, end),
       value: undefined,
-      loc: getLoc(start)
+      loc: getLoc(start),
     }
   },
 
@@ -216,7 +216,7 @@ const tokenizer = new Tokenizer(stack, {
         name: raw,
         nameLoc: getLoc(start, end),
         value: undefined,
-        loc: getLoc(start)
+        loc: getLoc(start),
       }
     } else {
       currentProp = {
@@ -226,7 +226,7 @@ const tokenizer = new Tokenizer(stack, {
         exp: undefined,
         arg: undefined,
         modifiers: raw === '.' ? ['prop'] : [],
-        loc: getLoc(start)
+        loc: getLoc(start),
       }
       if (name === 'pre') {
         inVPre = tokenizer.inVPre = true
@@ -254,7 +254,7 @@ const tokenizer = new Tokenizer(stack, {
         isStatic ? arg : arg.slice(1, -1),
         isStatic,
         getLoc(start, end),
-        isStatic ? ConstantTypes.CAN_STRINGIFY : ConstantTypes.NOT_CONSTANT
+        isStatic ? ConstantTypes.CAN_STRINGIFY : ConstantTypes.NOT_CONSTANT,
       )
     }
   },
@@ -298,7 +298,7 @@ const tokenizer = new Tokenizer(stack, {
     // check duplicate attrs
     if (
       currentOpenTag!.props.some(
-        p => (p.type === NodeTypes.DIRECTIVE ? p.rawName : p.name) === name
+        p => (p.type === NodeTypes.DIRECTIVE ? p.rawName : p.name) === name,
       )
     ) {
       emitError(ErrorCodes.DUPLICATE_ATTRIBUTE, start)
@@ -314,7 +314,7 @@ const tokenizer = new Tokenizer(stack, {
         if (__BROWSER__ && currentAttrValue.includes('&')) {
           currentAttrValue = currentOptions.decodeEntities!(
             currentAttrValue,
-            true
+            true,
           )
         }
 
@@ -336,7 +336,7 @@ const tokenizer = new Tokenizer(stack, {
             loc:
               quote === QuoteType.Unquoted
                 ? getLoc(currentAttrStartIndex, currentAttrEndIndex)
-                : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1)
+                : getLoc(currentAttrStartIndex - 1, currentAttrEndIndex + 1),
           }
           if (
             tokenizer.inSFCRoot &&
@@ -369,7 +369,7 @@ const tokenizer = new Tokenizer(stack, {
             false,
             getLoc(currentAttrStartIndex, currentAttrEndIndex),
             ConstantTypes.NOT_CONSTANT,
-            expParseMode
+            expParseMode,
           )
           if (currentProp.name === 'for') {
             currentProp.forParseResult = parseForExpression(currentProp.exp)
@@ -384,7 +384,7 @@ const tokenizer = new Tokenizer(stack, {
               CompilerDeprecationTypes.COMPILER_V_BIND_SYNC,
               currentOptions,
               currentProp.loc,
-              currentProp.rawName
+              currentProp.rawName,
             )
           ) {
             currentProp.name = 'model'
@@ -408,7 +408,7 @@ const tokenizer = new Tokenizer(stack, {
       addNode({
         type: NodeTypes.COMMENT,
         content: getSlice(start, end),
-        loc: getLoc(start - 4, end + 3)
+        loc: getLoc(start - 4, end + 3),
       })
     }
   },
@@ -426,7 +426,7 @@ const tokenizer = new Tokenizer(stack, {
         case State.InterpolationClose:
           emitError(
             ErrorCodes.X_MISSING_INTERPOLATION_END,
-            tokenizer.sectionStart
+            tokenizer.sectionStart,
           )
           break
         case State.InCommentLike:
@@ -476,10 +476,10 @@ const tokenizer = new Tokenizer(stack, {
     if ((stack[0] ? stack[0].ns : currentOptions.ns) === Namespaces.HTML) {
       emitError(
         ErrorCodes.UNEXPECTED_QUESTION_MARK_INSTEAD_OF_TAG_NAME,
-        start - 1
+        start - 1,
       )
     }
-  }
+  },
 })
 
 // This regex doesn't cover the case if key or index aliases have destructuring,
@@ -488,7 +488,7 @@ const forIteratorRE = /,([^,\}\]]*)(?:,([^,\}\]]*))?$/
 const stripParensRE = /^\(|\)$/g
 
 function parseForExpression(
-  input: SimpleExpressionNode
+  input: SimpleExpressionNode,
 ): ForParseResult | undefined {
   const loc = input.loc
   const exp = input.content
@@ -500,7 +500,7 @@ function parseForExpression(
   const createAliasExpression = (
     content: string,
     offset: number,
-    asParam = false
+    asParam = false,
   ) => {
     const start = loc.start.offset + offset
     const end = start + content.length
@@ -509,7 +509,7 @@ function parseForExpression(
       false,
       getLoc(start, end),
       ConstantTypes.NOT_CONSTANT,
-      asParam ? ExpParseMode.Params : ExpParseMode.Normal
+      asParam ? ExpParseMode.Params : ExpParseMode.Normal,
     )
   }
 
@@ -518,7 +518,7 @@ function parseForExpression(
     value: undefined,
     key: undefined,
     index: undefined,
-    finalized: false
+    finalized: false,
   }
 
   let valueContent = LHS.trim().replace(stripParensRE, '').trim()
@@ -545,9 +545,9 @@ function parseForExpression(
             indexContent,
             result.key
               ? keyOffset! + keyContent.length
-              : trimmedOffset + valueContent.length
+              : trimmedOffset + valueContent.length,
           ),
-          true
+          true,
         )
       }
     }
@@ -602,7 +602,7 @@ function onText(content: string, start: number, end: number) {
     parent.children.push({
       type: NodeTypes.TEXT,
       content,
-      loc: getLoc(start, end)
+      loc: getLoc(start, end),
     })
   }
 }
@@ -625,7 +625,7 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
     }
     el.innerLoc!.source = getSlice(
       el.innerLoc!.start.offset,
-      el.innerLoc!.end.offset
+      el.innerLoc!.end.offset,
     )
   }
 
@@ -666,7 +666,7 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
       __DEV__ &&
       isCompatEnabled(
         CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE,
-        currentOptions
+        currentOptions,
       )
     ) {
       let hasIf = false
@@ -684,7 +684,7 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
           warnDeprecation(
             CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE,
             currentOptions,
-            el.loc
+            el.loc,
           )
           break
         }
@@ -694,7 +694,7 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
     if (
       isCompatEnabled(
         CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE,
-        currentOptions
+        currentOptions,
       ) &&
       el.tag === 'template' &&
       !isFragmentTemplate(el)
@@ -703,7 +703,7 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
         warnDeprecation(
           CompilerDeprecationTypes.COMPILER_NATIVE_TEMPLATE,
           currentOptions,
-          el.loc
+          el.loc,
         )
       // unwrap
       const parent = stack[0] || currentRoot
@@ -712,14 +712,14 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
     }
 
     const inlineTemplateProp = props.find(
-      p => p.type === NodeTypes.ATTRIBUTE && p.name === 'inline-template'
+      p => p.type === NodeTypes.ATTRIBUTE && p.name === 'inline-template',
     ) as AttributeNode
     if (
       inlineTemplateProp &&
       checkCompatEnabled(
         CompilerDeprecationTypes.COMPILER_INLINE_TEMPLATE,
         currentOptions,
-        inlineTemplateProp.loc
+        inlineTemplateProp.loc,
       ) &&
       el.children.length
     ) {
@@ -727,9 +727,9 @@ function onCloseTag(el: ElementNode, end: number, isImplied = false) {
         type: NodeTypes.TEXT,
         content: getSlice(
           el.children[0].loc.start.offset,
-          el.children[el.children.length - 1].loc.end.offset
+          el.children[el.children.length - 1].loc.end.offset,
         ),
-        loc: inlineTemplateProp.loc
+        loc: inlineTemplateProp.loc,
       }
     }
   }
@@ -782,7 +782,7 @@ function isComponent({ tag, props }: ElementNode): boolean {
           checkCompatEnabled(
             CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT,
             currentOptions,
-            p.loc
+            p.loc,
           )
         ) {
           return true
@@ -796,7 +796,7 @@ function isComponent({ tag, props }: ElementNode): boolean {
       checkCompatEnabled(
         CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT,
         currentOptions,
-        p.loc
+        p.loc,
       )
     ) {
       return true
@@ -812,7 +812,7 @@ function isUpperCase(c: number) {
 const windowsNewlineRE = /\r\n/g
 function condenseWhitespace(
   nodes: TemplateChildNode[],
-  tag?: string
+  tag?: string,
 ): TemplateChildNode[] {
   const shouldCondense = currentOptions.whitespace !== 'preserve'
   let removedWhitespace = false
@@ -915,7 +915,7 @@ function getLoc(start: number, end?: number): SourceLocation {
     // @ts-expect-error allow late attachment
     end: end == null ? end : tokenizer.getPos(end),
     // @ts-expect-error allow late attachment
-    source: end == null ? end : getSlice(start, end)
+    source: end == null ? end : getSlice(start, end),
   }
 }
 
@@ -930,10 +930,10 @@ function dirToAttr(dir: DirectiveNode): AttributeNode {
     name: dir.rawName!,
     nameLoc: getLoc(
       dir.loc.start.offset,
-      dir.loc.start.offset + dir.rawName!.length
+      dir.loc.start.offset + dir.rawName!.length,
     ),
     value: undefined,
-    loc: dir.loc
+    loc: dir.loc,
   }
   if (dir.exp) {
     // account for quotes
@@ -947,7 +947,7 @@ function dirToAttr(dir: DirectiveNode): AttributeNode {
     attr.value = {
       type: NodeTypes.TEXT,
       content: (dir.exp as SimpleExpressionNode).content,
-      loc
+      loc,
     }
   }
   return attr
@@ -957,7 +957,7 @@ enum ExpParseMode {
   Normal,
   Params,
   Statements,
-  Skip
+  Skip,
 }
 
 function createExp(
@@ -965,7 +965,7 @@ function createExp(
   isStatic: SimpleExpressionNode['isStatic'] = false,
   loc: SourceLocation,
   constType: ConstantTypes = ConstantTypes.NOT_CONSTANT,
-  parseMode = ExpParseMode.Normal
+  parseMode = ExpParseMode.Normal,
 ) {
   const exp = createSimpleExpression(content, isStatic, loc, constType)
   if (
@@ -982,7 +982,7 @@ function createExp(
     try {
       const plugins = currentOptions.expressionPlugins
       const options: BabelOptions = {
-        plugins: plugins ? [...plugins, 'typescript'] : ['typescript']
+        plugins: plugins ? [...plugins, 'typescript'] : ['typescript'],
       }
       if (parseMode === ExpParseMode.Statements) {
         // v-on with multi-inline-statements, pad 1 char
@@ -1003,7 +1003,7 @@ function createExp(
 
 function emitError(code: ErrorCodes, index: number, message?: string) {
   currentOptions.onError(
-    createCompilerError(code, getLoc(index, index), undefined, message)
+    createCompilerError(code, getLoc(index, index), undefined, message),
   )
 }
 
@@ -1026,7 +1026,7 @@ export function baseParse(input: string, options?: ParserOptions): RootNode {
     let key: keyof ParserOptions
     for (key in options) {
       if (options[key] != null) {
-        // @ts-ignore
+        // @ts-expect-error
         currentOptions[key] = options[key]
       }
     }
@@ -1036,11 +1036,11 @@ export function baseParse(input: string, options?: ParserOptions): RootNode {
     if (!__BROWSER__ && currentOptions.decodeEntities) {
       console.warn(
         `[@vue/compiler-core] decodeEntities option is passed but will be ` +
-          `ignored in non-browser builds.`
+          `ignored in non-browser builds.`,
       )
     } else if (__BROWSER__ && !currentOptions.decodeEntities) {
       throw new Error(
-        `[@vue/compiler-core] decodeEntities option is required in browser builds.`
+        `[@vue/compiler-core] decodeEntities option is required in browser builds.`,
       )
     }
   }
index 3f5ef02479792bf10783ffcff18be6a169c01a17..47ab73e011a1243ae074b2fe557805ef67b70aec 100644 (file)
@@ -13,7 +13,7 @@ export const CREATE_TEXT = Symbol(__DEV__ ? `createTextVNode` : ``)
 export const CREATE_STATIC = Symbol(__DEV__ ? `createStaticVNode` : ``)
 export const RESOLVE_COMPONENT = Symbol(__DEV__ ? `resolveComponent` : ``)
 export const RESOLVE_DYNAMIC_COMPONENT = Symbol(
-  __DEV__ ? `resolveDynamicComponent` : ``
+  __DEV__ ? `resolveDynamicComponent` : ``,
 )
 export const RESOLVE_DIRECTIVE = Symbol(__DEV__ ? `resolveDirective` : ``)
 export const RESOLVE_FILTER = Symbol(__DEV__ ? `resolveFilter` : ``)
@@ -81,7 +81,7 @@ export const helperNameMap: Record<symbol, string> = {
   [UNREF]: `unref`,
   [IS_REF]: `isRef`,
   [WITH_MEMO]: `withMemo`,
-  [IS_MEMO_SAME]: `isMemoSame`
+  [IS_MEMO_SAME]: `isMemoSame`,
 }
 
 export function registerRuntimeHelpers(helpers: Record<symbol, string>) {
index 8adb1b47b4d01078cc9c4a4f3ffa0a4c49a6643e..c63ec6bfbb1f4022e1586403a475795f30b1de0c 100644 (file)
@@ -23,7 +23,7 @@ IN THE SOFTWARE.
  */
 
 import { ErrorCodes } from './errors'
-import { ElementNode, Position } from './ast'
+import type { ElementNode, Position } from './ast'
 
 /**
  * Note: entities is a non-browser-build-only dependency.
@@ -32,16 +32,16 @@ import { ElementNode, Position } from './ast'
  * so that it can be properly treeshaken.
  */
 import {
-  EntityDecoder,
   DecodingMode,
+  EntityDecoder,
+  fromCodePoint,
   htmlDecodeTree,
-  fromCodePoint
 } from 'entities/lib/decode.js'
 
 export enum ParseMode {
   BASE,
   HTML,
-  SFC
+  SFC,
 }
 
 export enum CharCodes {
@@ -77,7 +77,7 @@ export enum CharCodes {
   Colon = 0x3a, // ":"
   At = 0x40, // "@"
   LeftSquare = 91, // "["
-  RightSquare = 93 // "]"
+  RightSquare = 93, // "]"
 }
 
 const defaultDelimitersOpen = new Uint8Array([123, 123]) // "{{"
@@ -134,7 +134,7 @@ export enum State {
 
   InEntity,
 
-  InSFCRootTagName
+  InSFCRootTagName,
 }
 
 /**
@@ -174,7 +174,7 @@ export enum QuoteType {
   NoValue = 0,
   Unquoted = 1,
   Single = 2,
-  Double = 3
+  Double = 3,
 }
 
 export interface Callbacks {
@@ -221,8 +221,8 @@ export const Sequences = {
   StyleEnd: new Uint8Array([0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65]), // `</style`
   TitleEnd: new Uint8Array([0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65]), // `</title`
   TextareaEnd: new Uint8Array([
-    0x3c, 0x2f, 116, 101, 120, 116, 97, 114, 101, 97
-  ]) // `</textarea
+    0x3c, 0x2f, 116, 101, 120, 116, 97, 114, 101, 97,
+  ]), // `</textarea
 }
 
 export default class Tokenizer {
@@ -256,11 +256,11 @@ export default class Tokenizer {
 
   constructor(
     private readonly stack: ElementNode[],
-    private readonly cbs: Callbacks
+    private readonly cbs: Callbacks,
   ) {
     if (!__BROWSER__) {
       this.entityDecoder = new EntityDecoder(htmlDecodeTree, (cp, consumed) =>
-        this.emitCodePoint(cp, consumed)
+        this.emitCodePoint(cp, consumed),
       )
     }
   }
@@ -299,7 +299,7 @@ export default class Tokenizer {
     return {
       column,
       line,
-      offset: index
+      offset: index,
     }
   }
 
@@ -647,7 +647,7 @@ export default class Tokenizer {
       if ((__DEV__ || !__BROWSER__) && c === CharCodes.Eq) {
         this.cbs.onerr(
           ErrorCodes.UNEXPECTED_EQUALS_SIGN_BEFORE_ATTRIBUTE_NAME,
-          this.index
+          this.index,
         )
       }
       this.handleAttrStart(c)
@@ -694,7 +694,7 @@ export default class Tokenizer {
     ) {
       this.cbs.onerr(
         ErrorCodes.UNEXPECTED_CHARACTER_IN_ATTRIBUTE_NAME,
-        this.index
+        this.index,
       )
     }
   }
@@ -733,7 +733,7 @@ export default class Tokenizer {
       if (__DEV__ || !__BROWSER__) {
         this.cbs.onerr(
           ErrorCodes.X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END,
-          this.index
+          this.index,
         )
       }
     }
@@ -785,7 +785,7 @@ export default class Tokenizer {
       this.sectionStart = -1
       this.cbs.onattribend(
         quote === CharCodes.DoubleQuote ? QuoteType.Double : QuoteType.Single,
-        this.index + 1
+        this.index + 1,
       )
       this.state = State.BeforeAttrName
     } else if (!__BROWSER__ && c === CharCodes.Amp) {
@@ -814,7 +814,7 @@ export default class Tokenizer {
     ) {
       this.cbs.onerr(
         ErrorCodes.UNEXPECTED_CHARACTER_IN_UNQUOTED_ATTRIBUTE_VALUE,
-        this.index
+        this.index,
       )
     } else if (!__BROWSER__ && c === CharCodes.Amp) {
       this.startEntity()
@@ -892,7 +892,7 @@ export default class Tokenizer {
       this.entityDecoder!.startEntity(
         this.baseState === State.Text || this.baseState === State.InRCDATA
           ? DecodingMode.Legacy
-          : DecodingMode.Attribute
+          : DecodingMode.Attribute,
       )
     }
   }
@@ -1156,7 +1156,7 @@ export default class Tokenizer {
         this.cbs.onattribentity(
           fromCodePoint(cp),
           this.entityStart,
-          this.sectionStart
+          this.sectionStart,
         )
       } else {
         if (this.sectionStart < this.entityStart) {
@@ -1168,7 +1168,7 @@ export default class Tokenizer {
         this.cbs.ontextentity(
           fromCodePoint(cp),
           this.entityStart,
-          this.sectionStart
+          this.sectionStart,
         )
       }
     }
index 7da34bedb9b5351263754d3935175923df28da08..a7828b6f80d6e2beeec6400f39797894747a647e 100644 (file)
@@ -1,45 +1,45 @@
-import { TransformOptions } from './options'
+import type { TransformOptions } from './options'
 import {
-  RootNode,
-  NodeTypes,
-  ParentNode,
-  TemplateChildNode,
-  ElementNode,
-  DirectiveNode,
-  Property,
-  ExpressionNode,
-  createSimpleExpression,
-  JSChildNode,
-  SimpleExpressionNode,
+  type ArrayExpression,
+  type CacheExpression,
+  ConstantTypes,
+  type DirectiveNode,
+  type ElementNode,
   ElementTypes,
-  CacheExpression,
+  type ExpressionNode,
+  type JSChildNode,
+  NodeTypes,
+  type ParentNode,
+  type Property,
+  type RootNode,
+  type SimpleExpressionNode,
+  type TemplateChildNode,
+  type TemplateLiteral,
+  convertToBlock,
   createCacheExpression,
-  TemplateLiteral,
+  createSimpleExpression,
   createVNodeCall,
-  ConstantTypes,
-  ArrayExpression,
-  convertToBlock
 } from './ast'
 import {
-  isString,
-  isArray,
+  EMPTY_OBJ,
   NOOP,
-  PatchFlags,
   PatchFlagNames,
-  EMPTY_OBJ,
+  PatchFlags,
+  camelize,
   capitalize,
-  camelize
+  isArray,
+  isString,
 } from '@vue/shared'
 import { defaultOnError, defaultOnWarn } from './errors'
 import {
-  TO_DISPLAY_STRING,
+  CREATE_COMMENT,
   FRAGMENT,
+  TO_DISPLAY_STRING,
   helperNameMap,
-  CREATE_COMMENT
 } from './runtimeHelpers'
 import { isVSlot } from './utils'
 import { hoistStatic, isSingleElementRoot } from './transforms/hoistStatic'
-import { CompilerCompatOptions } from './compat/compatConfig'
+import type { CompilerCompatOptions } from './compat/compatConfig'
 
 // There are two types of transforms:
 //
@@ -48,7 +48,7 @@ import { CompilerCompatOptions } from './compat/compatConfig'
 //   replace or remove the node being processed.
 export type NodeTransform = (
   node: RootNode | TemplateChildNode,
-  context: TransformContext
+  context: TransformContext,
 ) => void | (() => void) | (() => void)[]
 
 // - DirectiveTransform:
@@ -60,7 +60,7 @@ export type DirectiveTransform = (
   context: TransformContext,
   // a platform specific compiler can import the base transform and augment
   // it by passing in this optional argument.
-  augmentor?: (ret: DirectiveTransformResult) => DirectiveTransformResult
+  augmentor?: (ret: DirectiveTransformResult) => DirectiveTransformResult,
 ) => DirectiveTransformResult
 
 export interface DirectiveTransformResult {
@@ -74,7 +74,7 @@ export interface DirectiveTransformResult {
 export type StructuralDirectiveTransform = (
   node: ElementNode,
   dir: DirectiveNode,
-  context: TransformContext
+  context: TransformContext,
 ) => void | (() => void)
 
 export interface ImportItem {
@@ -145,8 +145,8 @@ export function createTransformContext(
     isTS = false,
     onError = defaultOnError,
     onWarn = defaultOnWarn,
-    compatConfig
-  }: TransformOptions
+    compatConfig,
+  }: TransformOptions,
 ): TransformContext {
   const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/)
   const context: TransformContext = {
@@ -190,7 +190,7 @@ export function createTransformContext(
       vFor: 0,
       vSlot: 0,
       vPre: 0,
-      vOnce: 0
+      vOnce: 0,
     },
     parent: null,
     currentNode: root,
@@ -287,14 +287,14 @@ export function createTransformContext(
         `_hoisted_${context.hoists.length}`,
         false,
         exp.loc,
-        ConstantTypes.CAN_HOIST
+        ConstantTypes.CAN_HOIST,
       )
       identifier.hoisted = exp
       return identifier
     },
     cache(exp, isVNode = false) {
       return createCacheExpression(context.cached++, exp, isVNode)
-    }
+    },
   }
 
   if (__COMPAT__) {
@@ -383,7 +383,7 @@ function createRootCodegen(root: RootNode, context: TransformContext) {
       undefined,
       true,
       undefined,
-      false /* isComponent */
+      false /* isComponent */,
     )
   } else {
     // no children = noop. codegen will return null.
@@ -392,7 +392,7 @@ function createRootCodegen(root: RootNode, context: TransformContext) {
 
 export function traverseChildren(
   parent: ParentNode,
-  context: TransformContext
+  context: TransformContext,
 ) {
   let i = 0
   const nodeRemoved = () => {
@@ -410,7 +410,7 @@ export function traverseChildren(
 
 export function traverseNode(
   node: RootNode | TemplateChildNode,
-  context: TransformContext
+  context: TransformContext,
 ) {
   context.currentNode = node
   // apply transform plugins
@@ -473,7 +473,7 @@ export function traverseNode(
 
 export function createStructuralDirectiveTransform(
   name: string | RegExp,
-  fn: StructuralDirectiveTransform
+  fn: StructuralDirectiveTransform,
 ): NodeTransform {
   const matches = isString(name)
     ? (n: string) => n === name
index fd443496ca7aeae237e8e67c0a84b9b29386357e..70a0468e5196893ff059d75ab028eda5fc6ba545 100644 (file)
@@ -1,30 +1,30 @@
 import {
+  type CallExpression,
+  type ComponentNode,
   ConstantTypes,
-  RootNode,
-  NodeTypes,
-  TemplateChildNode,
-  SimpleExpressionNode,
   ElementTypes,
-  PlainElementNode,
-  ComponentNode,
-  TemplateNode,
-  VNodeCall,
-  ParentNode,
-  JSChildNode,
-  CallExpression,
+  type JSChildNode,
+  NodeTypes,
+  type ParentNode,
+  type PlainElementNode,
+  type RootNode,
+  type SimpleExpressionNode,
+  type TemplateChildNode,
+  type TemplateNode,
+  type VNodeCall,
   createArrayExpression,
   getVNodeBlockHelper,
-  getVNodeHelper
+  getVNodeHelper,
 } from '../ast'
-import { TransformContext } from '../transform'
-import { PatchFlags, isString, isSymbol, isArray } from '@vue/shared'
+import type { TransformContext } from '../transform'
+import { PatchFlags, isArray, isString, isSymbol } from '@vue/shared'
 import { isSlotOutlet } from '../utils'
 import {
-  OPEN_BLOCK,
   GUARD_REACTIVE_PROPS,
   NORMALIZE_CLASS,
   NORMALIZE_PROPS,
-  NORMALIZE_STYLE
+  NORMALIZE_STYLE,
+  OPEN_BLOCK,
 } from '../runtimeHelpers'
 
 export function hoistStatic(root: RootNode, context: TransformContext) {
@@ -33,13 +33,13 @@ export function hoistStatic(root: RootNode, context: TransformContext) {
     context,
     // Root node is unfortunately non-hoistable due to potential parent
     // fallthrough attributes.
-    isSingleElementRoot(root, root.children[0])
+    isSingleElementRoot(root, root.children[0]),
   )
 }
 
 export function isSingleElementRoot(
   root: RootNode,
-  child: TemplateChildNode
+  child: TemplateChildNode,
 ): child is PlainElementNode | ComponentNode | TemplateNode {
   const { children } = root
   return (
@@ -52,7 +52,7 @@ export function isSingleElementRoot(
 function walk(
   node: ParentNode,
   context: TransformContext,
-  doNotHoistNode: boolean = false
+  doNotHoistNode: boolean = false,
 ) {
   const { children } = node
   const originalCount = children.length
@@ -120,7 +120,7 @@ function walk(
         walk(
           child.branches[i],
           context,
-          child.branches[i].children.length === 1
+          child.branches[i].children.length === 1,
         )
       }
     }
@@ -141,7 +141,7 @@ function walk(
     isArray(node.codegenNode.children)
   ) {
     const hoisted = context.hoist(
-      createArrayExpression(node.codegenNode.children)
+      createArrayExpression(node.codegenNode.children),
     )
     // #6978, #7138, #7114
     // a hoisted children array inside v-for can caused HMR errors since
@@ -155,7 +155,7 @@ function walk(
 
 export function getConstantType(
   node: TemplateChildNode | SimpleExpressionNode,
-  context: TransformContext
+  context: TransformContext,
 ): ConstantTypes {
   const { constantCache } = context
   switch (node.type) {
@@ -244,7 +244,7 @@ export function getConstantType(
 
           context.removeHelper(OPEN_BLOCK)
           context.removeHelper(
-            getVNodeBlockHelper(context.inSSR, codegenNode.isComponent)
+            getVNodeBlockHelper(context.inSSR, codegenNode.isComponent),
           )
           codegenNode.isBlock = false
           context.helper(getVNodeHelper(context.inSSR, codegenNode.isComponent))
@@ -296,12 +296,12 @@ const allowHoistedHelperSet = new Set([
   NORMALIZE_CLASS,
   NORMALIZE_STYLE,
   NORMALIZE_PROPS,
-  GUARD_REACTIVE_PROPS
+  GUARD_REACTIVE_PROPS,
 ])
 
 function getConstantTypeOfHelperCall(
   value: CallExpression,
-  context: TransformContext
+  context: TransformContext,
 ): ConstantTypes {
   if (
     value.type === NodeTypes.JS_CALL_EXPRESSION &&
@@ -321,7 +321,7 @@ function getConstantTypeOfHelperCall(
 
 function getGeneratedPropsConstantType(
   node: PlainElementNode,
-  context: TransformContext
+  context: TransformContext,
 ): ConstantTypes {
   let returnType = ConstantTypes.CAN_STRINGIFY
   const props = getNodeProps(node)
index 5975069be0f59afb8a4810bb82d57511fe6806ae..cd8e21453ce1cdd39dbf13c454dedef4f3ad8cb1 100644 (file)
@@ -1,3 +1,3 @@
-import { DirectiveTransform } from '../transform'
+import type { DirectiveTransform } from '../transform'
 
 export const noopDirectiveTransform: DirectiveTransform = () => ({ props: [] })
index 6f35f4f8e71853b8370184939b32160969bb36fa..c50f7f5e96933ee61a6ea79748a6926d4b3823df 100644 (file)
@@ -1,68 +1,68 @@
-import { NodeTransform, TransformContext } from '../transform'
+import type { NodeTransform, TransformContext } from '../transform'
 import {
-  NodeTypes,
+  type ArrayExpression,
+  type CallExpression,
+  type ComponentNode,
+  ConstantTypes,
+  type DirectiveArguments,
+  type DirectiveNode,
+  type ElementNode,
   ElementTypes,
-  CallExpression,
-  ObjectExpression,
-  ElementNode,
-  DirectiveNode,
-  ExpressionNode,
-  ArrayExpression,
-  createCallExpression,
+  type ExpressionNode,
+  type JSChildNode,
+  NodeTypes,
+  type ObjectExpression,
+  type Property,
+  type TemplateTextChildNode,
+  type VNodeCall,
   createArrayExpression,
+  createCallExpression,
+  createObjectExpression,
   createObjectProperty,
   createSimpleExpression,
-  createObjectExpression,
-  Property,
-  ComponentNode,
-  VNodeCall,
-  TemplateTextChildNode,
-  DirectiveArguments,
   createVNodeCall,
-  ConstantTypes,
-  JSChildNode
 } from '../ast'
 import {
-  PatchFlags,
   PatchFlagNames,
-  isSymbol,
-  isOn,
+  PatchFlags,
+  camelize,
+  capitalize,
+  isBuiltInDirective,
   isObject,
+  isOn,
   isReservedProp,
-  capitalize,
-  camelize,
-  isBuiltInDirective
+  isSymbol,
 } from '@vue/shared'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { ErrorCodes, createCompilerError } from '../errors'
 import {
-  RESOLVE_DIRECTIVE,
-  RESOLVE_COMPONENT,
-  RESOLVE_DYNAMIC_COMPONENT,
+  GUARD_REACTIVE_PROPS,
+  KEEP_ALIVE,
   MERGE_PROPS,
   NORMALIZE_CLASS,
-  NORMALIZE_STYLE,
   NORMALIZE_PROPS,
-  TO_HANDLERS,
-  TELEPORT,
-  KEEP_ALIVE,
+  NORMALIZE_STYLE,
+  RESOLVE_COMPONENT,
+  RESOLVE_DIRECTIVE,
+  RESOLVE_DYNAMIC_COMPONENT,
   SUSPENSE,
+  TELEPORT,
+  TO_HANDLERS,
   UNREF,
-  GUARD_REACTIVE_PROPS
 } from '../runtimeHelpers'
 import {
-  toValidAssetId,
   findProp,
   isCoreComponent,
   isStaticArgOf,
-  isStaticExp
+  isStaticExp,
+  toValidAssetId,
 } from '../utils'
 import { buildSlots } from './vSlot'
 import { getConstantType } from './hoistStatic'
 import { BindingTypes } from '../options'
 import {
-  checkCompatEnabled,
   CompilerDeprecationTypes,
-  isCompatEnabled
+  checkCompatEnabled,
+  isCompatEnabled,
 } from '../compat/compatConfig'
 
 // some directive transforms (e.g. v-model) may return a symbol for runtime
@@ -125,7 +125,7 @@ export const transformElement: NodeTransform = (node, context) => {
         context,
         undefined,
         isComponent,
-        isDynamicComponent
+        isDynamicComponent,
       )
       vnodeProps = propsBuildResult.props
       patchFlag = propsBuildResult.patchFlag
@@ -134,7 +134,7 @@ export const transformElement: NodeTransform = (node, context) => {
       vnodeDirectives =
         directives && directives.length
           ? (createArrayExpression(
-              directives.map(dir => buildDirectiveArgs(dir, context))
+              directives.map(dir => buildDirectiveArgs(dir, context)),
             ) as DirectiveArguments)
           : undefined
 
@@ -160,8 +160,8 @@ export const transformElement: NodeTransform = (node, context) => {
             createCompilerError(ErrorCodes.X_KEEP_ALIVE_INVALID_CHILDREN, {
               start: node.children[0].loc.start,
               end: node.children[node.children.length - 1].loc.end,
-              source: ''
-            })
+              source: '',
+            }),
           )
         }
       }
@@ -239,7 +239,7 @@ export const transformElement: NodeTransform = (node, context) => {
       !!shouldUseBlock,
       false /* disableTracking */,
       isComponent,
-      node.loc
+      node.loc,
     )
   }
 }
@@ -247,7 +247,7 @@ export const transformElement: NodeTransform = (node, context) => {
 export function resolveComponentType(
   node: ComponentNode,
   context: TransformContext,
-  ssr = false
+  ssr = false,
 ) {
   let { tag } = node
 
@@ -260,7 +260,7 @@ export function resolveComponentType(
       (__COMPAT__ &&
         isCompatEnabled(
           CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT,
-          context
+          context,
         ))
     ) {
       const exp =
@@ -269,7 +269,7 @@ export function resolveComponentType(
           : isProp.exp
       if (exp) {
         return createCallExpression(context.helper(RESOLVE_DYNAMIC_COMPONENT), [
-          exp
+          exp,
         ])
       }
     } else if (
@@ -388,7 +388,7 @@ export function buildProps(
   props: ElementNode['props'] = node.props,
   isComponent: boolean,
   isDynamicComponent: boolean,
-  ssr = false
+  ssr = false,
 ): {
   props: PropsExpression | undefined
   directives: DirectiveNode[]
@@ -416,7 +416,7 @@ export function buildProps(
   const pushMergeArg = (arg?: PropsExpression) => {
     if (properties.length) {
       mergeArgs.push(
-        createObjectExpression(dedupeProperties(properties), elementLoc)
+        createObjectExpression(dedupeProperties(properties), elementLoc),
       )
       properties = []
     }
@@ -496,8 +496,8 @@ export function buildProps(
           properties.push(
             createObjectProperty(
               createSimpleExpression('ref_for', true),
-              createSimpleExpression('true')
-            )
+              createSimpleExpression('true'),
+            ),
           )
         }
         // in inline mode there is no setupState object, so we can't use string
@@ -514,8 +514,8 @@ export function buildProps(
             properties.push(
               createObjectProperty(
                 createSimpleExpression('ref_key', true),
-                createSimpleExpression(value.content, true, value.loc)
-              )
+                createSimpleExpression(value.content, true, value.loc),
+              ),
             )
           }
         }
@@ -528,7 +528,7 @@ export function buildProps(
           (__COMPAT__ &&
             isCompatEnabled(
               CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT,
-              context
+              context,
             )))
       ) {
         continue
@@ -539,9 +539,9 @@ export function buildProps(
           createSimpleExpression(
             value ? value.content : '',
             isStatic,
-            value ? value.loc : loc
-          )
-        )
+            value ? value.loc : loc,
+          ),
+        ),
       )
     } else {
       // directives
@@ -553,7 +553,7 @@ export function buildProps(
       if (name === 'slot') {
         if (!isComponent) {
           context.onError(
-            createCompilerError(ErrorCodes.X_V_SLOT_MISPLACED, loc)
+            createCompilerError(ErrorCodes.X_V_SLOT_MISPLACED, loc),
           )
         }
         continue
@@ -571,7 +571,7 @@ export function buildProps(
             (__COMPAT__ &&
               isCompatEnabled(
                 CompilerDeprecationTypes.COMPILER_IS_ON_ELEMENT,
-                context
+                context,
               ))))
       ) {
         continue
@@ -595,8 +595,8 @@ export function buildProps(
         properties.push(
           createObjectProperty(
             createSimpleExpression('ref_for', true),
-            createSimpleExpression('true')
-          )
+            createSimpleExpression('true'),
+          ),
         )
       }
 
@@ -634,7 +634,7 @@ export function buildProps(
                   checkCompatEnabled(
                     CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER,
                     context,
-                    loc
+                    loc,
                   )
                 }
               }
@@ -642,7 +642,7 @@ export function buildProps(
               if (
                 isCompatEnabled(
                   CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER,
-                  context
+                  context,
                 )
               ) {
                 mergeArgs.unshift(exp)
@@ -657,7 +657,7 @@ export function buildProps(
               type: NodeTypes.JS_CALL_EXPRESSION,
               loc,
               callee: context.helper(TO_HANDLERS),
-              arguments: isComponent ? [exp] : [exp, `true`]
+              arguments: isComponent ? [exp] : [exp, `true`],
             })
           }
         } else {
@@ -666,8 +666,8 @@ export function buildProps(
               isVBind
                 ? ErrorCodes.X_V_BIND_NO_EXPRESSION
                 : ErrorCodes.X_V_ON_NO_EXPRESSION,
-              loc
-            )
+              loc,
+            ),
           )
         }
         continue
@@ -716,7 +716,7 @@ export function buildProps(
       propsExpression = createCallExpression(
         context.helper(MERGE_PROPS),
         mergeArgs,
-        elementLoc
+        elementLoc,
       )
     } else {
       // single v-bind with nothing else - no need for a mergeProps call
@@ -725,7 +725,7 @@ export function buildProps(
   } else if (properties.length) {
     propsExpression = createObjectExpression(
       dedupeProperties(properties),
-      elementLoc
+      elementLoc,
     )
   }
 
@@ -785,7 +785,7 @@ export function buildProps(
           if (classProp && !isStaticExp(classProp.value)) {
             classProp.value = createCallExpression(
               context.helper(NORMALIZE_CLASS),
-              [classProp.value]
+              [classProp.value],
             )
           }
           if (
@@ -801,14 +801,14 @@ export function buildProps(
           ) {
             styleProp.value = createCallExpression(
               context.helper(NORMALIZE_STYLE),
-              [styleProp.value]
+              [styleProp.value],
             )
           }
         } else {
           // dynamic key binding, wrap with `normalizeProps`
           propsExpression = createCallExpression(
             context.helper(NORMALIZE_PROPS),
-            [propsExpression]
+            [propsExpression],
           )
         }
         break
@@ -821,9 +821,9 @@ export function buildProps(
           context.helper(NORMALIZE_PROPS),
           [
             createCallExpression(context.helper(GUARD_REACTIVE_PROPS), [
-              propsExpression
-            ])
-          ]
+              propsExpression,
+            ]),
+          ],
         )
         break
     }
@@ -834,7 +834,7 @@ export function buildProps(
     directives: runtimeDirectives,
     patchFlag,
     dynamicPropNames,
-    shouldUseBlock
+    shouldUseBlock,
   }
 }
 
@@ -875,14 +875,14 @@ function mergeAsArray(existing: Property, incoming: Property) {
   } else {
     existing.value = createArrayExpression(
       [existing.value, incoming.value],
-      existing.loc
+      existing.loc,
     )
   }
 }
 
 export function buildDirectiveArgs(
   dir: DirectiveNode,
-  context: TransformContext
+  context: TransformContext,
 ): ArrayExpression {
   const dirArgs: ArrayExpression['elements'] = []
   const runtime = directiveImportMap.get(dir)
@@ -922,10 +922,10 @@ export function buildDirectiveArgs(
     dirArgs.push(
       createObjectExpression(
         dir.modifiers.map(modifier =>
-          createObjectProperty(modifier, trueExpression)
+          createObjectProperty(modifier, trueExpression),
         ),
-        loc
-      )
+        loc,
+      ),
     )
   }
   return createArrayExpression(dirArgs, dir.loc)
index 263ada4f1378c59c66c0edccc7bff0797b6f4b76..093fb4447ff7f61a2cdfba415437ecae7337f6e0 100644 (file)
@@ -7,36 +7,36 @@
 // - This transform is only applied in non-browser builds because it relies on
 //   an additional JavaScript parser. In the browser, there is no source-map
 //   support and the code is wrapped in `with (this) { ... }`.
-import { NodeTransform, TransformContext } from '../transform'
+import type { NodeTransform, TransformContext } from '../transform'
 import {
+  type CompoundExpressionNode,
+  ConstantTypes,
+  type ExpressionNode,
   NodeTypes,
-  createSimpleExpression,
-  ExpressionNode,
-  SimpleExpressionNode,
-  CompoundExpressionNode,
+  type SimpleExpressionNode,
   createCompoundExpression,
-  ConstantTypes
+  createSimpleExpression,
 } from '../ast'
 import {
   isInDestructureAssignment,
   isStaticProperty,
   isStaticPropertyKey,
-  walkIdentifiers
+  walkIdentifiers,
 } from '../babelUtils'
 import { advancePositionWithClone, isSimpleIdentifier } from '../utils'
 import {
-  isGloballyAllowed,
-  makeMap,
+  genPropsAccessExp,
   hasOwn,
+  isGloballyAllowed,
   isString,
-  genPropsAccessExp
+  makeMap,
 } from '@vue/shared'
-import { createCompilerError, ErrorCodes } from '../errors'
-import {
-  Node,
-  Identifier,
+import { ErrorCodes, createCompilerError } from '../errors'
+import type {
   AssignmentExpression,
-  UpdateExpression
+  Identifier,
+  Node,
+  UpdateExpression,
 } from '@babel/types'
 import { validateBrowserExpression } from '../validateExpression'
 import { parse } from '@babel/parser'
@@ -53,7 +53,7 @@ export const transformExpression: NodeTransform = (node, context) => {
   if (node.type === NodeTypes.INTERPOLATION) {
     node.content = processExpression(
       node.content as SimpleExpressionNode,
-      context
+      context,
     )
   } else if (node.type === NodeTypes.ELEMENT) {
     // handle directives on element
@@ -74,7 +74,7 @@ export const transformExpression: NodeTransform = (node, context) => {
             exp,
             context,
             // slot args must be processed as function params
-            dir.name === 'slot'
+            dir.name === 'slot',
           )
         }
         if (arg && arg.type === NodeTypes.SIMPLE_EXPRESSION && !arg.isStatic) {
@@ -104,7 +104,7 @@ export function processExpression(
   asParams = false,
   // v-on handler values may contain multiple statements
   asRawStatements = false,
-  localVars: Record<string, number> = Object.create(context.identifiers)
+  localVars: Record<string, number> = Object.create(context.identifiers),
 ): ExpressionNode {
   if (__BROWSER__) {
     if (__DEV__) {
@@ -163,8 +163,8 @@ export function processExpression(
               context,
               false,
               false,
-              knownIds
-            )
+              knownIds,
+            ),
           )
           return `${context.helperString(IS_REF)}(${raw})${
             context.isTS ? ` //@ts-ignore\n` : ``
@@ -267,7 +267,7 @@ export function processExpression(
       : `(${rawExp})${asParams ? `=>{}` : ``}`
     try {
       ast = parse(source, {
-        plugins: context.expressionPlugins
+        plugins: context.expressionPlugins,
       }).program
     } catch (e: any) {
       context.onError(
@@ -275,8 +275,8 @@ export function processExpression(
           ErrorCodes.X_INVALID_EXPRESSION,
           node.loc,
           undefined,
-          e.message
-        )
+          e.message,
+        ),
       )
       return node
     }
@@ -320,7 +320,7 @@ export function processExpression(
     },
     true, // invoke on ALL identifiers
     parentStack,
-    knownIds
+    knownIds,
   )
 
   // We break up the compound expression into an array of strings and sub
@@ -346,10 +346,12 @@ export function processExpression(
         {
           start: advancePositionWithClone(node.loc.start, source, start),
           end: advancePositionWithClone(node.loc.start, source, end),
-          source
+          source,
         },
-        id.isConstant ? ConstantTypes.CAN_STRINGIFY : ConstantTypes.NOT_CONSTANT
-      )
+        id.isConstant
+          ? ConstantTypes.CAN_STRINGIFY
+          : ConstantTypes.NOT_CONSTANT,
+      ),
     )
     if (i === ids.length - 1 && end < rawExp.length) {
       children.push(rawExp.slice(end))
index 5fc0af5f7be6949b9588f1672dd63afd57c4f49c..310b6a94ea00f6deb23cfb5d4d28a0a816d62597 100644 (file)
@@ -1,15 +1,15 @@
-import { NodeTransform, TransformContext } from '../transform'
+import type { NodeTransform, TransformContext } from '../transform'
 import {
+  type CallExpression,
+  type ExpressionNode,
   NodeTypes,
-  CallExpression,
+  type SlotOutletNode,
   createCallExpression,
-  ExpressionNode,
-  SlotOutletNode,
-  createFunctionExpression
+  createFunctionExpression,
 } from '../ast'
 import { isSlotOutlet, isStaticArgOf, isStaticExp } from '../utils'
-import { buildProps, PropsExpression } from './transformElement'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { type PropsExpression, buildProps } from './transformElement'
+import { ErrorCodes, createCompilerError } from '../errors'
 import { RENDER_SLOT } from '../runtimeHelpers'
 import { camelize } from '@vue/shared'
 
@@ -23,7 +23,7 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
       slotName,
       '{}',
       'undefined',
-      'true'
+      'true',
     ]
     let expectedLen = 2
 
@@ -45,7 +45,7 @@ export const transformSlotOutlet: NodeTransform = (node, context) => {
     node.codegenNode = createCallExpression(
       context.helper(RENDER_SLOT),
       slotArgs,
-      loc
+      loc,
     )
   }
 }
@@ -57,7 +57,7 @@ interface SlotOutletProcessResult {
 
 export function processSlotOutlet(
   node: SlotOutletNode,
-  context: TransformContext
+  context: TransformContext,
 ): SlotOutletProcessResult {
   let slotName: string | ExpressionNode = `"default"`
   let slotProps: PropsExpression | undefined = undefined
@@ -92,7 +92,7 @@ export function processSlotOutlet(
       context,
       nonNameProps,
       false,
-      false
+      false,
     )
     slotProps = props
 
@@ -100,14 +100,14 @@ export function processSlotOutlet(
       context.onError(
         createCompilerError(
           ErrorCodes.X_V_SLOT_UNEXPECTED_DIRECTIVE_ON_SLOT_OUTLET,
-          directives[0].loc
-        )
+          directives[0].loc,
+        ),
       )
     }
   }
 
   return {
     slotName,
-    slotProps
+    slotProps,
   }
 }
index 2c8ab384fd8a2a1edb83ba805a8a7d64d6b8347d..bdfb37ccb07e01c547834f16c64bb2c830a3ae11 100644 (file)
@@ -1,16 +1,16 @@
-import { NodeTransform } from '../transform'
+import type { NodeTransform } from '../transform'
 import {
+  type CallExpression,
+  type CompoundExpressionNode,
+  ConstantTypes,
+  ElementTypes,
   NodeTypes,
-  CompoundExpressionNode,
   createCallExpression,
-  CallExpression,
-  ElementTypes,
-  ConstantTypes,
-  createCompoundExpression
+  createCompoundExpression,
 } from '../ast'
 import { isText } from '../utils'
 import { CREATE_TEXT } from '../runtimeHelpers'
-import { PatchFlags, PatchFlagNames } from '@vue/shared'
+import { PatchFlagNames, PatchFlags } from '@vue/shared'
 import { getConstantType } from './hoistStatic'
 
 // Merge adjacent text nodes and expressions into a single expression
@@ -39,7 +39,7 @@ export const transformText: NodeTransform = (node, context) => {
               if (!currentContainer) {
                 currentContainer = children[i] = createCompoundExpression(
                   [child],
-                  child.loc
+                  child.loc,
                 )
               }
               // merge adjacent text node into current
@@ -72,7 +72,7 @@ export const transformText: NodeTransform = (node, context) => {
               !node.props.find(
                 p =>
                   p.type === NodeTypes.DIRECTIVE &&
-                  !context.directiveTransforms[p.name]
+                  !context.directiveTransforms[p.name],
               ) &&
               // in compat mode, <template> tags with no special directives
               // will be rendered as a fragment so its children must be
@@ -100,7 +100,7 @@ export const transformText: NodeTransform = (node, context) => {
           ) {
             callArgs.push(
               PatchFlags.TEXT +
-                (__DEV__ ? ` /* ${PatchFlagNames[PatchFlags.TEXT]} */` : ``)
+                (__DEV__ ? ` /* ${PatchFlagNames[PatchFlags.TEXT]} */` : ``),
             )
           }
           children[i] = {
@@ -109,8 +109,8 @@ export const transformText: NodeTransform = (node, context) => {
             loc: child.loc,
             codegenNode: createCallExpression(
               context.helper(CREATE_TEXT),
-              callArgs
-            )
+              callArgs,
+            ),
           }
         }
       }
index eba95727bd5f573fa48369393c76bed79a296954..d121775497a73688f57283d8a1abd147fe73f146 100644 (file)
@@ -1,11 +1,11 @@
-import { DirectiveTransform } from '../transform'
+import type { DirectiveTransform } from '../transform'
 import {
+  type ExpressionNode,
+  NodeTypes,
   createObjectProperty,
   createSimpleExpression,
-  ExpressionNode,
-  NodeTypes
 } from '../ast'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { ErrorCodes, createCompilerError } from '../errors'
 import { camelize } from '@vue/shared'
 import { CAMELIZE } from '../runtimeHelpers'
 import { processExpression } from './transformExpression'
@@ -63,12 +63,12 @@ export const transformBind: DirectiveTransform = (dir, _node, context) => {
   ) {
     context.onError(createCompilerError(ErrorCodes.X_V_BIND_NO_EXPRESSION, loc))
     return {
-      props: [createObjectProperty(arg, createSimpleExpression('', true, loc))]
+      props: [createObjectProperty(arg, createSimpleExpression('', true, loc))],
     }
   }
 
   return {
-    props: [createObjectProperty(arg, exp)]
+    props: [createObjectProperty(arg, exp)],
   }
 }
 
index e23b39e1fabdc7922b4a136fa0daa9d2ab3f4ddd..5d423ee2429e96ffd353ed1d265536a5b61a1bb5 100644 (file)
@@ -1,52 +1,52 @@
 import {
+  type TransformContext,
   createStructuralDirectiveTransform,
-  TransformContext
 } from '../transform'
 import {
+  type BlockCodegenNode,
+  ConstantTypes,
+  type DirectiveNode,
+  type ElementNode,
+  type ExpressionNode,
+  type ForCodegenNode,
+  type ForIteratorExpression,
+  type ForNode,
+  type ForParseResult,
+  type ForRenderListExpression,
   NodeTypes,
-  ExpressionNode,
-  createSimpleExpression,
-  SimpleExpressionNode,
+  type PlainElementNode,
+  type RenderSlotCall,
+  type SimpleExpressionNode,
+  type SlotOutletNode,
+  type VNodeCall,
+  createBlockStatement,
   createCallExpression,
+  createCompoundExpression,
   createFunctionExpression,
   createObjectExpression,
   createObjectProperty,
-  ForCodegenNode,
-  RenderSlotCall,
-  SlotOutletNode,
-  ElementNode,
-  DirectiveNode,
-  ForNode,
-  PlainElementNode,
+  createSimpleExpression,
   createVNodeCall,
-  VNodeCall,
-  ForRenderListExpression,
-  BlockCodegenNode,
-  ForIteratorExpression,
-  ConstantTypes,
-  createBlockStatement,
-  createCompoundExpression,
   getVNodeBlockHelper,
   getVNodeHelper,
-  ForParseResult
 } from '../ast'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { ErrorCodes, createCompilerError } from '../errors'
 import {
+  findDir,
   findProp,
-  isTemplateNode,
-  isSlotOutlet,
   injectProp,
-  findDir
+  isSlotOutlet,
+  isTemplateNode,
 } from '../utils'
 import {
-  RENDER_LIST,
-  OPEN_BLOCK,
   FRAGMENT,
-  IS_MEMO_SAME
+  IS_MEMO_SAME,
+  OPEN_BLOCK,
+  RENDER_LIST,
 } from '../runtimeHelpers'
 import { processExpression } from './transformExpression'
 import { validateBrowserExpression } from '../validateExpression'
-import { PatchFlags, PatchFlagNames } from '@vue/shared'
+import { PatchFlagNames, PatchFlags } from '@vue/shared'
 
 export const transformFor = createStructuralDirectiveTransform(
   'for',
@@ -56,7 +56,7 @@ export const transformFor = createStructuralDirectiveTransform(
       // create the loop render function expression now, and add the
       // iterator on exit after all children have been traversed
       const renderExp = createCallExpression(helper(RENDER_LIST), [
-        forNode.source
+        forNode.source,
       ]) as ForRenderListExpression
       const isTemplate = isTemplateNode(node)
       const memo = findDir(node, 'memo')
@@ -76,13 +76,13 @@ export const transformFor = createStructuralDirectiveTransform(
         if (memo) {
           memo.exp = processExpression(
             memo.exp! as SimpleExpressionNode,
-            context
+            context,
           )
         }
         if (keyProperty && keyProp!.type !== NodeTypes.ATTRIBUTE) {
           keyProperty.value = processExpression(
             keyProperty.value as SimpleExpressionNode,
-            context
+            context,
           )
         }
       }
@@ -108,7 +108,7 @@ export const transformFor = createStructuralDirectiveTransform(
         true /* isBlock */,
         !isStableFragment /* disableTracking */,
         false /* isComponent */,
-        node.loc
+        node.loc,
       ) as ForCodegenNode
 
       return () => {
@@ -125,8 +125,8 @@ export const transformFor = createStructuralDirectiveTransform(
                 context.onError(
                   createCompilerError(
                     ErrorCodes.X_V_FOR_TEMPLATE_KEY_PLACEMENT,
-                    key.loc
-                  )
+                    key.loc,
+                  ),
                 )
                 return true
               }
@@ -169,7 +169,7 @@ export const transformFor = createStructuralDirectiveTransform(
             undefined,
             true,
             undefined,
-            false /* isComponent */
+            false /* isComponent */,
           )
         } else {
           // Normal element v-for. Directly use the child's codegenNode
@@ -184,12 +184,12 @@ export const transformFor = createStructuralDirectiveTransform(
               // switch from block to vnode
               removeHelper(OPEN_BLOCK)
               removeHelper(
-                getVNodeBlockHelper(context.inSSR, childBlock.isComponent)
+                getVNodeBlockHelper(context.inSSR, childBlock.isComponent),
               )
             } else {
               // switch from vnode to block
               removeHelper(
-                getVNodeHelper(context.inSSR, childBlock.isComponent)
+                getVNodeHelper(context.inSSR, childBlock.isComponent),
               )
             }
           }
@@ -205,8 +205,8 @@ export const transformFor = createStructuralDirectiveTransform(
         if (memo) {
           const loop = createFunctionExpression(
             createForLoopParams(forNode.parseResult, [
-              createSimpleExpression(`_cached`)
-            ])
+              createSimpleExpression(`_cached`),
+            ]),
           )
           loop.body = createBlockStatement([
             createCompoundExpression([`const _memo = (`, memo.exp!, `)`]),
@@ -214,30 +214,30 @@ export const transformFor = createStructuralDirectiveTransform(
               `if (_cached`,
               ...(keyExp ? [` && _cached.key === `, keyExp] : []),
               ` && ${context.helperString(
-                IS_MEMO_SAME
-              )}(_cached, _memo)) return _cached`
+                IS_MEMO_SAME,
+              )}(_cached, _memo)) return _cached`,
             ]),
             createCompoundExpression([`const _item = `, childBlock as any]),
             createSimpleExpression(`_item.memo = _memo`),
-            createSimpleExpression(`return _item`)
+            createSimpleExpression(`return _item`),
           ])
           renderExp.arguments.push(
             loop as ForIteratorExpression,
             createSimpleExpression(`_cache`),
-            createSimpleExpression(String(context.cached++))
+            createSimpleExpression(String(context.cached++)),
           )
         } else {
           renderExp.arguments.push(
             createFunctionExpression(
               createForLoopParams(forNode.parseResult),
               childBlock,
-              true /* force newline */
-            ) as ForIteratorExpression
+              true /* force newline */,
+            ) as ForIteratorExpression,
           )
         }
       }
     })
-  }
+  },
 )
 
 // target-agnostic transform used for both Client and SSR
@@ -245,11 +245,11 @@ export function processFor(
   node: ElementNode,
   dir: DirectiveNode,
   context: TransformContext,
-  processCodegen?: (forNode: ForNode) => (() => void) | undefined
+  processCodegen?: (forNode: ForNode) => (() => void) | undefined,
 ) {
   if (!dir.exp) {
     context.onError(
-      createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc)
+      createCompilerError(ErrorCodes.X_V_FOR_NO_EXPRESSION, dir.loc),
     )
     return
   }
@@ -258,7 +258,7 @@ export function processFor(
 
   if (!parseResult) {
     context.onError(
-      createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, dir.loc)
+      createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, dir.loc),
     )
     return
   }
@@ -276,7 +276,7 @@ export function processFor(
     keyAlias: key,
     objectIndexAlias: index,
     parseResult,
-    children: isTemplateNode(node) ? node.children : [node]
+    children: isTemplateNode(node) ? node.children : [node],
   }
 
   context.replaceNode(forNode)
@@ -306,34 +306,34 @@ export function processFor(
 
 export function finalizeForParseResult(
   result: ForParseResult,
-  context: TransformContext
+  context: TransformContext,
 ) {
   if (result.finalized) return
 
   if (!__BROWSER__ && context.prefixIdentifiers) {
     result.source = processExpression(
       result.source as SimpleExpressionNode,
-      context
+      context,
     )
     if (result.key) {
       result.key = processExpression(
         result.key as SimpleExpressionNode,
         context,
-        true
+        true,
       )
     }
     if (result.index) {
       result.index = processExpression(
         result.index as SimpleExpressionNode,
         context,
-        true
+        true,
       )
     }
     if (result.value) {
       result.value = processExpression(
         result.value as SimpleExpressionNode,
         context,
-        true
+        true,
       )
     }
   }
@@ -343,21 +343,21 @@ export function finalizeForParseResult(
       validateBrowserExpression(
         result.key as SimpleExpressionNode,
         context,
-        true
+        true,
       )
     }
     if (result.index) {
       validateBrowserExpression(
         result.index as SimpleExpressionNode,
         context,
-        true
+        true,
       )
     }
     if (result.value) {
       validateBrowserExpression(
         result.value as SimpleExpressionNode,
         context,
-        true
+        true,
       )
     }
   }
@@ -366,13 +366,13 @@ export function finalizeForParseResult(
 
 export function createForLoopParams(
   { value, key, index }: ForParseResult,
-  memoArgs: ExpressionNode[] = []
+  memoArgs: ExpressionNode[] = [],
 ): ExpressionNode[] {
   return createParamsList([value, key, index, ...memoArgs])
 }
 
 function createParamsList(
-  args: (ExpressionNode | undefined)[]
+  args: (ExpressionNode | undefined)[],
 ): ExpressionNode[] {
   let i = args.length
   while (i--) {
index c3b9f91a842e510450c4a13b7dde1a613b8bc9eb..a6437f89c639bf32b7d973721512e6ab6f534b5a 100644 (file)
@@ -1,37 +1,37 @@
 import {
+  type TransformContext,
   createStructuralDirectiveTransform,
-  TransformContext,
-  traverseNode
+  traverseNode,
 } from '../transform'
 import {
-  NodeTypes,
+  type AttributeNode,
+  type BlockCodegenNode,
+  type CacheExpression,
+  ConstantTypes,
+  type DirectiveNode,
+  type ElementNode,
   ElementTypes,
-  ElementNode,
-  DirectiveNode,
-  IfBranchNode,
-  SimpleExpressionNode,
+  type IfBranchNode,
+  type IfConditionalExpression,
+  type IfNode,
+  type MemoExpression,
+  NodeTypes,
+  type SimpleExpressionNode,
+  convertToBlock,
   createCallExpression,
   createConditionalExpression,
-  createSimpleExpression,
-  createObjectProperty,
   createObjectExpression,
-  IfConditionalExpression,
-  BlockCodegenNode,
-  IfNode,
+  createObjectProperty,
+  createSimpleExpression,
   createVNodeCall,
-  AttributeNode,
   locStub,
-  CacheExpression,
-  ConstantTypes,
-  MemoExpression,
-  convertToBlock
 } from '../ast'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { ErrorCodes, createCompilerError } from '../errors'
 import { processExpression } from './transformExpression'
 import { validateBrowserExpression } from '../validateExpression'
-import { FRAGMENT, CREATE_COMMENT } from '../runtimeHelpers'
-import { injectProp, findDir, findProp, getMemoedVNodeCall } from '../utils'
-import { PatchFlags, PatchFlagNames } from '@vue/shared'
+import { CREATE_COMMENT, FRAGMENT } from '../runtimeHelpers'
+import { findDir, findProp, getMemoedVNodeCall, injectProp } from '../utils'
+import { PatchFlagNames, PatchFlags } from '@vue/shared'
 
 export const transformIf = createStructuralDirectiveTransform(
   /^(if|else|else-if)$/,
@@ -57,7 +57,7 @@ export const transformIf = createStructuralDirectiveTransform(
           ifNode.codegenNode = createCodegenNodeForBranch(
             branch,
             key,
-            context
+            context,
           ) as IfConditionalExpression
         } else {
           // attach this branch's codegen node to the v-if root.
@@ -65,12 +65,12 @@ export const transformIf = createStructuralDirectiveTransform(
           parentCondition.alternate = createCodegenNodeForBranch(
             branch,
             key + ifNode.branches.length - 1,
-            context
+            context,
           )
         }
       }
     })
-  }
+  },
 )
 
 // target-agnostic transform used for both Client and SSR
@@ -81,8 +81,8 @@ export function processIf(
   processCodegen?: (
     node: IfNode,
     branch: IfBranchNode,
-    isRoot: boolean
-  ) => (() => void) | undefined
+    isRoot: boolean,
+  ) => (() => void) | undefined,
 ) {
   if (
     dir.name !== 'else' &&
@@ -90,7 +90,7 @@ export function processIf(
   ) {
     const loc = dir.exp ? dir.exp.loc : node.loc
     context.onError(
-      createCompilerError(ErrorCodes.X_V_IF_NO_EXPRESSION, dir.loc)
+      createCompilerError(ErrorCodes.X_V_IF_NO_EXPRESSION, dir.loc),
     )
     dir.exp = createSimpleExpression(`true`, false, loc)
   }
@@ -110,7 +110,7 @@ export function processIf(
     const ifNode: IfNode = {
       type: NodeTypes.IF,
       loc: node.loc,
-      branches: [branch]
+      branches: [branch],
     }
     context.replaceNode(ifNode)
     if (processCodegen) {
@@ -145,7 +145,7 @@ export function processIf(
           sibling.branches[sibling.branches.length - 1].condition === undefined
         ) {
           context.onError(
-            createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, node.loc)
+            createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, node.loc),
           )
         }
 
@@ -175,8 +175,8 @@ export function processIf(
                 context.onError(
                   createCompilerError(
                     ErrorCodes.X_V_IF_SAME_KEY,
-                    branch.userKey!.loc
-                  )
+                    branch.userKey!.loc,
+                  ),
                 )
               }
             })
@@ -195,7 +195,7 @@ export function processIf(
         context.currentNode = null
       } else {
         context.onError(
-          createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, node.loc)
+          createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, node.loc),
         )
       }
       break
@@ -211,14 +211,14 @@ function createIfBranch(node: ElementNode, dir: DirectiveNode): IfBranchNode {
     condition: dir.name === 'else' ? undefined : dir.exp,
     children: isTemplateIf && !findDir(node, 'for') ? node.children : [node],
     userKey: findProp(node, `key`),
-    isTemplateIf
+    isTemplateIf,
   }
 }
 
 function createCodegenNodeForBranch(
   branch: IfBranchNode,
   keyIndex: number,
-  context: TransformContext
+  context: TransformContext,
 ): IfConditionalExpression | BlockCodegenNode | MemoExpression {
   if (branch.condition) {
     return createConditionalExpression(
@@ -228,8 +228,8 @@ function createCodegenNodeForBranch(
       // closes the current block.
       createCallExpression(context.helper(CREATE_COMMENT), [
         __DEV__ ? '"v-if"' : '""',
-        'true'
-      ])
+        'true',
+      ]),
     ) as IfConditionalExpression
   } else {
     return createChildrenCodegenNode(branch, keyIndex, context)
@@ -239,7 +239,7 @@ function createCodegenNodeForBranch(
 function createChildrenCodegenNode(
   branch: IfBranchNode,
   keyIndex: number,
-  context: TransformContext
+  context: TransformContext,
 ): BlockCodegenNode | MemoExpression {
   const { helper } = context
   const keyProperty = createObjectProperty(
@@ -248,8 +248,8 @@ function createChildrenCodegenNode(
       `${keyIndex}`,
       false,
       locStub,
-      ConstantTypes.CAN_HOIST
-    )
+      ConstantTypes.CAN_HOIST,
+    ),
   )
   const { children } = branch
   const firstChild = children[0]
@@ -286,7 +286,7 @@ function createChildrenCodegenNode(
         true,
         false,
         false /* isComponent */,
-        branch.loc
+        branch.loc,
       )
     }
   } else {
@@ -306,7 +306,7 @@ function createChildrenCodegenNode(
 
 function isSameKey(
   a: AttributeNode | DirectiveNode | undefined,
-  b: AttributeNode | DirectiveNode
+  b: AttributeNode | DirectiveNode,
 ): boolean {
   if (!a || a.type !== b.type) {
     return false
@@ -334,7 +334,7 @@ function isSameKey(
 }
 
 function getParentCondition(
-  node: IfConditionalExpression | CacheExpression
+  node: IfConditionalExpression | CacheExpression,
 ): IfConditionalExpression {
   while (true) {
     if (node.type === NodeTypes.JS_CONDITIONAL_EXPRESSION) {
index c14f6ceb860841c132caa8579772551aea9107b1..7c728f4caadbfa429574bfb932394ac32c059437 100644 (file)
@@ -1,13 +1,13 @@
-import { NodeTransform } from '../transform'
+import type { NodeTransform } from '../transform'
 import { findDir } from '../utils'
 import {
+  ElementTypes,
+  type MemoExpression,
+  NodeTypes,
+  type PlainElementNode,
   convertToBlock,
   createCallExpression,
   createFunctionExpression,
-  ElementTypes,
-  MemoExpression,
-  NodeTypes,
-  PlainElementNode
 } from '../ast'
 import { WITH_MEMO } from '../runtimeHelpers'
 
@@ -33,7 +33,7 @@ export const transformMemo: NodeTransform = (node, context) => {
           dir.exp!,
           createFunctionExpression(undefined, codegenNode),
           `_cache`,
-          String(context.cached++)
+          String(context.cached++),
         ]) as MemoExpression
       }
     }
index 525801f523e240327e9bfc7bb1f526edf1bf14c1..863b3a7d729b331212ce0eeec0cfd973b16824d5 100644 (file)
@@ -1,20 +1,20 @@
-import { DirectiveTransform } from '../transform'
+import type { DirectiveTransform } from '../transform'
 import {
-  createSimpleExpression,
-  createObjectProperty,
-  createCompoundExpression,
-  NodeTypes,
-  Property,
+  ConstantTypes,
   ElementTypes,
-  ExpressionNode,
-  ConstantTypes
+  type ExpressionNode,
+  NodeTypes,
+  type Property,
+  createCompoundExpression,
+  createObjectProperty,
+  createSimpleExpression,
 } from '../ast'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { ErrorCodes, createCompilerError } from '../errors'
 import {
+  hasScopeRef,
   isMemberExpression,
   isSimpleIdentifier,
-  hasScopeRef,
-  isStaticExp
+  isStaticExp,
 } from '../utils'
 import { IS_REF } from '../runtimeHelpers'
 import { BindingTypes } from '../options'
@@ -24,7 +24,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
   const { exp, arg } = dir
   if (!exp) {
     context.onError(
-      createCompilerError(ErrorCodes.X_V_MODEL_NO_EXPRESSION, dir.loc)
+      createCompilerError(ErrorCodes.X_V_MODEL_NO_EXPRESSION, dir.loc),
     )
     return createTransformProps()
   }
@@ -60,7 +60,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
     (!isMemberExpression(expString, context) && !maybeRef)
   ) {
     context.onError(
-      createCompilerError(ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION, exp.loc)
+      createCompilerError(ErrorCodes.X_V_MODEL_MALFORMED_EXPRESSION, exp.loc),
     )
     return createTransformProps()
   }
@@ -72,7 +72,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
     context.identifiers[expString]
   ) {
     context.onError(
-      createCompilerError(ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE, exp.loc)
+      createCompilerError(ErrorCodes.X_V_MODEL_ON_SCOPE_VARIABLE, exp.loc),
     )
     return createTransformProps()
   }
@@ -92,7 +92,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
       assignmentExp = createCompoundExpression([
         `${eventArg} => ((`,
         createSimpleExpression(rawExp, false, exp.loc),
-        `).value = $event)`
+        `).value = $event)`,
       ])
     } else {
       // v-model used on a potentially ref binding in <script setup> inline mode.
@@ -102,14 +102,14 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
       assignmentExp = createCompoundExpression([
         `${eventArg} => (${context.helperString(IS_REF)}(${rawExp}) ? (`,
         createSimpleExpression(rawExp, false, exp.loc),
-        `).value = $event : ${altAssignment})`
+        `).value = $event : ${altAssignment})`,
       ])
     }
   } else {
     assignmentExp = createCompoundExpression([
       `${eventArg} => ((`,
       exp,
-      `) = $event)`
+      `) = $event)`,
     ])
   }
 
@@ -117,7 +117,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
     // modelValue: foo
     createObjectProperty(propName, dir.exp!),
     // "onUpdate:modelValue": $event => (foo = $event)
-    createObjectProperty(eventName, assignmentExp)
+    createObjectProperty(eventName, assignmentExp),
   ]
 
   // cache v-model handler if applicable (when it doesn't refer any scope vars)
@@ -148,9 +148,9 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
           `{ ${modifiers} }`,
           false,
           dir.loc,
-          ConstantTypes.CAN_HOIST
-        )
-      )
+          ConstantTypes.CAN_HOIST,
+        ),
+      ),
     )
   }
 
index 1c15675ce36733c9ab2d119a165bbe2220877a1e..8c13bdae524bb63dd76dec20bd9e48dd5e731118 100644 (file)
@@ -1,16 +1,16 @@
-import { DirectiveTransform, DirectiveTransformResult } from '../transform'
+import type { DirectiveTransform, DirectiveTransformResult } from '../transform'
 import {
+  type DirectiveNode,
+  ElementTypes,
+  type ExpressionNode,
+  NodeTypes,
+  type SimpleExpressionNode,
   createCompoundExpression,
   createObjectProperty,
   createSimpleExpression,
-  DirectiveNode,
-  ElementTypes,
-  ExpressionNode,
-  NodeTypes,
-  SimpleExpressionNode
 } from '../ast'
 import { camelize, toHandlerKey } from '@vue/shared'
-import { createCompilerError, ErrorCodes } from '../errors'
+import { ErrorCodes, createCompilerError } from '../errors'
 import { processExpression } from './transformExpression'
 import { validateBrowserExpression } from '../validateExpression'
 import { hasScopeRef, isMemberExpression } from '../utils'
@@ -33,7 +33,7 @@ export const transformOn: DirectiveTransform = (
   dir,
   node,
   context,
-  augmentor
+  augmentor,
 ) => {
   const { loc, modifiers, arg } = dir as VOnDirectiveNode
   if (!dir.exp && !modifiers.length) {
@@ -65,7 +65,7 @@ export const transformOn: DirectiveTransform = (
       eventName = createCompoundExpression([
         `${context.helperString(TO_HANDLER_KEY)}(`,
         arg,
-        `)`
+        `)`,
       ])
     }
   } else {
@@ -95,7 +95,7 @@ export const transformOn: DirectiveTransform = (
         exp,
         context,
         false,
-        hasMultipleStatements
+        hasMultipleStatements,
       )
       isInlineStatement && context.removeIdentifiers(`$event`)
       // with scope analysis, the function is hoistable if it has no reference
@@ -134,7 +134,7 @@ export const transformOn: DirectiveTransform = (
         exp as SimpleExpressionNode,
         context,
         false,
-        hasMultipleStatements
+        hasMultipleStatements,
       )
     }
 
@@ -151,7 +151,7 @@ export const transformOn: DirectiveTransform = (
               }(...args)`
         } => ${hasMultipleStatements ? `{` : `(`}`,
         exp,
-        hasMultipleStatements ? `}` : `)`
+        hasMultipleStatements ? `}` : `)`,
       ])
     }
   }
@@ -160,9 +160,9 @@ export const transformOn: DirectiveTransform = (
     props: [
       createObjectProperty(
         eventName,
-        exp || createSimpleExpression(`() => {}`, false, loc)
-      )
-    ]
+        exp || createSimpleExpression(`() => {}`, false, loc),
+      ),
+    ],
   }
 
   // apply extended compiler augmentor
index e1ec5e129dfbd4d690fd98a4041282ca4ce7b1d7..483b98da9610d105ad61168e439a5215f49d3676 100644 (file)
@@ -1,6 +1,6 @@
-import { NodeTransform } from '../transform'
+import type { NodeTransform } from '../transform'
 import { findDir } from '../utils'
-import { ElementNode, ForNode, IfNode, NodeTypes } from '../ast'
+import { type ElementNode, type ForNode, type IfNode, NodeTypes } from '../ast'
 import { SET_BLOCK_TRACKING } from '../runtimeHelpers'
 
 const seen = new WeakSet()
index b270797cc756585320a0f5222fafddcce37aa8af..1b95e6f71dbfa2c61f1fa648d3ff5f255a2bf305 100644 (file)
@@ -1,34 +1,34 @@
 import {
-  ElementNode,
-  ObjectExpression,
-  createObjectExpression,
+  type CallExpression,
+  type ConditionalExpression,
+  type DirectiveNode,
+  type ElementNode,
+  ElementTypes,
+  type ExpressionNode,
+  type FunctionExpression,
   NodeTypes,
+  type ObjectExpression,
+  type Property,
+  type SlotsExpression,
+  type SourceLocation,
+  type TemplateChildNode,
+  createArrayExpression,
+  createCallExpression,
+  createConditionalExpression,
+  createFunctionExpression,
+  createObjectExpression,
   createObjectProperty,
   createSimpleExpression,
-  createFunctionExpression,
-  DirectiveNode,
-  ElementTypes,
-  ExpressionNode,
-  Property,
-  TemplateChildNode,
-  SourceLocation,
-  createConditionalExpression,
-  ConditionalExpression,
-  FunctionExpression,
-  CallExpression,
-  createCallExpression,
-  createArrayExpression,
-  SlotsExpression
 } from '../ast'
-import { TransformContext, NodeTransform } from '../transform'
-import { createCompilerError, ErrorCodes } from '../errors'
+import type { NodeTransform, TransformContext } from '../transform'
+import { ErrorCodes, createCompilerError } from '../errors'
 import {
+  assert,
   findDir,
+  hasScopeRef,
+  isStaticExp,
   isTemplateNode,
-  assert,
   isVSlot,
-  hasScopeRef,
-  isStaticExp
 } from '../utils'
 import { CREATE_SLOTS, RENDER_LIST, WITH_CTX } from '../runtimeHelpers'
 import { createForLoopParams, finalizeForParseResult } from './vFor'
@@ -99,7 +99,7 @@ export type SlotFnBuilder = (
   slotProps: ExpressionNode | undefined,
   vFor: DirectiveNode | undefined,
   slotChildren: TemplateChildNode[],
-  loc: SourceLocation
+  loc: SourceLocation,
 ) => FunctionExpression
 
 const buildClientSlotFn: SlotFnBuilder = (props, _vForExp, children, loc) =>
@@ -108,7 +108,7 @@ const buildClientSlotFn: SlotFnBuilder = (props, _vForExp, children, loc) =>
     children,
     false /* newline */,
     true /* isSlot */,
-    children.length ? children[0].loc : loc
+    children.length ? children[0].loc : loc,
   )
 
 // Instead of being a DirectiveTransform, v-slot processing is called during
@@ -116,7 +116,7 @@ const buildClientSlotFn: SlotFnBuilder = (props, _vForExp, children, loc) =>
 export function buildSlots(
   node: ElementNode,
   context: TransformContext,
-  buildSlotFn: SlotFnBuilder = buildClientSlotFn
+  buildSlotFn: SlotFnBuilder = buildClientSlotFn,
 ): {
   slots: SlotsExpression
   hasDynamicSlots: boolean
@@ -147,8 +147,8 @@ export function buildSlots(
     slotsProperties.push(
       createObjectProperty(
         arg || createSimpleExpression('default', true),
-        buildSlotFn(exp, undefined, children, loc)
-      )
+        buildSlotFn(exp, undefined, children, loc),
+      ),
     )
   }
 
@@ -178,7 +178,7 @@ export function buildSlots(
     if (onComponentSlot) {
       // already has on-component slot - this is incorrect usage.
       context.onError(
-        createCompilerError(ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, slotDir.loc)
+        createCompilerError(ErrorCodes.X_V_SLOT_MIXED_SLOT_USAGE, slotDir.loc),
       )
       break
     }
@@ -188,7 +188,7 @@ export function buildSlots(
     const {
       arg: slotName = createSimpleExpression(`default`, true),
       exp: slotProps,
-      loc: dirLoc
+      loc: dirLoc,
     } = slotDir
 
     // check if name is dynamic.
@@ -211,8 +211,8 @@ export function buildSlots(
         createConditionalExpression(
           vIf.exp!,
           buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++),
-          defaultFallback
-        )
+          defaultFallback,
+        ),
       )
     } else if (
       (vElse = findDir(slotElement, /^else(-if)?$/, true /* allowEmpty */))
@@ -246,14 +246,14 @@ export function buildSlots(
               buildDynamicSlot(
                 slotName,
                 slotFunction,
-                conditionalBranchIndex++
+                conditionalBranchIndex++,
               ),
-              defaultFallback
+              defaultFallback,
             )
           : buildDynamicSlot(slotName, slotFunction, conditionalBranchIndex++)
       } else {
         context.onError(
-          createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, vElse.loc)
+          createCompilerError(ErrorCodes.X_V_ELSE_NO_ADJACENT_IF, vElse.loc),
         )
       }
     } else if (vFor) {
@@ -269,13 +269,16 @@ export function buildSlots(
             createFunctionExpression(
               createForLoopParams(parseResult),
               buildDynamicSlot(slotName, slotFunction),
-              true /* force newline */
-            )
-          ])
+              true /* force newline */,
+            ),
+          ]),
         )
       } else {
         context.onError(
-          createCompilerError(ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION, vFor.loc)
+          createCompilerError(
+            ErrorCodes.X_V_FOR_MALFORMED_EXPRESSION,
+            vFor.loc,
+          ),
         )
       }
     } else {
@@ -285,8 +288,8 @@ export function buildSlots(
           context.onError(
             createCompilerError(
               ErrorCodes.X_V_SLOT_DUPLICATE_SLOT_NAMES,
-              dirLoc
-            )
+              dirLoc,
+            ),
           )
           continue
         }
@@ -302,7 +305,7 @@ export function buildSlots(
   if (!onComponentSlot) {
     const buildDefaultSlotProperty = (
       props: ExpressionNode | undefined,
-      children: TemplateChildNode[]
+      children: TemplateChildNode[],
     ) => {
       const fn = buildSlotFn(props, undefined, children, loc)
       if (__COMPAT__ && context.compatConfig) {
@@ -326,12 +329,12 @@ export function buildSlots(
         context.onError(
           createCompilerError(
             ErrorCodes.X_V_SLOT_EXTRANEOUS_DEFAULT_SLOT_CHILDREN,
-            implicitDefaultChildren[0].loc
-          )
+            implicitDefaultChildren[0].loc,
+          ),
         )
       } else {
         slotsProperties.push(
-          buildDefaultSlotProperty(undefined, implicitDefaultChildren)
+          buildDefaultSlotProperty(undefined, implicitDefaultChildren),
         )
       }
     }
@@ -351,37 +354,37 @@ export function buildSlots(
         // 1 = compiled and static = can skip normalization AND diff as optimized
         createSimpleExpression(
           slotFlag + (__DEV__ ? ` /* ${slotFlagsText[slotFlag]} */` : ``),
-          false
-        )
-      )
+          false,
+        ),
+      ),
     ),
-    loc
+    loc,
   ) as SlotsExpression
   if (dynamicSlots.length) {
     slots = createCallExpression(context.helper(CREATE_SLOTS), [
       slots,
-      createArrayExpression(dynamicSlots)
+      createArrayExpression(dynamicSlots),
     ]) as SlotsExpression
   }
 
   return {
     slots,
-    hasDynamicSlots
+    hasDynamicSlots,
   }
 }
 
 function buildDynamicSlot(
   name: ExpressionNode,
   fn: FunctionExpression,
-  index?: number
+  index?: number,
 ): ObjectExpression {
   const props = [
     createObjectProperty(`name`, name),
-    createObjectProperty(`fn`, fn)
+    createObjectProperty(`fn`, fn),
   ]
   if (index != null) {
     props.push(
-      createObjectProperty(`key`, createSimpleExpression(String(index), true))
+      createObjectProperty(`key`, createSimpleExpression(String(index), true)),
     )
   }
   return createObjectExpression(props)
index 3f08f990e2c8b00692c6a7f1b8e0c45ae48e3cb4..99a2c5b61a89974b730a90922483b3f382d608f6 100644 (file)
@@ -1,45 +1,45 @@
 import {
-  Position,
-  ElementNode,
+  type BlockCodegenNode,
+  type CallExpression,
+  type DirectiveNode,
+  type ElementNode,
+  ElementTypes,
+  type ExpressionNode,
+  type IfBranchNode,
+  type InterpolationNode,
+  type JSChildNode,
+  type MemoExpression,
   NodeTypes,
-  CallExpression,
+  type ObjectExpression,
+  type Position,
+  type Property,
+  type RenderSlotCall,
+  type RootNode,
+  type SimpleExpressionNode,
+  type SlotOutletNode,
+  type TemplateChildNode,
+  type TemplateNode,
+  type TextNode,
+  type VNodeCall,
   createCallExpression,
-  DirectiveNode,
-  ElementTypes,
-  TemplateChildNode,
-  RootNode,
-  ObjectExpression,
-  Property,
-  JSChildNode,
   createObjectExpression,
-  SlotOutletNode,
-  TemplateNode,
-  RenderSlotCall,
-  ExpressionNode,
-  IfBranchNode,
-  TextNode,
-  InterpolationNode,
-  VNodeCall,
-  SimpleExpressionNode,
-  BlockCodegenNode,
-  MemoExpression
 } from './ast'
-import { TransformContext } from './transform'
+import type { TransformContext } from './transform'
 import {
+  BASE_TRANSITION,
+  GUARD_REACTIVE_PROPS,
+  KEEP_ALIVE,
   MERGE_PROPS,
-  TELEPORT,
+  NORMALIZE_PROPS,
   SUSPENSE,
-  KEEP_ALIVE,
-  BASE_TRANSITION,
+  TELEPORT,
   TO_HANDLERS,
-  NORMALIZE_PROPS,
-  GUARD_REACTIVE_PROPS,
-  WITH_MEMO
+  WITH_MEMO,
 } from './runtimeHelpers'
-import { isString, isObject, NOOP } from '@vue/shared'
-import { PropsExpression } from './transforms/transformElement'
+import { NOOP, isObject, isString } from '@vue/shared'
+import type { PropsExpression } from './transforms/transformElement'
 import { parseExpression } from '@babel/parser'
-import { Expression } from '@babel/types'
+import type { Expression } from '@babel/types'
 import { unwrapTSNode } from './babelUtils'
 
 export const isStaticExp = (p: JSChildNode): p is SimpleExpressionNode =>
@@ -70,7 +70,7 @@ enum MemberExpLexState {
   inMemberExp,
   inBrackets,
   inParens,
-  inString
+  inString,
 }
 
 const validFirstIdentCharRE = /[A-Za-z_$\xA0-\uFFFF]/
@@ -157,7 +157,7 @@ export const isMemberExpressionNode = __BROWSER__
   : (path: string, context: TransformContext): boolean => {
       try {
         let ret: Expression = parseExpression(path, {
-          plugins: context.expressionPlugins
+          plugins: context.expressionPlugins,
         })
         ret = unwrapTSNode(ret) as Expression
         return (
@@ -177,16 +177,16 @@ export const isMemberExpression = __BROWSER__
 export function advancePositionWithClone(
   pos: Position,
   source: string,
-  numberOfCharacters: number = source.length
+  numberOfCharacters: number = source.length,
 ): Position {
   return advancePositionWithMutation(
     {
       offset: pos.offset,
       line: pos.line,
-      column: pos.column
+      column: pos.column,
     },
     source,
-    numberOfCharacters
+    numberOfCharacters,
   )
 }
 
@@ -195,7 +195,7 @@ export function advancePositionWithClone(
 export function advancePositionWithMutation(
   pos: Position,
   source: string,
-  numberOfCharacters: number = source.length
+  numberOfCharacters: number = source.length,
 ): Position {
   let linesCount = 0
   let lastNewLinePos = -1
@@ -226,7 +226,7 @@ export function assert(condition: boolean, msg?: string) {
 export function findDir(
   node: ElementNode,
   name: string | RegExp,
-  allowEmpty: boolean = false
+  allowEmpty: boolean = false,
 ): DirectiveNode | undefined {
   for (let i = 0; i < node.props.length; i++) {
     const p = node.props[i]
@@ -244,7 +244,7 @@ export function findProp(
   node: ElementNode,
   name: string,
   dynamicOnly: boolean = false,
-  allowEmpty: boolean = false
+  allowEmpty: boolean = false,
 ): ElementNode['props'][0] | undefined {
   for (let i = 0; i < node.props.length; i++) {
     const p = node.props[i]
@@ -265,7 +265,7 @@ export function findProp(
 
 export function isStaticArgOf(
   arg: DirectiveNode['arg'],
-  name: string
+  name: string,
 ): boolean {
   return !!(arg && isStaticExp(arg) && arg.content === name)
 }
@@ -277,12 +277,12 @@ export function hasDynamicKeyVBind(node: ElementNode): boolean {
       p.name === 'bind' &&
       (!p.arg || // v-bind="obj"
         p.arg.type !== NodeTypes.SIMPLE_EXPRESSION || // v-bind:[_ctx.foo]
-        !p.arg.isStatic) // v-bind:[foo]
+        !p.arg.isStatic), // v-bind:[foo]
   )
 }
 
 export function isText(
-  node: TemplateChildNode
+  node: TemplateChildNode,
 ): node is TextNode | InterpolationNode {
   return node.type === NodeTypes.INTERPOLATION || node.type === NodeTypes.TEXT
 }
@@ -292,7 +292,7 @@ export function isVSlot(p: ElementNode['props'][0]): p is DirectiveNode {
 }
 
 export function isTemplateNode(
-  node: RootNode | TemplateChildNode
+  node: RootNode | TemplateChildNode,
 ): node is TemplateNode {
   return (
     node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.TEMPLATE
@@ -300,7 +300,7 @@ export function isTemplateNode(
 }
 
 export function isSlotOutlet(
-  node: RootNode | TemplateChildNode
+  node: RootNode | TemplateChildNode,
 ): node is SlotOutletNode {
   return node.type === NodeTypes.ELEMENT && node.tagType === ElementTypes.SLOT
 }
@@ -309,7 +309,7 @@ const propsHelperSet = new Set([NORMALIZE_PROPS, GUARD_REACTIVE_PROPS])
 
 function getUnnormalizedProps(
   props: PropsExpression | '{}',
-  callPath: CallExpression[] = []
+  callPath: CallExpression[] = [],
 ): [PropsExpression | '{}', CallExpression[]] {
   if (
     props &&
@@ -320,7 +320,7 @@ function getUnnormalizedProps(
     if (!isString(callee) && propsHelperSet.has(callee)) {
       return getUnnormalizedProps(
         props.arguments[0] as PropsExpression,
-        callPath.concat(props)
+        callPath.concat(props),
       )
     }
   }
@@ -329,7 +329,7 @@ function getUnnormalizedProps(
 export function injectProp(
   node: VNodeCall | RenderSlotCall,
   prop: Property,
-  context: TransformContext
+  context: TransformContext,
 ) {
   let propsWithInjection: ObjectExpression | CallExpression | undefined
   /**
@@ -372,7 +372,7 @@ export function injectProp(
         // #2366
         propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
           createObjectExpression([prop]),
-          props
+          props,
         ])
       } else {
         props.arguments.unshift(createObjectExpression([prop]))
@@ -388,7 +388,7 @@ export function injectProp(
     // single v-bind with expression, return a merged replacement
     propsWithInjection = createCallExpression(context.helper(MERGE_PROPS), [
       createObjectExpression([prop]),
-      props
+      props,
     ])
     // in the case of nested helper call, e.g. `normalizeProps(guardReactiveProps(props))`,
     // it will be rewritten as `normalizeProps(mergeProps({ key: 0 }, props))`,
@@ -420,7 +420,7 @@ function hasProp(prop: Property, props: ObjectExpression) {
     result = props.properties.some(
       p =>
         p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
-        p.key.content === propKeyName
+        p.key.content === propKeyName,
     )
   }
   return result
@@ -428,7 +428,7 @@ function hasProp(prop: Property, props: ObjectExpression) {
 
 export function toValidAssetId(
   name: string,
-  type: 'component' | 'directive' | 'filter'
+  type: 'component' | 'directive' | 'filter',
 ): string {
   // see issue#4422, we need adding identifier on validAssetId if variable `name` has specific character
   return `_${type}_${name.replace(/[^\w]/g, (searchValue, replaceValue) => {
@@ -439,7 +439,7 @@ export function toValidAssetId(
 // Check if a node contains expressions that reference current context scope ids
 export function hasScopeRef(
   node: TemplateChildNode | IfBranchNode | ExpressionNode | undefined,
-  ids: TransformContext['identifiers']
+  ids: TransformContext['identifiers'],
 ): boolean {
   if (!node || Object.keys(ids).length === 0) {
     return false
index 83998eee2c88e8c6520c95cfcf9c9cfa4db1125d..dca90ddd3f1a9ec5739000b62b31411a39769b0e 100644 (file)
@@ -1,6 +1,6 @@
-import { SimpleExpressionNode } from './ast'
-import { TransformContext } from './transform'
-import { createCompilerError, ErrorCodes } from './errors'
+import type { SimpleExpressionNode } from './ast'
+import type { TransformContext } from './transform'
+import { ErrorCodes, createCompilerError } from './errors'
 
 // these keywords should not appear inside expressions, but operators like
 // 'typeof', 'instanceof', and 'in' are allowed
@@ -13,7 +13,7 @@ const prohibitedKeywordRE = new RegExp(
     )
       .split(',')
       .join('\\b|\\b') +
-    '\\b'
+    '\\b',
 )
 
 // strip strings in expressions
@@ -29,7 +29,7 @@ export function validateBrowserExpression(
   node: SimpleExpressionNode,
   context: TransformContext,
   asParams = false,
-  asRawStatements = false
+  asRawStatements = false,
 ) {
   const exp = node.content
 
@@ -43,7 +43,7 @@ export function validateBrowserExpression(
     new Function(
       asRawStatements
         ? ` ${exp} `
-        : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`
+        : `return ${asParams ? `(${exp}) => {}` : `(${exp})`}`,
     )
   } catch (e: any) {
     let message = e.message
@@ -58,8 +58,8 @@ export function validateBrowserExpression(
         ErrorCodes.X_INVALID_EXPRESSION,
         node.loc,
         undefined,
-        message
-      )
+        message,
+      ),
     )
   }
 }
index 03c0929dbe26b437677871aa7a99b9123f38fe13..ecdc070ad96ece2ba2467dbee9d29662b64740cd 100644 (file)
@@ -29,16 +29,16 @@ describe('decodeHtmlBrowser', () => {
 
     // #3001 html tags inside attribute values
     expect(decodeHtmlBrowser('<strong>Text</strong>', true)).toBe(
-      '<strong>Text</strong>'
+      '<strong>Text</strong>',
     )
     expect(decodeHtmlBrowser('<strong>&amp;</strong>', true)).toBe(
-      '<strong>&</strong>'
+      '<strong>&</strong>',
     )
     expect(
       decodeHtmlBrowser(
         '<strong>&lt;strong&gt;&amp;&lt;/strong&gt;</strong>',
-        true
-      )
+        true,
+      ),
     ).toBe('<strong><strong>&</strong></strong>')
   })
 })
index 23b0970e1b2c169c0d19aa51e0cec529d7ce3708..80a08e76af67661a9582ad921ddc7c97d468fa09 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  baseParse as parse,
-  NodeTypes,
-  ElementNode,
-  TextNode,
-  ElementTypes,
-  InterpolationNode,
-  AttributeNode,
+  type AttributeNode,
   ConstantTypes,
-  Namespaces
+  type ElementNode,
+  ElementTypes,
+  type InterpolationNode,
+  Namespaces,
+  NodeTypes,
+  type TextNode,
+  baseParse as parse,
 } from '@vue/compiler-core'
 import { parserOptions } from '../src/parserOptions'
 
@@ -16,7 +16,7 @@ describe('DOM parser', () => {
     test('textarea handles comments/elements as just text', () => {
       const ast = parse(
         '<textarea>some<div>text</div>and<!--comment--></textarea>',
-        parserOptions
+        parserOptions,
       )
       const element = ast.children[0] as ElementNode
       const text = element.children[0] as TextNode
@@ -27,8 +27,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 10, line: 1, column: 11 },
           end: { offset: 46, line: 1, column: 47 },
-          source: 'some<div>text</div>and<!--comment-->'
-        }
+          source: 'some<div>text</div>and<!--comment-->',
+        },
       })
     })
 
@@ -43,8 +43,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 10, line: 1, column: 11 },
           end: { offset: 15, line: 1, column: 16 },
-          source: '&amp;'
-        }
+          source: '&amp;',
+        },
       })
     })
 
@@ -58,16 +58,16 @@ describe('DOM parser', () => {
           content: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `foo`,
-            isStatic: false
-          }
-        }
+            isStatic: false,
+          },
+        },
       ])
     })
 
     test('style handles comments/elements as just a text', () => {
       const ast = parse(
         '<style>some<div>text</div>and<!--comment--></style>',
-        parserOptions
+        parserOptions,
       )
       const element = ast.children[0] as ElementNode
       const text = element.children[0] as TextNode
@@ -78,8 +78,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 7, line: 1, column: 8 },
           end: { offset: 43, line: 1, column: 44 },
-          source: 'some<div>text</div>and<!--comment-->'
-        }
+          source: 'some<div>text</div>and<!--comment-->',
+        },
       })
     })
 
@@ -94,8 +94,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 7, line: 1, column: 8 },
           end: { offset: 12, line: 1, column: 13 },
-          source: '&amp;'
-        }
+          source: '&amp;',
+        },
       })
     })
 
@@ -109,8 +109,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 14, line: 1, column: 15 },
           end: { offset: 23, line: 1, column: 24 },
-          source: 'some text'
-        }
+          source: 'some text',
+        },
       })
     })
 
@@ -120,21 +120,21 @@ describe('DOM parser', () => {
       expect((ast.children[0] as ElementNode).children).toMatchObject([
         {
           type: NodeTypes.TEXT,
-          content: `  \na   `
+          content: `  \na   `,
         },
         {
           type: NodeTypes.ELEMENT,
           children: [
             {
               type: NodeTypes.TEXT,
-              content: `foo \n bar`
-            }
-          ]
+              content: `foo \n bar`,
+            },
+          ],
         },
         {
           type: NodeTypes.TEXT,
-          content: `   \n   c`
-        }
+          content: `   \n   c`,
+        },
       ])
     })
 
@@ -145,7 +145,7 @@ describe('DOM parser', () => {
       expect((ast.children[0] as ElementNode).children).toMatchObject([
         {
           type: NodeTypes.TEXT,
-          content: `hello`
+          content: `hello`,
         },
         {
           type: NodeTypes.ELEMENT,
@@ -153,10 +153,10 @@ describe('DOM parser', () => {
             {
               type: NodeTypes.TEXT,
               // should not remove the leading newline for nested elements
-              content: `\nbye`
-            }
-          ]
-        }
+              content: `\nbye`,
+            },
+          ],
+        },
       ])
     })
 
@@ -166,7 +166,7 @@ describe('DOM parser', () => {
       const ast = parse(`foo&nbsp;&nbsp;bar`, parserOptions)
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.TEXT,
-        content: `foo${nbsp}${nbsp}bar`
+        content: `foo${nbsp}${nbsp}bar`,
       })
     })
 
@@ -181,8 +181,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 11, line: 1, column: 12 },
-          source: '&ampersand;'
-        }
+          source: '&ampersand;',
+        },
       })
     })
 
@@ -190,7 +190,7 @@ describe('DOM parser', () => {
     test('HTML entities compatibility in attribute', () => {
       const ast = parse(
         '<div a="&ampersand;" b="&amp;ersand;" c="&amp!"></div>',
-        parserOptions
+        parserOptions,
       )
       const element = ast.children[0] as ElementNode
       const text1 = (element.props[0] as AttributeNode).value
@@ -203,8 +203,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 7, line: 1, column: 8 },
           end: { offset: 20, line: 1, column: 21 },
-          source: '"&ampersand;"'
-        }
+          source: '"&ampersand;"',
+        },
       })
       expect(text2).toStrictEqual({
         type: NodeTypes.TEXT,
@@ -212,8 +212,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 23, line: 1, column: 24 },
           end: { offset: 37, line: 1, column: 38 },
-          source: '"&amp;ersand;"'
-        }
+          source: '"&amp;ersand;"',
+        },
       })
       expect(text3).toStrictEqual({
         type: NodeTypes.TEXT,
@@ -221,8 +221,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 40, line: 1, column: 41 },
           end: { offset: 47, line: 1, column: 48 },
-          source: '"&amp!"'
-        }
+          source: '"&amp!"',
+        },
       })
     })
 
@@ -236,8 +236,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 6, line: 1, column: 7 },
-          source: '&#x86;'
-        }
+          source: '&#x86;',
+        },
       })
     })
   })
@@ -258,14 +258,14 @@ describe('DOM parser', () => {
           loc: {
             start: { offset: 8, line: 1, column: 9 },
             end: { offset: 16, line: 1, column: 17 },
-            source: 'a &lt; b'
-          }
+            source: 'a &lt; b',
+          },
         },
         loc: {
           start: { offset: 5, line: 1, column: 6 },
           end: { offset: 19, line: 1, column: 20 },
-          source: '{{ a &lt; b }}'
-        }
+          source: '{{ a &lt; b }}',
+        },
       })
     })
   })
@@ -285,9 +285,9 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 0, line: 1, column: 1 },
           end: { offset: 5, line: 1, column: 6 },
-          source: '<img>'
+          source: '<img>',
         },
-        codegenNode: undefined
+        codegenNode: undefined,
       })
     })
 
@@ -297,26 +297,26 @@ describe('DOM parser', () => {
       expect(ast.children[0]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'div',
-        tagType: ElementTypes.ELEMENT
+        tagType: ElementTypes.ELEMENT,
       })
 
       expect(ast.children[1]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
 
       expect(ast.children[2]).toMatchObject({
         type: NodeTypes.ELEMENT,
         tag: 'Comp',
-        tagType: ElementTypes.COMPONENT
+        tagType: ElementTypes.COMPONENT,
       })
     })
 
     test('Strict end tag detection for textarea.', () => {
       const ast = parse(
         '<textarea>hello</textarea</textarea0></texTArea>',
-        parserOptions
+        parserOptions,
       )
       const element = ast.children[0] as ElementNode
       const text = element.children[0] as TextNode
@@ -328,8 +328,8 @@ describe('DOM parser', () => {
         loc: {
           start: { offset: 10, line: 1, column: 11 },
           end: { offset: 37, line: 1, column: 38 },
-          source: 'hello</textarea</textarea0>'
-        }
+          source: 'hello</textarea</textarea0>',
+        },
       })
     })
   })
@@ -359,7 +359,7 @@ describe('DOM parser', () => {
     test('SVG in MATH_ML namespace', () => {
       const ast = parse(
         '<math><annotation-xml><svg></svg></annotation-xml></math>',
-        parserOptions
+        parserOptions,
       )
       const elementMath = ast.children[0] as ElementNode
       const elementAnnotation = elementMath.children[0] as ElementNode
@@ -372,7 +372,7 @@ describe('DOM parser', () => {
     test('html text/html in MATH_ML namespace', () => {
       const ast = parse(
         '<math><annotation-xml encoding="text/html"><test/></annotation-xml></math>',
-        parserOptions
+        parserOptions,
       )
 
       const elementMath = ast.children[0] as ElementNode
@@ -386,7 +386,7 @@ describe('DOM parser', () => {
     test('html application/xhtml+xml in MATH_ML namespace', () => {
       const ast = parse(
         '<math><annotation-xml encoding="application/xhtml+xml"><test/></annotation-xml></math>',
-        parserOptions
+        parserOptions,
       )
       const elementMath = ast.children[0] as ElementNode
       const elementAnnotation = elementMath.children[0] as ElementNode
@@ -399,7 +399,7 @@ describe('DOM parser', () => {
     test('mtext malignmark in MATH_ML namespace', () => {
       const ast = parse(
         '<math><mtext><malignmark/></mtext></math>',
-        parserOptions
+        parserOptions,
       )
       const elementMath = ast.children[0] as ElementNode
       const elementText = elementMath.children[0] as ElementNode
@@ -422,7 +422,7 @@ describe('DOM parser', () => {
     test('foreignObject tag in SVG namespace', () => {
       const ast = parse(
         '<svg><foreignObject><test/></foreignObject></svg>',
-        parserOptions
+        parserOptions,
       )
       const elementSvg = ast.children[0] as ElementNode
       const elementForeignObject = elementSvg.children[0] as ElementNode
@@ -473,7 +473,7 @@ describe('DOM parser', () => {
     test('root ns', () => {
       const ast = parse('<foreignObject><test/></foreignObject>', {
         ...parserOptions,
-        ns: Namespaces.SVG
+        ns: Namespaces.SVG,
       })
       const elementForieng = ast.children[0] as ElementNode
       const element = elementForieng.children[0] as ElementNode
@@ -487,13 +487,13 @@ describe('DOM parser', () => {
       // treatment for <script>, <style>, <textarea> etc.
       const ast = parse('<script><g/><g/></script>', {
         ...parserOptions,
-        ns: Namespaces.SVG
+        ns: Namespaces.SVG,
       })
       const elementSvg = ast.children[0] as ElementNode
       // should parse as nodes instead of text
       expect(elementSvg.children).toMatchObject([
         { type: NodeTypes.ELEMENT, tag: 'g' },
-        { type: NodeTypes.ELEMENT, tag: 'g' }
+        { type: NodeTypes.ELEMENT, tag: 'g' },
       ])
     })
   })
index 12eb280aa7bdd2d25674864f2ae987799fdaee15..8f64adb80a3445e1f8e8573c8cca83811f149036 100644 (file)
@@ -4,7 +4,7 @@ describe('Transition multi children warnings', () => {
   function checkWarning(
     template: string,
     shouldWarn: boolean,
-    message = `<Transition> expects exactly one child element or component.`
+    message = `<Transition> expects exactly one child element or component.`,
   ) {
     const spy = vi.fn()
     compile(template.trim(), {
@@ -12,7 +12,7 @@ describe('Transition multi children warnings', () => {
       transformHoist: null,
       onError: err => {
         spy(err.message)
-      }
+      },
     })
 
     if (shouldWarn) expect(spy).toHaveBeenCalledWith(message)
@@ -27,7 +27,7 @@ describe('Transition multi children warnings', () => {
         <div>hey</div>
       </transition>
       `,
-      true
+      true,
     )
   })
 
@@ -38,7 +38,7 @@ describe('Transition multi children warnings', () => {
         <div v-for="i in items">hey</div>
       </transition>
       `,
-      true
+      true,
     )
   })
 
@@ -50,7 +50,7 @@ describe('Transition multi children warnings', () => {
         <div v-else v-for="i in items">hey</div>
       </transition>
       `,
-      true
+      true,
     )
   })
 
@@ -61,7 +61,7 @@ describe('Transition multi children warnings', () => {
         <template v-if="ok"></template>
       </transition>
       `,
-      true
+      true,
     )
   })
 
@@ -73,7 +73,7 @@ describe('Transition multi children warnings', () => {
         <template v-else></template>
       </transition>
       `,
-      true
+      true,
     )
   })
 
@@ -85,7 +85,7 @@ describe('Transition multi children warnings', () => {
         <div v-if="other">hey</div>
       </transition>
       `,
-      true
+      true,
     )
   })
 
@@ -96,7 +96,7 @@ describe('Transition multi children warnings', () => {
         <div>hey</div>
       </transition>
       `,
-      false
+      false,
     )
   })
 
@@ -107,7 +107,7 @@ describe('Transition multi children warnings', () => {
         <div v-if="a">hey</div>
       </transition>
       `,
-      false
+      false,
     )
   })
 
@@ -120,7 +120,7 @@ describe('Transition multi children warnings', () => {
         <div v-else>hey</div>
       </transition>
       `,
-      false
+      false,
     )
   })
 
@@ -132,7 +132,7 @@ describe('Transition multi children warnings', () => {
         <div v-else>hey</div>
       </transition>
       `,
-      false
+      false,
     )
   })
 })
@@ -143,7 +143,7 @@ test('inject persisted when child has v-show', () => {
     <transition>
       <div v-show="ok" />
     </transition>
-    `).code
+    `).code,
   ).toMatchSnapshot()
 })
 
@@ -161,6 +161,6 @@ test('the v-if/else-if/else branches in Transition should ignore comments', () =
         <p v-else/>
       </div>
     </transition>
-    `).code
+    `).code,
   ).toMatchSnapshot()
 })
index 4df6ee297f3407ab08eb6fd75ad80b7baee72d78..f06b9fd52dd09aff0f2929630f5075f44b4c040e 100644 (file)
@@ -1,4 +1,4 @@
-import { compile, CompilerError } from '../../src'
+import { type CompilerError, compile } from '../../src'
 
 describe('compiler: ignore side effect tags', () => {
   it('should ignore script', () => {
@@ -6,7 +6,7 @@ describe('compiler: ignore side effect tags', () => {
     const { code } = compile(`<script>console.log(1)</script>`, {
       onError(e) {
         err = e
-      }
+      },
     })
     expect(code).not.toMatch('script')
     expect(err).toBeDefined()
@@ -18,7 +18,7 @@ describe('compiler: ignore side effect tags', () => {
     const { code } = compile(`<style>h1 { color: red }</style>`, {
       onError(e) {
         err = e
-      }
+      },
     })
     expect(code).not.toMatch('style')
     expect(err).toBeDefined()
index 90eb25c72ef68679350a6d7eb2e2569f214061dc..b0eb515c2540c0a387522d4391032c28465b1033 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  compile,
-  NodeTypes,
   CREATE_STATIC,
+  ConstantTypes,
+  NodeTypes,
+  compile,
   createSimpleExpression,
-  ConstantTypes
 } from '../../src'
 import {
+  StringifyThresholds,
   stringifyStatic,
-  StringifyThresholds
 } from '../../src/transforms/stringifyStatic'
 
 describe('stringify static html', () => {
@@ -15,7 +15,7 @@ describe('stringify static html', () => {
     return compile(template, {
       hoistStatic: true,
       prefixIdentifiers: true,
-      transformHoist: stringifyStatic
+      transformHoist: stringifyStatic,
     })
   }
 
@@ -25,7 +25,7 @@ describe('stringify static html', () => {
 
   test('should bail on non-eligible static trees', () => {
     const { ast } = compileWithStringify(
-      `<div><div><div>hello</div><div>hello</div></div></div>`
+      `<div><div><div>hello</div><div>hello</div></div></div>`,
     )
     // should be a normal vnode call
     expect(ast.hoists[0]!.type).toBe(NodeTypes.VNODE_CALL)
@@ -35,8 +35,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div><div>${repeat(
         `<span class="foo"/>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div></div>`,
     )
     // should be optimized now
     expect(ast.hoists).toMatchObject([
@@ -47,15 +47,15 @@ describe('stringify static html', () => {
           JSON.stringify(
             `<div>${repeat(
               `<span class="foo"></span>`,
-              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-            )}</div>`
+              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+            )}</div>`,
           ),
-          '1'
-        ]
+          '1',
+        ],
       }, // the children array is hoisted as well
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -63,8 +63,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div><div>${repeat(
         `<span/>`,
-        StringifyThresholds.NODE_COUNT
-      )}</div></div>`
+        StringifyThresholds.NODE_COUNT,
+      )}</div></div>`,
     )
     // should be optimized now
     expect(ast.hoists).toMatchObject([
@@ -75,16 +75,16 @@ describe('stringify static html', () => {
           JSON.stringify(
             `<div>${repeat(
               `<span></span>`,
-              StringifyThresholds.NODE_COUNT
-            )}</div>`
+              StringifyThresholds.NODE_COUNT,
+            )}</div>`,
           ),
-          '1'
-        ]
+          '1',
+        ],
       },
       // the children array is hoisted as well
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -92,8 +92,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div>${repeat(
         `<span class="foo"/>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div>`,
     )
     // should have 6 hoisted nodes (including the entire array),
     // but 2~5 should be null because they are merged into 1
@@ -105,19 +105,19 @@ describe('stringify static html', () => {
           JSON.stringify(
             repeat(
               `<span class="foo"></span>`,
-              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-            )
+              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+            ),
           ),
-          '5'
-        ]
+          '5',
+        ],
       },
       null,
       null,
       null,
       null,
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -125,8 +125,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div><div :style="{ color: 'red' }">${repeat(
         `<span :class="[{ foo: true }, { bar: true }]">{{ 1 }} + {{ false }}</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div></div>`,
     )
     // should be optimized now
     expect(ast.hoists).toMatchObject([
@@ -137,15 +137,15 @@ describe('stringify static html', () => {
           JSON.stringify(
             `<div style="color:red;">${repeat(
               `<span class="foo bar">1 + false</span>`,
-              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-            )}</div>`
+              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+            )}</div>`,
           ),
-          '1'
-        ]
+          '1',
+        ],
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -154,8 +154,8 @@ describe('stringify static html', () => {
       `<div><div>${repeat(
         `<span :class="'foo' + '&gt;ar'">{{ 1 }} + {{ '<' }}</span>` +
           `<span>&amp;</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div></div>`,
     )
     // should be optimized now
     expect(ast.hoists).toMatchObject([
@@ -166,15 +166,15 @@ describe('stringify static html', () => {
           JSON.stringify(
             `<div>${repeat(
               `<span class="foo&gt;ar">1 + &lt;</span>` + `<span>&amp;</span>`,
-              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-            )}</div>`
+              StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+            )}</div>`,
           ),
-          '1'
-        ]
+          '1',
+        ],
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -182,7 +182,7 @@ describe('stringify static html', () => {
     const { ast, code } = compile(
       `<div><div>${repeat(
         `<span class="foo">foo</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
       )}<img src="./foo" /></div></div>`,
       {
         hoistStatic: true,
@@ -195,7 +195,7 @@ describe('stringify static html', () => {
                 '_imports_0_',
                 false,
                 node.loc,
-                ConstantTypes.CAN_HOIST
+                ConstantTypes.CAN_HOIST,
               )
               node.props[0] = {
                 type: NodeTypes.DIRECTIVE,
@@ -203,23 +203,23 @@ describe('stringify static html', () => {
                 arg: createSimpleExpression('src', true),
                 exp,
                 modifiers: [],
-                loc: node.loc
+                loc: node.loc,
               }
             }
-          }
-        ]
-      }
+          },
+        ],
+      },
     )
     expect(ast.hoists).toMatchObject([
       {
         // the expression and the tree are still hoistable
         // but should stay NodeTypes.VNODE_CALL
         // if it's stringified it will be NodeTypes.JS_CALL_EXPRESSION
-        type: NodeTypes.VNODE_CALL
+        type: NodeTypes.VNODE_CALL,
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
     expect(code).toMatchSnapshot()
   })
@@ -230,7 +230,7 @@ describe('stringify static html', () => {
     const { ast, code } = compile(
       `<div><div>${repeat(
         `<span class="foo">foo</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
       )}<img src="./foo" /></div></div>`,
       {
         hoistStatic: true,
@@ -243,7 +243,7 @@ describe('stringify static html', () => {
                 '_imports_0_',
                 false,
                 node.loc,
-                ConstantTypes.CAN_STRINGIFY
+                ConstantTypes.CAN_STRINGIFY,
               )
               node.props[0] = {
                 type: NodeTypes.DIRECTIVE,
@@ -251,22 +251,22 @@ describe('stringify static html', () => {
                 arg: createSimpleExpression('src', true),
                 exp,
                 modifiers: [],
-                loc: node.loc
+                loc: node.loc,
               }
             }
-          }
-        ]
-      }
+          },
+        ],
+      },
     )
     expect(ast.hoists).toMatchObject([
       {
         // the hoisted node should be NodeTypes.JS_CALL_EXPRESSION
         // of `createStaticVNode()` instead of dynamic NodeTypes.VNODE_CALL
-        type: NodeTypes.JS_CALL_EXPRESSION
+        type: NodeTypes.JS_CALL_EXPRESSION,
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
     expect(code).toMatchSnapshot()
   })
@@ -276,31 +276,31 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div><div><input indeterminate>${repeat(
         `<span class="foo">foo</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div></div>`,
     )
     expect(ast.hoists).toMatchObject([
       {
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
 
     const { ast: ast2 } = compileWithStringify(
       `<div><div><input :indeterminate="true">${repeat(
         `<span class="foo">foo</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div></div>`,
     )
     expect(ast2.hoists).toMatchObject([
       {
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -308,31 +308,31 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div><div>${repeat(
         `<span class="foo">foo</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}<input indeterminate></div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}<input indeterminate></div></div>`,
     )
     expect(ast.hoists).toMatchObject([
       {
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
 
     const { ast: ast2 } = compileWithStringify(
       `<div><div>${repeat(
         `<span class="foo">foo</span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}<input :indeterminate="true"></div></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}<input :indeterminate="true"></div></div>`,
     )
     expect(ast2.hoists).toMatchObject([
       {
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -340,16 +340,16 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<table><tbody>${repeat(
         `<tr class="foo"><td>foo</td></tr>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</tbody></table>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</tbody></table>`,
     )
     expect(ast.hoists).toMatchObject([
       {
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       },
       {
-        type: NodeTypes.JS_ARRAY_EXPRESSION
-      }
+        type: NodeTypes.JS_ARRAY_EXPRESSION,
+      },
     ])
   })
 
@@ -357,30 +357,30 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<foo>${repeat(
         `<div class="foo"></div>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</foo>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</foo>`,
     )
     expect(ast.hoists.length).toBe(
-      StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
+      StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
     )
     ast.hoists.forEach(node => {
       expect(node).toMatchObject({
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       })
     })
 
     const { ast: ast2 } = compileWithStringify(
       `<foo><template #foo>${repeat(
         `<div class="foo"></div>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</template></foo>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</template></foo>`,
     )
     expect(ast2.hoists.length).toBe(
-      StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
+      StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
     )
     ast2.hoists.forEach(node => {
       expect(node).toMatchObject({
-        type: NodeTypes.VNODE_CALL // not CALL_EXPRESSION
+        type: NodeTypes.VNODE_CALL, // not CALL_EXPRESSION
       })
     })
   })
@@ -389,8 +389,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div>${repeat(
         `<span :title="null"></span>`,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</div>`,
     )
     expect(ast.hoists[0]).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
@@ -399,11 +399,11 @@ describe('stringify static html', () => {
         JSON.stringify(
           `${repeat(
             `<span></span>`,
-            StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-          )}`
+            StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+          )}`,
         ),
-        '5'
-      ]
+        '5',
+      ],
     })
   })
 
@@ -412,8 +412,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<button :disabled="false">enable</button>${repeat(
         `<div></div>`,
-        StringifyThresholds.NODE_COUNT
-      )}`
+        StringifyThresholds.NODE_COUNT,
+      )}`,
     )
     expect(ast.hoists[0]).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
@@ -422,11 +422,11 @@ describe('stringify static html', () => {
         JSON.stringify(
           `<button>enable</button>${repeat(
             `<div></div>`,
-            StringifyThresholds.NODE_COUNT
-          )}`
+            StringifyThresholds.NODE_COUNT,
+          )}`,
         ),
-        '21'
-      ]
+        '21',
+      ],
     })
   })
 
@@ -436,8 +436,8 @@ describe('stringify static html', () => {
     const { ast } = compileWithStringify(
       `<div>${svg}${repeat(
         repeated,
-        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-      )}</svg></div>`
+        StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+      )}</svg></div>`,
     )
     expect(ast.hoists[0]).toMatchObject({
       type: NodeTypes.JS_CALL_EXPRESSION,
@@ -446,11 +446,11 @@ describe('stringify static html', () => {
         JSON.stringify(
           `${svg}${repeat(
             repeated,
-            StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
-          )}</svg>`
+            StringifyThresholds.ELEMENT_WITH_BINDING_COUNT,
+          )}</svg>`,
         ),
-        '1'
-      ]
+        '1',
+      ],
     })
   })
 
index 6eee9f8ba3821ebfb66e32401bd59bd5f8602431..51c40c45d98eec49cd4bd08add23f31733ace006 100644 (file)
@@ -1,10 +1,10 @@
 import {
+  type CompilerOptions,
+  type ElementNode,
+  NodeTypes,
+  type VNodeCall,
   baseParse as parse,
   transform,
-  CompilerOptions,
-  ElementNode,
-  NodeTypes,
-  VNodeCall
 } from '@vue/compiler-core'
 import { transformBind } from '../../../compiler-core/src/transforms/vBind'
 import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
@@ -12,16 +12,16 @@ import { transformStyle } from '../../src/transforms/transformStyle'
 
 function transformWithStyleTransform(
   template: string,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ) {
   const ast = parse(template)
   transform(ast, {
     nodeTransforms: [transformStyle],
-    ...options
+    ...options,
   })
   return {
     root: ast,
-    node: ast.children[0] as ElementNode
+    node: ast.children[0] as ElementNode,
   }
 }
 
@@ -34,13 +34,13 @@ describe('compiler: style transform', () => {
       arg: {
         type: NodeTypes.SIMPLE_EXPRESSION,
         content: `style`,
-        isStatic: true
+        isStatic: true,
       },
       exp: {
         type: NodeTypes.SIMPLE_EXPRESSION,
         content: `{"color":"red"}`,
-        isStatic: false
-      }
+        isStatic: false,
+      },
     })
   })
 
@@ -48,8 +48,8 @@ describe('compiler: style transform', () => {
     const { node } = transformWithStyleTransform(`<div style="color: red"/>`, {
       nodeTransforms: [transformStyle, transformElement],
       directiveTransforms: {
-        bind: transformBind
-      }
+        bind: transformBind,
+      },
     })
     expect((node.codegenNode as VNodeCall).props).toMatchObject({
       type: NodeTypes.JS_OBJECT_EXPRESSION,
@@ -58,15 +58,15 @@ describe('compiler: style transform', () => {
           key: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `style`,
-            isStatic: true
+            isStatic: true,
           },
           value: {
             type: NodeTypes.SIMPLE_EXPRESSION,
             content: `{"color":"red"}`,
-            isStatic: false
-          }
-        }
-      ]
+            isStatic: false,
+          },
+        },
+      ],
     })
     // should not cause the STYLE patchFlag to be attached
     expect((node.codegenNode as VNodeCall).patchFlag).toBeUndefined()
index af33652393869880a008c1db5b6d144b0ccf2c64..a59a7a40aaf32ac3a180a1aed99ecad4935e2544 100644 (file)
@@ -1,14 +1,14 @@
 import {
+  type CompilerOptions,
+  type PlainElementNode,
   baseParse as parse,
   transform,
-  PlainElementNode,
-  CompilerOptions
 } from '@vue/compiler-core'
 import { transformVHtml } from '../../src/transforms/vHtml'
 import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
 import {
   createObjectMatcher,
-  genFlagText
+  genFlagText,
 } from '../../../compiler-core/__tests__/testUtils'
 import { PatchFlags } from '@vue/shared'
 import { DOMErrorCodes } from '../../src/errors'
@@ -18,9 +18,9 @@ function transformWithVHtml(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms: [transformElement],
     directiveTransforms: {
-      html: transformVHtml
+      html: transformVHtml,
     },
-    ...options
+    ...options,
   })
   return ast
 }
@@ -31,40 +31,40 @@ describe('compiler: v-html transform', () => {
     expect((ast.children[0] as PlainElementNode).codegenNode).toMatchObject({
       tag: `"div"`,
       props: createObjectMatcher({
-        innerHTML: `[test]`
+        innerHTML: `[test]`,
       }),
       children: undefined,
       patchFlag: genFlagText(PatchFlags.PROPS),
-      dynamicProps: `["innerHTML"]`
+      dynamicProps: `["innerHTML"]`,
     })
   })
 
   it('should raise error and ignore children when v-html is present', () => {
     const onError = vi.fn()
     const ast = transformWithVHtml(`<div v-html="test">hello</div>`, {
-      onError
+      onError,
     })
     expect(onError.mock.calls).toMatchObject([
-      [{ code: DOMErrorCodes.X_V_HTML_WITH_CHILDREN }]
+      [{ code: DOMErrorCodes.X_V_HTML_WITH_CHILDREN }],
     ])
     expect((ast.children[0] as PlainElementNode).codegenNode).toMatchObject({
       tag: `"div"`,
       props: createObjectMatcher({
-        innerHTML: `[test]`
+        innerHTML: `[test]`,
       }),
       children: undefined, // <-- children should have been removed
       patchFlag: genFlagText(PatchFlags.PROPS),
-      dynamicProps: `["innerHTML"]`
+      dynamicProps: `["innerHTML"]`,
     })
   })
 
   it('should raise error if has no expression', () => {
     const onError = vi.fn()
     transformWithVHtml(`<div v-html></div>`, {
-      onError
+      onError,
     })
     expect(onError.mock.calls).toMatchObject([
-      [{ code: DOMErrorCodes.X_V_HTML_NO_EXPRESSION }]
+      [{ code: DOMErrorCodes.X_V_HTML_NO_EXPRESSION }],
     ])
   })
 })
index a67ca5d691f7faab0a5d3014dd9b65a3e4881d62..02d188f01b9e6e01f57961a65b2a25e40d1e73a6 100644 (file)
@@ -1,8 +1,8 @@
 import {
+  type CompilerOptions,
+  generate,
   baseParse as parse,
   transform,
-  CompilerOptions,
-  generate
 } from '@vue/compiler-core'
 import { transformModel } from '../../src/transforms/vModel'
 import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
@@ -12,7 +12,7 @@ import {
   V_MODEL_DYNAMIC,
   V_MODEL_RADIO,
   V_MODEL_SELECT,
-  V_MODEL_TEXT
+  V_MODEL_TEXT,
 } from '../../src/runtimeHelpers'
 
 function transformWithModel(template: string, options: CompilerOptions = {}) {
@@ -20,9 +20,9 @@ function transformWithModel(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms: [transformElement],
     directiveTransforms: {
-      model: transformModel
+      model: transformModel,
     },
-    ...options
+    ...options,
   })
   return ast
 }
@@ -70,7 +70,7 @@ describe('compiler: transform v-model', () => {
     expect(generate(root).code).toMatchSnapshot()
 
     const root2 = transformWithModel(
-      '<input v-bind:[key]="val" v-model="model" />'
+      '<input v-bind:[key]="val" v-model="model" />',
     )
     expect(root2.helpers).toContain(V_MODEL_DYNAMIC)
     expect(generate(root2).code).toMatchSnapshot()
@@ -98,8 +98,8 @@ describe('compiler: transform v-model', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT
-        })
+          code: DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT,
+        }),
       )
     })
 
@@ -110,8 +110,8 @@ describe('compiler: transform v-model', () => {
       expect(onError).toHaveBeenCalledTimes(1)
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT
-        })
+          code: DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT,
+        }),
       )
     })
 
@@ -119,7 +119,7 @@ describe('compiler: transform v-model', () => {
       const onError = vi.fn()
       const root = transformWithModel('<my-input v-model="model" />', {
         onError,
-        isCustomElement: tag => tag.startsWith('my-')
+        isCustomElement: tag => tag.startsWith('my-'),
       })
       expect(root.helpers).toContain(V_MODEL_TEXT)
       expect(onError).not.toHaveBeenCalled()
@@ -129,24 +129,24 @@ describe('compiler: transform v-model', () => {
     test('should raise error if used file input element', () => {
       const onError = vi.fn()
       transformWithModel(`<input type="file" v-model="test"/>`, {
-        onError
+        onError,
       })
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT
-        })
+          code: DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT,
+        }),
       )
     })
 
     test('should error on dynamic value binding alongside v-model', () => {
       const onError = vi.fn()
       transformWithModel(`<input v-model="test" :value="test" />`, {
-        onError
+        onError,
       })
       expect(onError).toHaveBeenCalledWith(
         expect.objectContaining({
-          code: DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE
-        })
+          code: DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE,
+        }),
       )
     })
 
@@ -154,7 +154,7 @@ describe('compiler: transform v-model', () => {
     test('should NOT error on static value binding alongside v-model', () => {
       const onError = vi.fn()
       transformWithModel(`<input v-model="test" value="test" />`, {
-        onError
+        onError,
       })
       expect(onError).not.toHaveBeenCalled()
     })
index 42b4cd798886c9680fb2c84e9c12a5e98797d04f..2e80729119d16c4985d7edfd9fc5ca451259d4ee 100644 (file)
@@ -1,14 +1,14 @@
 import {
-  baseParse as parse,
-  CompilerOptions,
-  ElementNode,
+  BindingTypes,
+  type CompilerOptions,
+  type ElementNode,
+  NodeTypes,
+  type ObjectExpression,
   TO_HANDLER_KEY,
+  type VNodeCall,
   helperNameMap,
-  NodeTypes,
-  ObjectExpression,
+  baseParse as parse,
   transform,
-  VNodeCall,
-  BindingTypes
 } from '@vue/compiler-core'
 import { transformOn } from '../../src/transforms/vOn'
 import { V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS } from '../../src/runtimeHelpers'
@@ -22,31 +22,31 @@ function parseWithVOn(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms: [transformExpression, transformElement],
     directiveTransforms: {
-      on: transformOn
+      on: transformOn,
     },
-    ...options
+    ...options,
   })
   const node = (ast.children[0] as ElementNode).codegenNode as VNodeCall
   return {
     root: ast,
     node,
-    props: (node.props as ObjectExpression).properties
+    props: (node.props as ObjectExpression).properties,
   }
 }
 
 describe('compiler-dom: transform v-on', () => {
   it('should support multiple modifiers w/ prefixIdentifiers: true', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @click.stop.prevent="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       value: {
         callee: V_ON_WITH_MODIFIERS,
-        arguments: [{ content: '_ctx.test' }, '["stop","prevent"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["stop","prevent"]'],
+      },
     })
   })
 
@@ -54,8 +54,8 @@ describe('compiler-dom: transform v-on', () => {
     const { props } = parseWithVOn(
       `<div @click.stop="test" @keyup.enter="test" />`,
       {
-        prefixIdentifiers: true
-      }
+        prefixIdentifiers: true,
+      },
     )
     const [clickProp, keyUpProp] = props
 
@@ -64,95 +64,95 @@ describe('compiler-dom: transform v-on', () => {
       type: NodeTypes.JS_PROPERTY,
       value: {
         callee: V_ON_WITH_MODIFIERS,
-        arguments: [{ content: '_ctx.test' }, '["stop"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["stop"]'],
+      },
     })
     expect(keyUpProp).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       value: {
         callee: V_ON_WITH_KEYS,
-        arguments: [{ content: '_ctx.test' }, '["enter"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["enter"]'],
+      },
     })
   })
 
   it('should support multiple modifiers and event options w/ prefixIdentifiers: true', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @click.stop.capture.once="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       key: {
-        content: `onClickCaptureOnce`
+        content: `onClickCaptureOnce`,
       },
       value: {
         callee: V_ON_WITH_MODIFIERS,
-        arguments: [{ content: '_ctx.test' }, '["stop"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["stop"]'],
+      },
     })
   })
 
   it('should wrap keys guard for keyboard events or dynamic events', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @keydown.stop.capture.ctrl.a="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       key: {
-        content: `onKeydownCapture`
+        content: `onKeydownCapture`,
       },
       value: {
         callee: V_ON_WITH_KEYS,
         arguments: [
           {
             callee: V_ON_WITH_MODIFIERS,
-            arguments: [{ content: '_ctx.test' }, '["stop","ctrl"]']
+            arguments: [{ content: '_ctx.test' }, '["stop","ctrl"]'],
           },
-          '["a"]'
-        ]
-      }
+          '["a"]',
+        ],
+      },
     })
   })
 
   it('should not wrap keys guard if no key modifier is present', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @keyup.exact="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       value: {
         callee: V_ON_WITH_MODIFIERS,
-        arguments: [{ content: '_ctx.test' }, '["exact"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["exact"]'],
+      },
     })
   })
 
   it('should wrap keys guard for static key event w/ left/right modifiers', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @keyup.left="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       value: {
         callee: V_ON_WITH_KEYS,
-        arguments: [{ content: '_ctx.test' }, '["left"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["left"]'],
+      },
     })
   })
 
   it('should wrap both for dynamic key event w/ left/right modifiers', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @[e].left="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
@@ -161,41 +161,41 @@ describe('compiler-dom: transform v-on', () => {
         arguments: [
           {
             callee: V_ON_WITH_MODIFIERS,
-            arguments: [{ content: `_ctx.test` }, `["left"]`]
+            arguments: [{ content: `_ctx.test` }, `["left"]`],
           },
-          '["left"]'
-        ]
-      }
+          '["left"]',
+        ],
+      },
     })
   })
 
   it('should not wrap normal guard if there is only keys guard', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @keyup.enter="test"/>`, {
-      prefixIdentifiers: true
+      prefixIdentifiers: true,
     })
     expect(prop).toMatchObject({
       type: NodeTypes.JS_PROPERTY,
       value: {
         callee: V_ON_WITH_KEYS,
-        arguments: [{ content: '_ctx.test' }, '["enter"]']
-      }
+        arguments: [{ content: '_ctx.test' }, '["enter"]'],
+      },
     })
   })
 
   test('should transform click.right', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @click.right="test"/>`)
     expect(prop.key).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `onContextmenu`
+      content: `onContextmenu`,
     })
 
     // dynamic
     const {
-      props: [prop2]
+      props: [prop2],
     } = parseWithVOn(`<div @[event].right="test"/>`)
     // (_toHandlerKey(event)).toLowerCase() === "onclick" ? "onContextmenu" : (_toHandlerKey(event))
     expect(prop2.key).toMatchObject({
@@ -206,34 +206,34 @@ describe('compiler-dom: transform v-on', () => {
           children: [
             `_${helperNameMap[TO_HANDLER_KEY]}(`,
             { content: 'event' },
-            `)`
-          ]
+            `)`,
+          ],
         },
         `) === "onClick" ? "onContextmenu" : (`,
         {
           children: [
             `_${helperNameMap[TO_HANDLER_KEY]}(`,
             { content: 'event' },
-            `)`
-          ]
+            `)`,
+          ],
         },
-        `)`
-      ]
+        `)`,
+      ],
     })
   })
 
   test('should transform click.middle', () => {
     const {
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @click.middle="test"/>`)
     expect(prop.key).toMatchObject({
       type: NodeTypes.SIMPLE_EXPRESSION,
-      content: `onMouseup`
+      content: `onMouseup`,
     })
 
     // dynamic
     const {
-      props: [prop2]
+      props: [prop2],
     } = parseWithVOn(`<div @[event].middle="test"/>`)
     // (_eventNaming(event)).toLowerCase() === "onclick" ? "onMouseup" : (_eventNaming(event))
     expect(prop2.key).toMatchObject({
@@ -244,48 +244,48 @@ describe('compiler-dom: transform v-on', () => {
           children: [
             `_${helperNameMap[TO_HANDLER_KEY]}(`,
             { content: 'event' },
-            `)`
-          ]
+            `)`,
+          ],
         },
         `) === "onClick" ? "onMouseup" : (`,
         {
           children: [
             `_${helperNameMap[TO_HANDLER_KEY]}(`,
             { content: 'event' },
-            `)`
-          ]
+            `)`,
+          ],
         },
-        `)`
-      ]
+        `)`,
+      ],
     })
   })
 
   test('cache handler w/ modifiers', () => {
     const {
       root,
-      props: [prop]
+      props: [prop],
     } = parseWithVOn(`<div @keyup.enter.capture="foo" />`, {
       prefixIdentifiers: true,
-      cacheHandlers: true
+      cacheHandlers: true,
     })
     expect(root.cached).toBe(1)
     // should not treat cached handler as dynamicProp, so it should have no
     // dynamicProps flags and only the hydration flag
     expect((root as any).children[0].codegenNode.patchFlag).toBe(
-      genFlagText(PatchFlags.NEED_HYDRATION)
+      genFlagText(PatchFlags.NEED_HYDRATION),
     )
     expect(prop).toMatchObject({
       key: {
-        content: `onKeyupCapture`
+        content: `onKeyupCapture`,
       },
       value: {
         type: NodeTypes.JS_CACHE_EXPRESSION,
         index: 0,
         value: {
           type: NodeTypes.JS_CALL_EXPRESSION,
-          callee: V_ON_WITH_KEYS
-        }
-      }
+          callee: V_ON_WITH_KEYS,
+        },
+      },
     })
   })
 
@@ -293,11 +293,11 @@ describe('compiler-dom: transform v-on', () => {
     const { node } = parseWithVOn(`<div @keydown.up="foo" />`, {
       prefixIdentifiers: true,
       bindingMetadata: {
-        foo: BindingTypes.SETUP_CONST
+        foo: BindingTypes.SETUP_CONST,
       },
       directiveTransforms: {
-        on: transformOn
-      }
+        on: transformOn,
+      },
     })
     // should only have hydration flag
     expect(node.patchFlag).toBe(genFlagText(PatchFlags.NEED_HYDRATION))
index 6d521c8e10db47f1236a488d98308121c8be2574..11aa62464d348636a919f19dc7728d05b244e5e9 100644 (file)
@@ -1,8 +1,8 @@
 import {
+  type CompilerOptions,
+  generate,
   baseParse as parse,
   transform,
-  generate,
-  CompilerOptions
 } from '@vue/compiler-core'
 import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
 import { transformShow } from '../../src/transforms/vShow'
@@ -13,9 +13,9 @@ function transformWithShow(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms: [transformElement],
     directiveTransforms: {
-      show: transformShow
+      show: transformShow,
     },
-    ...options
+    ...options,
   })
   return ast
 }
@@ -34,8 +34,8 @@ describe('compiler: v-show transform', () => {
     expect(onError).toHaveBeenCalledTimes(1)
     expect(onError).toHaveBeenCalledWith(
       expect.objectContaining({
-        code: DOMErrorCodes.X_V_SHOW_NO_EXPRESSION
-      })
+        code: DOMErrorCodes.X_V_SHOW_NO_EXPRESSION,
+      }),
     )
   })
 })
index 22db3ec05e2f17604c952188be82b2e40e061aed..1b717e8339846509b92d05e696c4c0537b7fea41 100644 (file)
@@ -1,14 +1,14 @@
 import {
+  type CompilerOptions,
+  type PlainElementNode,
   baseParse as parse,
   transform,
-  PlainElementNode,
-  CompilerOptions
 } from '@vue/compiler-core'
 import { transformVText } from '../../src/transforms/vText'
 import { transformElement } from '../../../compiler-core/src/transforms/transformElement'
 import {
   createObjectMatcher,
-  genFlagText
+  genFlagText,
 } from '../../../compiler-core/__tests__/testUtils'
 import { PatchFlags } from '@vue/shared'
 import { DOMErrorCodes } from '../../src/errors'
@@ -18,9 +18,9 @@ function transformWithVText(template: string, options: CompilerOptions = {}) {
   transform(ast, {
     nodeTransforms: [transformElement],
     directiveTransforms: {
-      text: transformVText
+      text: transformVText,
     },
-    ...options
+    ...options,
   })
   return ast
 }
@@ -32,43 +32,43 @@ describe('compiler: v-text transform', () => {
       tag: `"div"`,
       props: createObjectMatcher({
         textContent: {
-          arguments: [{ content: 'test' }]
-        }
+          arguments: [{ content: 'test' }],
+        },
       }),
       children: undefined,
       patchFlag: genFlagText(PatchFlags.PROPS),
-      dynamicProps: `["textContent"]`
+      dynamicProps: `["textContent"]`,
     })
   })
 
   it('should raise error and ignore children when v-text is present', () => {
     const onError = vi.fn()
     const ast = transformWithVText(`<div v-text="test">hello</div>`, {
-      onError
+      onError,
     })
     expect(onError.mock.calls).toMatchObject([
-      [{ code: DOMErrorCodes.X_V_TEXT_WITH_CHILDREN }]
+      [{ code: DOMErrorCodes.X_V_TEXT_WITH_CHILDREN }],
     ])
     expect((ast.children[0] as PlainElementNode).codegenNode).toMatchObject({
       tag: `"div"`,
       props: createObjectMatcher({
         textContent: {
-          arguments: [{ content: 'test' }]
-        }
+          arguments: [{ content: 'test' }],
+        },
       }),
       children: undefined, // <-- children should have been removed
       patchFlag: genFlagText(PatchFlags.PROPS),
-      dynamicProps: `["textContent"]`
+      dynamicProps: `["textContent"]`,
     })
   })
 
   it('should raise error if has no expression', () => {
     const onError = vi.fn()
     transformWithVText(`<div v-text></div>`, {
-      onError
+      onError,
     })
     expect(onError.mock.calls).toMatchObject([
-      [{ code: DOMErrorCodes.X_V_TEXT_NO_EXPRESSION }]
+      [{ code: DOMErrorCodes.X_V_TEXT_NO_EXPRESSION }],
     ])
   })
 })
index f8582c0b6ac11a6646d6c2f09b14ad4c09f77de4..b47624840abe1e34b0619ff1c04d661394ef7bd3 100644 (file)
@@ -1,8 +1,8 @@
 import {
-  SourceLocation,
-  CompilerError,
+  type CompilerError,
+  ErrorCodes,
+  type SourceLocation,
   createCompilerError,
-  ErrorCodes
 } from '@vue/compiler-core'
 
 export interface DOMCompilerError extends CompilerError {
@@ -11,12 +11,12 @@ export interface DOMCompilerError extends CompilerError {
 
 export function createDOMCompilerError(
   code: DOMErrorCodes,
-  loc?: SourceLocation
+  loc?: SourceLocation,
 ) {
   return createCompilerError(
     code,
     loc,
-    __DEV__ || !__BROWSER__ ? DOMErrorMessages : undefined
+    __DEV__ || !__BROWSER__ ? DOMErrorMessages : undefined,
   ) as DOMCompilerError
 }
 
@@ -32,7 +32,7 @@ export enum DOMErrorCodes {
   X_V_SHOW_NO_EXPRESSION,
   X_TRANSITION_INVALID_CHILDREN,
   X_IGNORED_SIDE_EFFECT_TAG,
-  __EXTEND_POINT__
+  __EXTEND_POINT__,
 }
 
 if (__TEST__) {
@@ -43,7 +43,7 @@ if (__TEST__) {
     throw new Error(
       `DOMErrorCodes need to be updated to ${
         ErrorCodes.__EXTEND_POINT__ + 1
-      } to match extension point from core ErrorCodes.`
+      } to match extension point from core ErrorCodes.`,
     )
   }
 }
@@ -59,5 +59,5 @@ export const DOMErrorMessages: { [code: number]: string } = {
   [DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE]: `Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.`,
   [DOMErrorCodes.X_V_SHOW_NO_EXPRESSION]: `v-show is missing expression.`,
   [DOMErrorCodes.X_TRANSITION_INVALID_CHILDREN]: `<Transition> expects exactly one child element or component.`,
-  [DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`
+  [DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG]: `Tags with side effect (<script> and <style>) are ignored in client component templates.`,
 }
index 2fc43b242019b48dfa06ddc14b4a20cfb7eb21c9..a3a738a8fb13fa2338a8c3413db73ecaf7203559 100644 (file)
@@ -1,13 +1,13 @@
 import {
+  type CodegenResult,
+  type CompilerOptions,
+  type DirectiveTransform,
+  type NodeTransform,
+  type ParserOptions,
+  type RootNode,
   baseCompile,
   baseParse,
-  CompilerOptions,
-  CodegenResult,
-  ParserOptions,
-  RootNode,
   noopDirectiveTransform,
-  NodeTransform,
-  DirectiveTransform
 } from '@vue/compiler-core'
 import { parserOptions } from './parserOptions'
 import { transformStyle } from './transforms/transformStyle'
@@ -25,7 +25,7 @@ export { parserOptions }
 
 export const DOMNodeTransforms: NodeTransform[] = [
   transformStyle,
-  ...(__DEV__ ? [transformTransition] : [])
+  ...(__DEV__ ? [transformTransition] : []),
 ]
 
 export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
@@ -34,12 +34,12 @@ export const DOMDirectiveTransforms: Record<string, DirectiveTransform> = {
   text: transformVText,
   model: transformModel, // override compiler-core
   on: transformOn, // override compiler-core
-  show: transformShow
+  show: transformShow,
 }
 
 export function compile(
   src: string | RootNode,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ): CodegenResult {
   return baseCompile(
     src,
@@ -50,15 +50,15 @@ export function compile(
         // by compiler-ssr to generate vnode fallback branches
         ignoreSideEffectTags,
         ...DOMNodeTransforms,
-        ...(options.nodeTransforms || [])
+        ...(options.nodeTransforms || []),
       ],
       directiveTransforms: extend(
         {},
         DOMDirectiveTransforms,
-        options.directiveTransforms || {}
+        options.directiveTransforms || {},
       ),
-      transformHoist: __BROWSER__ ? null : stringifyStatic
-    })
+      transformHoist: __BROWSER__ ? null : stringifyStatic,
+    }),
   )
 }
 
@@ -71,6 +71,6 @@ export { transformStyle } from './transforms/transformStyle'
 export {
   createDOMCompilerError,
   DOMErrorCodes,
-  DOMErrorMessages
+  DOMErrorMessages,
 } from './errors'
 export * from '@vue/compiler-core'
index 244251b9ba9e3d53b6874a9801cf8ea2bc53b4a4..e4899a9bf214fdd8004dd4a0679c6957fbeac16e 100644 (file)
@@ -1,5 +1,5 @@
-import { ParserOptions, NodeTypes, Namespaces } from '@vue/compiler-core'
-import { isVoidTag, isHTMLTag, isSVGTag, isMathMLTag } from '@vue/shared'
+import { Namespaces, NodeTypes, type ParserOptions } from '@vue/compiler-core'
+import { isHTMLTag, isMathMLTag, isSVGTag, isVoidTag } from '@vue/shared'
 import { TRANSITION, TRANSITION_GROUP } from './runtimeHelpers'
 import { decodeHtmlBrowser } from './decodeHtmlBrowser'
 
@@ -33,7 +33,7 @@ export const parserOptions: ParserOptions = {
               a.name === 'encoding' &&
               a.value != null &&
               (a.value.content === 'text/html' ||
-                a.value.content === 'application/xhtml+xml')
+                a.value.content === 'application/xhtml+xml'),
           )
         ) {
           ns = Namespaces.HTML
@@ -64,5 +64,5 @@ export const parserOptions: ParserOptions = {
       }
     }
     return ns
-  }
+  },
 }
index 19c595ef69ac21495553bd92e001849542d55302..db829096cb87e89abb2c53879635ef9c685796fa 100644 (file)
@@ -24,5 +24,5 @@ registerRuntimeHelpers({
   [V_ON_WITH_KEYS]: `withKeys`,
   [V_SHOW]: `vShow`,
   [TRANSITION]: `Transition`,
-  [TRANSITION_GROUP]: `TransitionGroup`
+  [TRANSITION_GROUP]: `TransitionGroup`,
 })
index 970f16faf6a601347a926322a0aa9469354bb9c5..f6cf968e37263492a9348f7a9afcca03684a6948 100644 (file)
@@ -1,12 +1,12 @@
 import {
-  NodeTransform,
-  NodeTypes,
+  type ComponentNode,
   ElementTypes,
-  ComponentNode,
-  IfBranchNode
+  type IfBranchNode,
+  type NodeTransform,
+  NodeTypes,
 } from '@vue/compiler-core'
 import { TRANSITION } from '../runtimeHelpers'
-import { createDOMCompilerError, DOMErrorCodes } from '../errors'
+import { DOMErrorCodes, createDOMCompilerError } from '../errors'
 
 export const transformTransition: NodeTransform = (node, context) => {
   if (
@@ -28,9 +28,9 @@ export const transformTransition: NodeTransform = (node, context) => {
               {
                 start: node.children[0].loc.start,
                 end: node.children[node.children.length - 1].loc.end,
-                source: ''
-              }
-            )
+                source: '',
+              },
+            ),
           )
         }
 
@@ -45,7 +45,7 @@ export const transformTransition: NodeTransform = (node, context) => {
                 name: 'persisted',
                 nameLoc: node.loc,
                 value: undefined,
-                loc: node.loc
+                loc: node.loc,
               })
             }
           }
@@ -60,7 +60,7 @@ function hasMultipleChildren(node: ComponentNode | IfBranchNode): boolean {
   const children = (node.children = node.children.filter(
     c =>
       c.type !== NodeTypes.COMMENT &&
-      !(c.type === NodeTypes.TEXT && !c.content.trim())
+      !(c.type === NodeTypes.TEXT && !c.content.trim()),
   ))
   const child = children[0]
   return (
index fa37b366fa2581e0a79655491687f8dfaf1cc6bf..81dc498497b2654489bc71956ec41e62aaf99f95 100644 (file)
@@ -1,4 +1,4 @@
-import { NodeTransform, NodeTypes, ElementTypes } from '@vue/compiler-core'
+import { ElementTypes, type NodeTransform, NodeTypes } from '@vue/compiler-core'
 import { DOMErrorCodes, createDOMCompilerError } from '../errors'
 
 export const ignoreSideEffectTags: NodeTransform = (node, context) => {
@@ -11,8 +11,8 @@ export const ignoreSideEffectTags: NodeTransform = (node, context) => {
       context.onError(
         createDOMCompilerError(
           DOMErrorCodes.X_IGNORED_SIDE_EFFECT_TAG,
-          node.loc
-        )
+          node.loc,
+        ),
       )
     context.removeNode()
   }
index 32e5b3c2289ea4f6e5d12fcf48c36eef7d09635e..a5ff770f4e82c2d9c335296a2f4426c3a6241640 100644 (file)
@@ -2,40 +2,40 @@
  * This module is Node-only.
  */
 import {
-  NodeTypes,
-  ElementNode,
-  TransformContext,
-  TemplateChildNode,
-  SimpleExpressionNode,
-  createCallExpression,
-  HoistTransform,
   CREATE_STATIC,
-  ExpressionNode,
-  ElementTypes,
-  PlainElementNode,
-  JSChildNode,
-  TextCallNode,
   ConstantTypes,
-  Namespaces
+  type ElementNode,
+  ElementTypes,
+  type ExpressionNode,
+  type HoistTransform,
+  type JSChildNode,
+  Namespaces,
+  NodeTypes,
+  type PlainElementNode,
+  type SimpleExpressionNode,
+  type TemplateChildNode,
+  type TextCallNode,
+  type TransformContext,
+  createCallExpression,
 } from '@vue/compiler-core'
 import {
-  isVoidTag,
+  escapeHtml,
+  isBooleanAttr,
+  isKnownHtmlAttr,
+  isKnownSvgAttr,
   isString,
   isSymbol,
-  isKnownHtmlAttr,
-  escapeHtml,
-  toDisplayString,
+  isVoidTag,
+  makeMap,
   normalizeClass,
   normalizeStyle,
   stringifyStyle,
-  makeMap,
-  isKnownSvgAttr,
-  isBooleanAttr
+  toDisplayString,
 } from '@vue/shared'
 
 export enum StringifyThresholds {
   ELEMENT_WITH_BINDING_COUNT = 5,
-  NODE_COUNT = 20
+  NODE_COUNT = 20,
 }
 
 type StringifiableNode = PlainElementNode | TextCallNode
@@ -87,11 +87,11 @@ export const stringifyStatic: HoistTransform = (children, context, parent) => {
       // combine all currently eligible nodes into a single static vnode call
       const staticCall = createCallExpression(context.helper(CREATE_STATIC), [
         JSON.stringify(
-          currentChunk.map(node => stringifyNode(node, context)).join('')
+          currentChunk.map(node => stringifyNode(node, context)).join(''),
         ).replace(expReplaceRE, `" + $1 + "`),
         // the 2nd argument indicates the number of DOM nodes this static vnode
         // will insert / hydrate
-        String(currentChunk.length)
+        String(currentChunk.length),
       ])
       // replace the first node's hoisted expression with the static vnode call
       replaceHoist(currentChunk[0], staticCall, context)
@@ -161,14 +161,14 @@ const isStringifiableAttr = (name: string, ns: Namespaces) => {
 const replaceHoist = (
   node: StringifiableNode,
   replacement: JSChildNode | null,
-  context: TransformContext
+  context: TransformContext,
 ) => {
   const hoistToReplace = (node.codegenNode as SimpleExpressionNode).hoisted!
   context.hoists[context.hoists.indexOf(hoistToReplace)] = replacement
 }
 
 const isNonStringifiable = /*#__PURE__*/ makeMap(
-  `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`
+  `caption,thead,tr,th,tbody,td,tfoot,colgroup,col`,
 )
 
 /**
@@ -248,7 +248,7 @@ function analyzeNode(node: StringifiableNode): [number, number] | false {
 
 function stringifyNode(
   node: string | TemplateChildNode,
-  context: TransformContext
+  context: TransformContext,
 ): string {
   if (isString(node)) {
     return node
@@ -277,7 +277,7 @@ function stringifyNode(
 
 function stringifyElement(
   node: ElementNode,
-  context: TransformContext
+  context: TransformContext,
 ): string {
   let res = `<${node.tag}`
   let innerHTML = ''
@@ -316,7 +316,7 @@ function stringifyElement(
             evaluated = stringifyStyle(normalizeStyle(evaluated))
           }
           res += ` ${(p.arg as SimpleExpressionNode).content}="${escapeHtml(
-            evaluated
+            evaluated,
           )}"`
         }
       } else if (p.name === 'html') {
@@ -325,7 +325,7 @@ function stringifyElement(
         innerHTML = evaluateConstant(p.exp as SimpleExpressionNode)
       } else if (p.name === 'text') {
         innerHTML = escapeHtml(
-          toDisplayString(evaluateConstant(p.exp as SimpleExpressionNode))
+          toDisplayString(evaluateConstant(p.exp as SimpleExpressionNode)),
         )
       }
     }
index d87b241609fd56e50e1241d7f0bd743b61c9ea7f..405b6da47ab9b4ccba3dd3cc4a2698236675e41e 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  NodeTransform,
+  ConstantTypes,
+  type NodeTransform,
   NodeTypes,
+  type SimpleExpressionNode,
+  type SourceLocation,
   createSimpleExpression,
-  SimpleExpressionNode,
-  SourceLocation,
-  ConstantTypes
 } from '@vue/compiler-core'
 import { parseStringStyle } from '@vue/shared'
 
@@ -25,7 +25,7 @@ export const transformStyle: NodeTransform = node => {
           arg: createSimpleExpression(`style`, true, p.loc),
           exp: parseInlineCSS(p.value.content, p.loc),
           modifiers: [],
-          loc: p.loc
+          loc: p.loc,
         }
       }
     })
@@ -34,13 +34,13 @@ export const transformStyle: NodeTransform = node => {
 
 const parseInlineCSS = (
   cssText: string,
-  loc: SourceLocation
+  loc: SourceLocation,
 ): SimpleExpressionNode => {
   const normalized = parseStringStyle(cssText)
   return createSimpleExpression(
     JSON.stringify(normalized),
     false,
     loc,
-    ConstantTypes.CAN_STRINGIFY
+    ConstantTypes.CAN_STRINGIFY,
   )
 }
index e42451a58c288205de665fcc145a177a75cddab6..d44ae508fe7a0746fa678be0089ceb78e3049a90 100644 (file)
@@ -1,20 +1,20 @@
 import {
-  DirectiveTransform,
+  type DirectiveTransform,
   createObjectProperty,
-  createSimpleExpression
+  createSimpleExpression,
 } from '@vue/compiler-core'
-import { createDOMCompilerError, DOMErrorCodes } from '../errors'
+import { DOMErrorCodes, createDOMCompilerError } from '../errors'
 
 export const transformVHtml: DirectiveTransform = (dir, node, context) => {
   const { exp, loc } = dir
   if (!exp) {
     context.onError(
-      createDOMCompilerError(DOMErrorCodes.X_V_HTML_NO_EXPRESSION, loc)
+      createDOMCompilerError(DOMErrorCodes.X_V_HTML_NO_EXPRESSION, loc),
     )
   }
   if (node.children.length) {
     context.onError(
-      createDOMCompilerError(DOMErrorCodes.X_V_HTML_WITH_CHILDREN, loc)
+      createDOMCompilerError(DOMErrorCodes.X_V_HTML_WITH_CHILDREN, loc),
     )
     node.children.length = 0
   }
@@ -22,8 +22,8 @@ export const transformVHtml: DirectiveTransform = (dir, node, context) => {
     props: [
       createObjectProperty(
         createSimpleExpression(`innerHTML`, true, loc),
-        exp || createSimpleExpression('', true)
-      )
-    ]
+        exp || createSimpleExpression('', true),
+      ),
+    ],
   }
 }
index bc1f6fcd27bf044a5a7723cd05cb64f5d81da932..5c28580b9844bc789e28f80f517978c5a0288799 100644 (file)
@@ -1,20 +1,20 @@
 import {
-  transformModel as baseTransform,
-  DirectiveTransform,
+  type DirectiveTransform,
   ElementTypes,
-  findProp,
   NodeTypes,
-  hasDynamicKeyVBind,
+  transformModel as baseTransform,
   findDir,
-  isStaticArgOf
+  findProp,
+  hasDynamicKeyVBind,
+  isStaticArgOf,
 } from '@vue/compiler-core'
-import { createDOMCompilerError, DOMErrorCodes } from '../errors'
+import { DOMErrorCodes, createDOMCompilerError } from '../errors'
 import {
   V_MODEL_CHECKBOX,
+  V_MODEL_DYNAMIC,
   V_MODEL_RADIO,
   V_MODEL_SELECT,
   V_MODEL_TEXT,
-  V_MODEL_DYNAMIC
 } from '../runtimeHelpers'
 
 export const transformModel: DirectiveTransform = (dir, node, context) => {
@@ -28,8 +28,8 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
     context.onError(
       createDOMCompilerError(
         DOMErrorCodes.X_V_MODEL_ARG_ON_ELEMENT,
-        dir.arg.loc
-      )
+        dir.arg.loc,
+      ),
     )
   }
 
@@ -39,8 +39,8 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
       context.onError(
         createDOMCompilerError(
           DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE,
-          value.loc
-        )
+          value.loc,
+        ),
       )
     }
   }
@@ -74,8 +74,8 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
               context.onError(
                 createDOMCompilerError(
                   DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT,
-                  dir.loc
-                )
+                  dir.loc,
+                ),
               )
               break
             default:
@@ -108,8 +108,8 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
     context.onError(
       createDOMCompilerError(
         DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT,
-        dir.loc
-      )
+        dir.loc,
+      ),
     )
   }
 
@@ -120,7 +120,7 @@ export const transformModel: DirectiveTransform = (dir, node, context) => {
       !(
         p.key.type === NodeTypes.SIMPLE_EXPRESSION &&
         p.key.content === 'modelValue'
-      )
+      ),
   )
 
   return baseResult
index e84bbd917e608c95d91ac63eae611ace43e8c10f..88d2c5db74113e63bb1585df5107588ca3b104f7 100644 (file)
@@ -1,21 +1,21 @@
 import {
+  CompilerDeprecationTypes,
+  type DirectiveTransform,
+  type ExpressionNode,
+  NodeTypes,
+  type SimpleExpressionNode,
+  type SourceLocation,
+  type TransformContext,
   transformOn as baseTransform,
-  DirectiveTransform,
-  createObjectProperty,
+  checkCompatEnabled,
   createCallExpression,
-  createSimpleExpression,
-  NodeTypes,
   createCompoundExpression,
-  ExpressionNode,
-  SimpleExpressionNode,
+  createObjectProperty,
+  createSimpleExpression,
   isStaticExp,
-  CompilerDeprecationTypes,
-  TransformContext,
-  SourceLocation,
-  checkCompatEnabled
 } from '@vue/compiler-core'
-import { V_ON_WITH_MODIFIERS, V_ON_WITH_KEYS } from '../runtimeHelpers'
-import { makeMap, capitalize } from '@vue/shared'
+import { V_ON_WITH_KEYS, V_ON_WITH_MODIFIERS } from '../runtimeHelpers'
+import { capitalize, makeMap } from '@vue/shared'
 
 const isEventOptionModifier = /*#__PURE__*/ makeMap(`passive,once,capture`)
 const isNonKeyModifier = /*#__PURE__*/ makeMap(
@@ -24,20 +24,20 @@ const isNonKeyModifier = /*#__PURE__*/ makeMap(
     // system modifiers + exact
     `ctrl,shift,alt,meta,exact,` +
     // mouse
-    `middle`
+    `middle`,
 )
 // left & right could be mouse or key modifiers based on event type
 const maybeKeyModifier = /*#__PURE__*/ makeMap('left,right')
 const isKeyboardEvent = /*#__PURE__*/ makeMap(
   `onkeyup,onkeydown,onkeypress`,
-  true
+  true,
 )
 
 const resolveModifiers = (
   key: ExpressionNode,
   modifiers: string[],
   context: TransformContext,
-  loc: SourceLocation
+  loc: SourceLocation,
 ) => {
   const keyModifiers = []
   const nonKeyModifiers = []
@@ -52,7 +52,7 @@ const resolveModifiers = (
       checkCompatEnabled(
         CompilerDeprecationTypes.COMPILER_V_ON_NATIVE,
         context,
-        loc
+        loc,
       )
     ) {
       eventOptionModifiers.push(modifier)
@@ -86,7 +86,7 @@ const resolveModifiers = (
   return {
     keyModifiers,
     nonKeyModifiers,
-    eventOptionModifiers
+    eventOptionModifiers,
   }
 }
 
@@ -101,7 +101,7 @@ const transformClick = (key: ExpressionNode, event: string) => {
           key,
           `) === "onClick" ? "${event}" : (`,
           key,
-          `)`
+          `)`,
         ])
       : key
 }
@@ -126,7 +126,7 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
     if (nonKeyModifiers.length) {
       handlerExp = createCallExpression(context.helper(V_ON_WITH_MODIFIERS), [
         handlerExp,
-        JSON.stringify(nonKeyModifiers)
+        JSON.stringify(nonKeyModifiers),
       ])
     }
 
@@ -137,7 +137,7 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
     ) {
       handlerExp = createCallExpression(context.helper(V_ON_WITH_KEYS), [
         handlerExp,
-        JSON.stringify(keyModifiers)
+        JSON.stringify(keyModifiers),
       ])
     }
 
@@ -149,7 +149,7 @@ export const transformOn: DirectiveTransform = (dir, node, context) => {
     }
 
     return {
-      props: [createObjectProperty(key, handlerExp)]
+      props: [createObjectProperty(key, handlerExp)],
     }
   })
 }
index 7fe76d0ba771546bfd7189024a1343254c9c3093..37c077a0c4f0965981b37bd0ef122db8398cf0e1 100644 (file)
@@ -1,17 +1,17 @@
-import { DirectiveTransform } from '@vue/compiler-core'
-import { createDOMCompilerError, DOMErrorCodes } from '../errors'
+import type { DirectiveTransform } from '@vue/compiler-core'
+import { DOMErrorCodes, createDOMCompilerError } from '../errors'
 import { V_SHOW } from '../runtimeHelpers'
 
 export const transformShow: DirectiveTransform = (dir, node, context) => {
   const { exp, loc } = dir
   if (!exp) {
     context.onError(
-      createDOMCompilerError(DOMErrorCodes.X_V_SHOW_NO_EXPRESSION, loc)
+      createDOMCompilerError(DOMErrorCodes.X_V_SHOW_NO_EXPRESSION, loc),
     )
   }
 
   return {
     props: [],
-    needRuntime: context.helper(V_SHOW)
+    needRuntime: context.helper(V_SHOW),
   }
 }
index 77bf0032b8e4a17142ba88537ae375f4808ed86e..de46e40fffc057d980cf33e6e21765b0b63be185 100644 (file)
@@ -1,23 +1,23 @@
 import {
-  DirectiveTransform,
-  createObjectProperty,
-  createSimpleExpression,
+  type DirectiveTransform,
   TO_DISPLAY_STRING,
   createCallExpression,
-  getConstantType
+  createObjectProperty,
+  createSimpleExpression,
+  getConstantType,
 } from '@vue/compiler-core'
-import { createDOMCompilerError, DOMErrorCodes } from '../errors'
+import { DOMErrorCodes, createDOMCompilerError } from '../errors'
 
 export const transformVText: DirectiveTransform = (dir, node, context) => {
   const { exp, loc } = dir
   if (!exp) {
     context.onError(
-      createDOMCompilerError(DOMErrorCodes.X_V_TEXT_NO_EXPRESSION, loc)
+      createDOMCompilerError(DOMErrorCodes.X_V_TEXT_NO_EXPRESSION, loc),
     )
   }
   if (node.children.length) {
     context.onError(
-      createDOMCompilerError(DOMErrorCodes.X_V_TEXT_WITH_CHILDREN, loc)
+      createDOMCompilerError(DOMErrorCodes.X_V_TEXT_WITH_CHILDREN, loc),
     )
     node.children.length = 0
   }
@@ -31,10 +31,10 @@ export const transformVText: DirectiveTransform = (dir, node, context) => {
             : createCallExpression(
                 context.helperString(TO_DISPLAY_STRING),
                 [exp],
-                loc
+                loc,
               )
-          : createSimpleExpression('', true)
-      )
-    ]
+          : createSimpleExpression('', true),
+      ),
+    ],
   }
 }
index 276808cf1c9e61de7266bd0b0fb710db77b543d2..f6b667f0e5ef58255fc2558ab9615e694aa09359 100644 (file)
@@ -1,5 +1,5 @@
 import { BindingTypes } from '@vue/compiler-core'
-import { compileSFCScript as compile, assertCode, mockId } from './utils'
+import { assertCode, compileSFCScript as compile, mockId } from './utils'
 
 describe('SFC compile <script setup>', () => {
   test('should compile JS syntax', () => {
@@ -34,7 +34,7 @@ describe('SFC compile <script setup>', () => {
     expect(content).toMatch(
       `return { get aa() { return aa }, set aa(v) { aa = v }, ` +
         `bb, cc, dd, get a() { return a }, set a(v) { a = v }, b, c, d, ` +
-        `get xx() { return xx }, get x() { return x } }`
+        `get xx() { return xx }, get x() { return x } }`,
     )
     expect(bindings).toStrictEqual({
       x: BindingTypes.SETUP_MAYBE_REF,
@@ -46,7 +46,7 @@ describe('SFC compile <script setup>', () => {
       aa: BindingTypes.SETUP_LET,
       bb: BindingTypes.LITERAL_CONST,
       cc: BindingTypes.SETUP_CONST,
-      dd: BindingTypes.SETUP_CONST
+      dd: BindingTypes.SETUP_CONST,
     })
     assertCode(content)
   })
@@ -63,7 +63,7 @@ describe('SFC compile <script setup>', () => {
       bar: BindingTypes.SETUP_MAYBE_REF,
       baz: BindingTypes.SETUP_MAYBE_REF,
       y: BindingTypes.SETUP_MAYBE_REF,
-      z: BindingTypes.SETUP_MAYBE_REF
+      z: BindingTypes.SETUP_MAYBE_REF,
     })
     assertCode(content)
   })
@@ -209,7 +209,7 @@ describe('SFC compile <script setup>', () => {
         compile(`<script setup>
           import { ref } from 'vue'
           import 'foo/css'
-        </script>`).content
+        </script>`).content,
       )
     })
 
@@ -220,7 +220,7 @@ describe('SFC compile <script setup>', () => {
         import a from 'a' // comment
         import b from 'b'
         </script>
-        `).content
+        `).content,
       )
     })
 
@@ -232,7 +232,7 @@ describe('SFC compile <script setup>', () => {
       defineProps(['foo'])
       defineEmits(['bar'])
       const r = ref(0)
-      </script>`).content
+      </script>`).content,
       )
     })
 
@@ -249,11 +249,11 @@ describe('SFC compile <script setup>', () => {
         color: v-bind(msg)
       }
       </style>
-      `
+      `,
       )
       assertCode(content)
       expect(content).toMatch(
-        `import { useCssVars as _useCssVars, unref as _unref } from 'vue'`
+        `import { useCssVars as _useCssVars, unref as _unref } from 'vue'`,
       )
       expect(content).toMatch(`import { useCssVars, ref } from 'vue'`)
     })
@@ -270,7 +270,7 @@ describe('SFC compile <script setup>', () => {
         `)
       assertCode(content)
       expect(content.indexOf(`import { x }`)).toEqual(
-        content.lastIndexOf(`import { x }`)
+        content.lastIndexOf(`import { x }`),
       )
     })
 
@@ -288,7 +288,7 @@ describe('SFC compile <script setup>', () => {
           ref: BindingTypes.SETUP_MAYBE_REF,
           reactive: BindingTypes.SETUP_MAYBE_REF,
           foo: BindingTypes.SETUP_MAYBE_REF,
-          bar: BindingTypes.SETUP_MAYBE_REF
+          bar: BindingTypes.SETUP_MAYBE_REF,
         })
       })
 
@@ -305,7 +305,7 @@ describe('SFC compile <script setup>', () => {
           _reactive: BindingTypes.SETUP_MAYBE_REF,
           _ref: BindingTypes.SETUP_MAYBE_REF,
           foo: BindingTypes.SETUP_MAYBE_REF,
-          bar: BindingTypes.SETUP_MAYBE_REF
+          bar: BindingTypes.SETUP_MAYBE_REF,
         })
       })
 
@@ -318,7 +318,7 @@ describe('SFC compile <script setup>', () => {
       `)
         expect(bindings).toStrictEqual({
           bar: BindingTypes.SETUP_REACTIVE_CONST,
-          x: BindingTypes.SETUP_CONST
+          x: BindingTypes.SETUP_CONST,
         })
       })
     })
@@ -334,7 +334,7 @@ describe('SFC compile <script setup>', () => {
     `)
       assertCode(content)
       expect(bindings).toStrictEqual({
-        foo: BindingTypes.SETUP_MAYBE_REF
+        foo: BindingTypes.SETUP_MAYBE_REF,
       })
     })
   })
@@ -363,7 +363,7 @@ describe('SFC compile <script setup>', () => {
       // foo: lowercase component
       expect(content).toMatch(
         `return { fooBar, get FooBaz() { return FooBaz }, ` +
-          `get FooQux() { return FooQux }, get foo() { return foo } }`
+          `get FooQux() { return FooQux }, get foo() { return foo } }`,
       )
       assertCode(content)
     })
@@ -396,7 +396,7 @@ describe('SFC compile <script setup>', () => {
         `)
       expect(content).toMatch(
         `return { get FooBar() { return FooBar }, get foo() { return foo }, ` +
-          `get bar() { return bar }, get baz() { return baz } }`
+          `get bar() { return bar }, get baz() { return baz } }`,
       )
       assertCode(content)
     })
@@ -413,7 +413,7 @@ describe('SFC compile <script setup>', () => {
         </template>
         `)
       expect(content).toMatch(
-        `return { cond, get bar() { return bar }, get baz() { return baz } }`
+        `return { cond, get bar() { return bar }, get baz() { return baz } }`,
       )
       assertCode(content)
     })
@@ -431,7 +431,7 @@ describe('SFC compile <script setup>', () => {
       // y: should not be matched by {{ yy }} or 'y' in binding exps
       // x$y: #4274 should escape special chars when creating Regex
       expect(content).toMatch(
-        `return { get x() { return x }, get z() { return z }, get x$y() { return x$y } }`
+        `return { get x() { return x }, get z() { return z }, get x$y() { return x$y } }`,
       )
       assertCode(content)
     })
@@ -448,7 +448,7 @@ describe('SFC compile <script setup>', () => {
         `)
       // VAR2 should not be matched
       expect(content).toMatch(
-        `return { get VAR() { return VAR }, get VAR3() { return VAR3 } }`
+        `return { get VAR() { return VAR }, get VAR3() { return VAR3 } }`,
       )
       assertCode(content)
     })
@@ -465,7 +465,7 @@ describe('SFC compile <script setup>', () => {
         </template>
         `)
       expect(content).toMatch(
-        `return { get FooBaz() { return FooBaz }, get Last() { return Last } }`
+        `return { get FooBaz() { return FooBaz }, get Last() { return Last } }`,
       )
       assertCode(content)
     })
@@ -514,7 +514,7 @@ describe('SFC compile <script setup>', () => {
         </template>
         `)
       expect(content).toMatch(
-        'return { get foo() { return foo }, get bar() { return bar }, get Baz() { return Baz } }'
+        'return { get foo() { return foo }, get bar() { return bar }, get Baz() { return Baz } }',
       )
       assertCode(content)
     })
@@ -573,7 +573,7 @@ describe('SFC compile <script setup>', () => {
           <div>static</div>
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       // check snapshot and make sure helper imports and
       // hoists are placed correctly.
@@ -591,7 +591,7 @@ describe('SFC compile <script setup>', () => {
         defineExpose({ count })
         </script>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       assertCode(content)
       expect(content).toMatch(`setup(__props, { expose: __expose })`)
@@ -612,7 +612,7 @@ describe('SFC compile <script setup>', () => {
           <some-other-comp/>
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       expect(content).toMatch('[_unref(vMyDir)]')
       expect(content).toMatch('_createVNode(ChildComp)')
@@ -641,7 +641,7 @@ describe('SFC compile <script setup>', () => {
           {{ tree.foo() }}
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       // no need to unref vue component import
       expect(content).toMatch(`createVNode(Foo,`)
@@ -680,7 +680,7 @@ describe('SFC compile <script setup>', () => {
           <input v-model="lett">
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       // known const ref: set value
       expect(content).toMatch(`(count).value = $event`)
@@ -688,7 +688,7 @@ describe('SFC compile <script setup>', () => {
       expect(content).toMatch(`_isRef(maybe) ? (maybe).value = $event : null`)
       // let: handle both cases
       expect(content).toMatch(
-        `_isRef(lett) ? (lett).value = $event : lett = $event`
+        `_isRef(lett) ? (lett).value = $event : lett = $event`,
       )
       assertCode(content)
     })
@@ -708,7 +708,7 @@ describe('SFC compile <script setup>', () => {
           <input v-model="foo">
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       expect(content).not.toMatch(`_isRef(foo)`)
     })
@@ -746,7 +746,7 @@ describe('SFC compile <script setup>', () => {
            }"/>
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       // known const ref: set value
       expect(content).toMatch(`count.value = 1`)
@@ -754,7 +754,7 @@ describe('SFC compile <script setup>', () => {
       expect(content).toMatch(`maybe.value = count.value`)
       // let: handle both cases
       expect(content).toMatch(
-        `_isRef(lett) ? lett.value = count.value : lett = count.value`
+        `_isRef(lett) ? lett.value = count.value : lett = count.value`,
       )
       expect(content).toMatch(`_isRef(v) ? v.value += 1 : v += 1`)
       expect(content).toMatch(`_isRef(v) ? v.value -= 1 : v -= 1`)
@@ -780,7 +780,7 @@ describe('SFC compile <script setup>', () => {
           <div @click="--lett"/>
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       // known const ref: set value
       expect(content).toMatch(`count.value++`)
@@ -809,7 +809,7 @@ describe('SFC compile <script setup>', () => {
           <div @click="({ lett } = val)"/>
         </template>
         `,
-        { inlineTemplate: true }
+        { inlineTemplate: true },
       )
       // known const ref: set value
       expect(content).toMatch(`({ count: count.value } = val)`)
@@ -840,9 +840,9 @@ describe('SFC compile <script setup>', () => {
         {
           inlineTemplate: true,
           templateOptions: {
-            ssr: true
-          }
-        }
+            ssr: true,
+          },
+        },
       )
       expect(content).toMatch(`\n  __ssrInlineRender: true,\n`)
       expect(content).toMatch(`return (_ctx, _push`)
@@ -866,9 +866,9 @@ describe('SFC compile <script setup>', () => {
         </template>
         `,
           {
-            inlineTemplate: false
-          }
-        )
+            inlineTemplate: false,
+          },
+        ),
       ).not.toThrowError()
     })
   })
@@ -887,11 +887,11 @@ describe('SFC compile <script setup>', () => {
       const { content, bindings } = compile(
         `<script setup lang="ts">
         enum Foo { A = 123 }
-        </script>`
+        </script>`,
       )
       assertCode(content)
       expect(bindings).toStrictEqual({
-        Foo: BindingTypes.LITERAL_CONST
+        Foo: BindingTypes.LITERAL_CONST,
       })
     })
 
@@ -904,14 +904,14 @@ describe('SFC compile <script setup>', () => {
         </script>
         <script setup lang="ts">
         enum Foo { A = 123 }
-        </script>`
+        </script>`,
       )
       assertCode(content)
       expect(bindings).toStrictEqual({
         D: BindingTypes.LITERAL_CONST,
         C: BindingTypes.LITERAL_CONST,
         B: BindingTypes.LITERAL_CONST,
-        Foo: BindingTypes.LITERAL_CONST
+        Foo: BindingTypes.LITERAL_CONST,
       })
     })
 
@@ -920,11 +920,11 @@ describe('SFC compile <script setup>', () => {
         `<script setup lang="ts">
         const enum Foo { A = 123 }
         </script>`,
-        { hoistStatic: true }
+        { hoistStatic: true },
       )
       assertCode(content)
       expect(bindings).toStrictEqual({
-        Foo: BindingTypes.LITERAL_CONST
+        Foo: BindingTypes.LITERAL_CONST,
       })
     })
 
@@ -933,7 +933,7 @@ describe('SFC compile <script setup>', () => {
         `<script setup lang="ts">
         import type { Foo } from './main.ts'
         import { type Bar, Baz } from './main.ts'
-        </script>`
+        </script>`,
       )
       expect(content).toMatch(`return { get Baz() { return Baz } }`)
       assertCode(content)
@@ -1057,7 +1057,7 @@ describe('SFC compile <script setup>', () => {
       // class method
       assertAwaitDetection(
         `const cls = class Foo { async method() { await bar }}`,
-        false
+        false,
       )
     })
   })
@@ -1065,7 +1065,7 @@ describe('SFC compile <script setup>', () => {
   describe('errors', () => {
     test('<script> and <script setup> must have same lang', () => {
       expect(() =>
-        compile(`<script>foo()</script><script setup lang="ts">bar()</script>`)
+        compile(`<script>foo()</script><script setup lang="ts">bar()</script>`),
       ).toThrow(`<script> and <script setup> must have the same language type`)
     })
 
@@ -1075,20 +1075,20 @@ describe('SFC compile <script setup>', () => {
       expect(() =>
         compile(`<script setup>
         export const a = 1
-        </script>`)
+        </script>`),
       ).toThrow(moduleErrorMsg)
 
       expect(() =>
         compile(`<script setup>
         export * from './foo'
-        </script>`)
+        </script>`),
       ).toThrow(moduleErrorMsg)
 
       expect(() =>
         compile(`<script setup>
           const bar = 1
           export { bar as default }
-        </script>`)
+        </script>`),
       ).toThrow(moduleErrorMsg)
     })
 
@@ -1101,14 +1101,14 @@ describe('SFC compile <script setup>', () => {
             default: () => bar
           }
         })
-        </script>`)
+        </script>`),
       ).toThrow(`cannot reference locally declared variables`)
 
       expect(() =>
         compile(`<script setup>
         let bar = 'hello'
         defineEmits([bar])
-        </script>`)
+        </script>`),
       ).toThrow(`cannot reference locally declared variables`)
 
       // #4644
@@ -1121,7 +1121,7 @@ describe('SFC compile <script setup>', () => {
             default: () => bar
           }
         })
-        </script>`)
+        </script>`),
       ).not.toThrow(`cannot reference locally declared variables`)
     })
 
@@ -1137,7 +1137,7 @@ describe('SFC compile <script setup>', () => {
           defineEmits({
             foo: bar => bar > 1
           })
-        </script>`).content
+        </script>`).content,
       )
     })
 
@@ -1153,7 +1153,7 @@ describe('SFC compile <script setup>', () => {
         defineEmits({
           foo: () => bar > 1
         })
-        </script>`).content
+        </script>`).content,
       )
     })
   })
@@ -1187,7 +1187,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
-      bar: BindingTypes.PROPS
+      bar: BindingTypes.PROPS,
     })
     expect(bindings!.__isScriptSetup).toBe(false)
   })
@@ -1211,7 +1211,7 @@ describe('SFC analyze <script> bindings', () => {
       foo: BindingTypes.PROPS,
       bar: BindingTypes.PROPS,
       baz: BindingTypes.PROPS,
-      qux: BindingTypes.PROPS
+      qux: BindingTypes.PROPS,
     })
     expect(bindings!.__isScriptSetup).toBe(false)
   })
@@ -1232,7 +1232,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.SETUP_MAYBE_REF,
-      bar: BindingTypes.SETUP_MAYBE_REF
+      bar: BindingTypes.SETUP_MAYBE_REF,
     })
     expect(bindings!.__isScriptSetup).toBe(false)
   })
@@ -1247,7 +1247,7 @@ describe('SFC analyze <script> bindings', () => {
       </script>
     `)
     expect(bindings).toStrictEqual({
-      foo: BindingTypes.LITERAL_CONST
+      foo: BindingTypes.LITERAL_CONST,
     })
   })
 
@@ -1267,7 +1267,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.SETUP_MAYBE_REF,
-      bar: BindingTypes.SETUP_MAYBE_REF
+      bar: BindingTypes.SETUP_MAYBE_REF,
     })
     expect(bindings!.__isScriptSetup).toBe(false)
   })
@@ -1288,7 +1288,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.DATA,
-      bar: BindingTypes.DATA
+      bar: BindingTypes.DATA,
     })
   })
 
@@ -1321,7 +1321,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.OPTIONS,
-      bar: BindingTypes.OPTIONS
+      bar: BindingTypes.OPTIONS,
     })
   })
 
@@ -1335,7 +1335,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.OPTIONS,
-      bar: BindingTypes.OPTIONS
+      bar: BindingTypes.OPTIONS,
     })
   })
 
@@ -1352,7 +1352,7 @@ describe('SFC analyze <script> bindings', () => {
     `)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.OPTIONS,
-      bar: BindingTypes.OPTIONS
+      bar: BindingTypes.OPTIONS,
     })
   })
 
@@ -1389,7 +1389,7 @@ describe('SFC analyze <script> bindings', () => {
       baz: BindingTypes.SETUP_MAYBE_REF,
       qux: BindingTypes.DATA,
       quux: BindingTypes.OPTIONS,
-      quuz: BindingTypes.OPTIONS
+      quuz: BindingTypes.OPTIONS,
     })
   })
 
@@ -1416,7 +1416,7 @@ describe('SFC analyze <script> bindings', () => {
       c: BindingTypes.LITERAL_CONST,
       d: BindingTypes.SETUP_MAYBE_REF,
       e: BindingTypes.SETUP_LET,
-      foo: BindingTypes.PROPS
+      foo: BindingTypes.PROPS,
     })
   })
 
@@ -1427,8 +1427,8 @@ describe('SFC analyze <script> bindings', () => {
         <template>{{ a }}</template>`,
         undefined,
         {
-          filename: 'FooBar.vue'
-        }
+          filename: 'FooBar.vue',
+        },
       )
       expect(content).toMatch(`export default {
   __name: 'FooBar'`)
@@ -1446,8 +1446,8 @@ describe('SFC analyze <script> bindings', () => {
         <template>{{ a }}</template>`,
         undefined,
         {
-          filename: 'FooBar.vue'
-        }
+          filename: 'FooBar.vue',
+        },
       )
       expect(content).not.toMatch(`name: 'FooBar'`)
       expect(content).toMatch(`name: 'Baz'`)
@@ -1466,8 +1466,8 @@ describe('SFC analyze <script> bindings', () => {
         <template>{{ a }}</template>`,
         undefined,
         {
-          filename: 'FooBar.vue'
-        }
+          filename: 'FooBar.vue',
+        },
       )
       expect(content).not.toMatch(`name: 'FooBar'`)
       expect(content).toMatch(`name: 'Baz'`)
@@ -1483,8 +1483,8 @@ describe('SFC genDefaultAs', () => {
       export default {}
       </script>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).toMatch(`const _sfc_ = {}`)
@@ -1500,8 +1500,8 @@ describe('SFC genDefaultAs', () => {
       .foo { color: v-bind(x) }
       </style>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).not.toMatch('__default__')
@@ -1518,12 +1518,12 @@ describe('SFC genDefaultAs', () => {
       const a = 1
       </script>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).toMatch(
-      `const _sfc_ = /*#__PURE__*/Object.assign(__default__`
+      `const _sfc_ = /*#__PURE__*/Object.assign(__default__`,
     )
     assertCode(content)
   })
@@ -1537,12 +1537,12 @@ describe('SFC genDefaultAs', () => {
       const a = 1
       </script>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).toMatch(
-      `const _sfc_ = /*#__PURE__*/Object.assign(__default__`
+      `const _sfc_ = /*#__PURE__*/Object.assign(__default__`,
     )
     assertCode(content)
   })
@@ -1553,8 +1553,8 @@ describe('SFC genDefaultAs', () => {
       const a = 1
       </script>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).toMatch(`const _sfc_ = {\n  setup`)
@@ -1567,8 +1567,8 @@ describe('SFC genDefaultAs', () => {
       const a = 1
       </script>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).toMatch(`const _sfc_ = /*#__PURE__*/_defineComponent(`)
@@ -1584,12 +1584,12 @@ describe('SFC genDefaultAs', () => {
       const a = 1
       </script>`,
       {
-        genDefaultAs: '_sfc_'
-      }
+        genDefaultAs: '_sfc_',
+      },
     )
     expect(content).not.toMatch('export default')
     expect(content).toMatch(
-      `const _sfc_ = /*#__PURE__*/_defineComponent({\n  ...__default__`
+      `const _sfc_ = /*#__PURE__*/_defineComponent({\n  ...__default__`,
     )
     assertCode(content)
   })
@@ -1600,12 +1600,12 @@ describe('SFC genDefaultAs', () => {
       import { toRef } from 'vue'
       const props = defineProps<{foo: string}>()
       const foo = toRef(() => props.foo)
-      </script>`
+      </script>`,
     )
     expect(bindings).toStrictEqual({
       toRef: BindingTypes.SETUP_CONST,
       props: BindingTypes.SETUP_REACTIVE_CONST,
-      foo: BindingTypes.SETUP_REF
+      foo: BindingTypes.SETUP_REF,
     })
   })
 
@@ -1622,7 +1622,7 @@ describe('SFC genDefaultAs', () => {
         compile(`
       <script setup>
         import { foo } from './foo.js' assert { type: 'foobar' }
-        </script>`)
+        </script>`),
       ).toThrow()
     })
 
@@ -1635,9 +1635,9 @@ describe('SFC genDefaultAs', () => {
       `,
         {
           babelParserPlugins: [
-            ['importAttributes', { deprecatedAssertSyntax: true }]
-          ]
-        }
+            ['importAttributes', { deprecatedAssertSyntax: true }],
+          ],
+        },
       )
       assertCode(content)
     })
index 0d1a41e0f2b28dab48c61906df2f6973b345e3fc..55bc421627211aa22caf53a6588a0fda3634097a 100644 (file)
@@ -1,5 +1,5 @@
 import { BindingTypes } from '@vue/compiler-core'
-import { compileSFCScript as compile, assertCode } from '../utils'
+import { assertCode, compileSFCScript as compile } from '../utils'
 
 describe('defineEmits', () => {
   test('basic usage', () => {
@@ -10,13 +10,13 @@ const myEmit = defineEmits(['foo', 'bar'])
   `)
     assertCode(content)
     expect(bindings).toStrictEqual({
-      myEmit: BindingTypes.SETUP_CONST
+      myEmit: BindingTypes.SETUP_CONST,
     })
     // should remove defineEmits import and call
     expect(content).not.toMatch('defineEmits')
     // should generate correct setup signature
     expect(content).toMatch(
-      `setup(__props, { expose: __expose, emit: __emit }) {`
+      `setup(__props, { expose: __expose, emit: __emit }) {`,
     )
     expect(content).toMatch('const myEmit = __emit')
     // should include context options in default export
@@ -226,9 +226,9 @@ const emit = defineEmits(['a', 'b'])
           foo: []
           (e: 'hi'): void
         }>()
-        </script>`)
+        </script>`),
       ).toThrow(
-        `defineEmits() type cannot mixed call signature and property syntax.`
+        `defineEmits() type cannot mixed call signature and property syntax.`,
       )
     })
   })
index 8ddd28a89e606c211c85899eec9bb12413faf18d..7b2a9f7cbe4c845963f86524bbebc65698b606ca 100644 (file)
@@ -1,4 +1,4 @@
-import { compileSFCScript as compile, assertCode } from '../utils'
+import { assertCode, compileSFCScript as compile } from '../utils'
 
 test('defineExpose()', () => {
   const { content } = compile(`
index 45e5be895dd22768e09a278a6a099bba3ef6b9cf..eea19fc9cbd47d7d9f6296620a8d17113938342d 100644 (file)
@@ -1,5 +1,5 @@
 import { BindingTypes } from '@vue/compiler-core'
-import { compileSFCScript as compile, assertCode } from '../utils'
+import { assertCode, compileSFCScript as compile } from '../utils'
 
 describe('defineModel()', () => {
   test('basic usage', () => {
@@ -10,7 +10,7 @@ describe('defineModel()', () => {
       const c = defineModel('count')
       const toString = defineModel('toString', { type: Function })
       </script>
-      `
+      `,
     )
     assertCode(content)
     expect(content).toMatch('props: {')
@@ -18,10 +18,10 @@ describe('defineModel()', () => {
     expect(content).toMatch('"count": {},')
     expect(content).toMatch('"toString": { type: Function },')
     expect(content).toMatch(
-      'emits: ["update:modelValue", "update:count", "update:toString"],'
+      'emits: ["update:modelValue", "update:count", "update:toString"],',
     )
     expect(content).toMatch(
-      `const modelValue = _useModel(__props, "modelValue")`
+      `const modelValue = _useModel(__props, "modelValue")`,
     )
     expect(content).toMatch(`const c = _useModel(__props, "count")`)
     expect(content).toMatch(`return { modelValue, c, toString }`)
@@ -31,7 +31,7 @@ describe('defineModel()', () => {
       modelValue: BindingTypes.SETUP_REF,
       count: BindingTypes.PROPS,
       c: BindingTypes.SETUP_REF,
-      toString: BindingTypes.SETUP_REF
+      toString: BindingTypes.SETUP_REF,
     })
   })
 
@@ -43,7 +43,7 @@ describe('defineModel()', () => {
       defineEmits(['change'])
       const count = defineModel({ default: 0 })
       </script>
-    `
+    `,
     )
     assertCode(content)
     expect(content).toMatch(`props: /*#__PURE__*/_mergeModels({ foo: String }`)
@@ -53,7 +53,7 @@ describe('defineModel()', () => {
     expect(bindings).toStrictEqual({
       count: BindingTypes.SETUP_REF,
       foo: BindingTypes.PROPS,
-      modelValue: BindingTypes.PROPS
+      modelValue: BindingTypes.PROPS,
     })
   })
 
@@ -64,7 +64,7 @@ describe('defineModel()', () => {
       defineProps(['foo', 'bar'])
       const count = defineModel('count')
       </script>
-    `
+    `,
     )
     assertCode(content)
     expect(content).toMatch(`props: /*#__PURE__*/_mergeModels(['foo', 'bar'], {
@@ -75,7 +75,7 @@ describe('defineModel()', () => {
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
       bar: BindingTypes.PROPS,
-      count: BindingTypes.SETUP_REF
+      count: BindingTypes.SETUP_REF,
     })
   })
 
@@ -91,7 +91,7 @@ describe('defineModel()', () => {
 
       const local = true
       const hoist = defineModel('hoist', { local })
-      </script>`
+      </script>`,
     )
     assertCode(content)
     expect(content).toMatch(`_useModel(__props, "modelValue", { local: true })`)
@@ -111,21 +111,21 @@ describe('defineModel()', () => {
       const disabled = defineModel<number>('disabled', { required: false })
       const any = defineModel<any | boolean>('any')
       </script>
-      `
+      `,
     )
     assertCode(content)
     expect(content).toMatch('"modelValue": { type: [Boolean, String] }')
     expect(content).toMatch('"count": { type: Number }')
     expect(content).toMatch(
-      '"disabled": { type: Number, ...{ required: false } }'
+      '"disabled": { type: Number, ...{ required: false } }',
     )
     expect(content).toMatch('"any": { type: Boolean, skipCheck: true }')
     expect(content).toMatch(
-      'emits: ["update:modelValue", "update:count", "update:disabled", "update:any"]'
+      'emits: ["update:modelValue", "update:count", "update:disabled", "update:any"]',
     )
 
     expect(content).toMatch(
-      `const modelValue = _useModel(__props, "modelValue")`
+      `const modelValue = _useModel(__props, "modelValue")`,
     )
     expect(content).toMatch(`const count = _useModel(__props, "count")`)
     expect(content).toMatch(`const disabled = _useModel(__props, "disabled")`)
@@ -135,7 +135,7 @@ describe('defineModel()', () => {
       modelValue: BindingTypes.SETUP_REF,
       count: BindingTypes.SETUP_REF,
       disabled: BindingTypes.SETUP_REF,
-      any: BindingTypes.SETUP_REF
+      any: BindingTypes.SETUP_REF,
     })
   })
 
@@ -150,21 +150,21 @@ describe('defineModel()', () => {
       const optional = defineModel<string>('optional', { required: false })
       </script>
       `,
-      { isProd: true }
+      { isProd: true },
     )
     assertCode(content)
     expect(content).toMatch('"modelValue": { type: Boolean }')
     expect(content).toMatch('"fn": {}')
     expect(content).toMatch(
-      '"fnWithDefault": { type: Function, ...{ default: () => null } },'
+      '"fnWithDefault": { type: Function, ...{ default: () => null } },',
     )
     expect(content).toMatch('"str": {}')
     expect(content).toMatch('"optional": { required: false }')
     expect(content).toMatch(
-      'emits: ["update:modelValue", "update:fn", "update:fnWithDefault", "update:str", "update:optional"]'
+      'emits: ["update:modelValue", "update:fn", "update:fnWithDefault", "update:str", "update:optional"]',
     )
     expect(content).toMatch(
-      `const modelValue = _useModel(__props, "modelValue")`
+      `const modelValue = _useModel(__props, "modelValue")`,
     )
     expect(content).toMatch(`const fn = _useModel(__props, "fn")`)
     expect(content).toMatch(`const str = _useModel(__props, "str")`)
@@ -173,7 +173,7 @@ describe('defineModel()', () => {
       fn: BindingTypes.SETUP_REF,
       fnWithDefault: BindingTypes.SETUP_REF,
       str: BindingTypes.SETUP_REF,
-      optional: BindingTypes.SETUP_REF
+      optional: BindingTypes.SETUP_REF,
     })
   })
 })
index e4f50be38f7a21d6a91b5243316671f80e69a1be..dac9ef6418818ab549982531c3c76cf7764e5b04 100644 (file)
@@ -1,4 +1,4 @@
-import { compileSFCScript as compile, assertCode } from '../utils'
+import { assertCode, compileSFCScript as compile } from '../utils'
 
 describe('defineOptions()', () => {
   test('basic usage', () => {
@@ -12,7 +12,7 @@ describe('defineOptions()', () => {
     expect(content).not.toMatch('defineOptions')
     // should include context options in default export
     expect(content).toMatch(
-      `export default /*#__PURE__*/Object.assign({ name: 'FooApp' }, `
+      `export default /*#__PURE__*/Object.assign({ name: 'FooApp' }, `,
     )
   })
 
@@ -35,7 +35,7 @@ describe('defineOptions()', () => {
       defineOptions({ name: 'FooApp' })
       defineOptions({ name: 'BarApp' })
       </script>
-      `)
+      `),
     ).toThrowError('[@vue/compiler-sfc] duplicate defineOptions() call')
   })
 
@@ -45,9 +45,9 @@ describe('defineOptions()', () => {
       <script setup>
       defineOptions({ props: { foo: String } })
       </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead.'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead.',
     )
 
     expect(() =>
@@ -55,9 +55,9 @@ describe('defineOptions()', () => {
       <script setup>
       defineOptions({ emits: ['update'] })
       </script>
-    `)
+    `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead.'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead.',
     )
 
     expect(() =>
@@ -65,9 +65,9 @@ describe('defineOptions()', () => {
       <script setup>
       defineOptions({ expose: ['foo'] })
       </script>
-    `)
+    `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead.'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead.',
     )
 
     expect(() =>
@@ -75,9 +75,9 @@ describe('defineOptions()', () => {
       <script setup>
       defineOptions({ slots: ['foo'] })
       </script>
-    `)
+    `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead.'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead.',
     )
   })
 
@@ -87,9 +87,9 @@ describe('defineOptions()', () => {
       <script setup lang="ts">
       defineOptions<{ name: 'FooApp' }>()
       </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot accept type arguments'
+      '[@vue/compiler-sfc] defineOptions() cannot accept type arguments',
     )
   })
 
@@ -99,9 +99,9 @@ describe('defineOptions()', () => {
       <script setup lang="ts">
       defineOptions({ props: [] } as any)
       </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead.'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead.',
     )
   })
 
@@ -111,9 +111,9 @@ describe('defineOptions()', () => {
         <script setup>
         defineOptions({ props: ['foo'] })
         </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare props. Use defineProps() instead',
     )
 
     expect(() =>
@@ -121,9 +121,9 @@ describe('defineOptions()', () => {
         <script setup>
         defineOptions({ emits: ['update'] })
         </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare emits. Use defineEmits() instead',
     )
 
     expect(() =>
@@ -131,9 +131,9 @@ describe('defineOptions()', () => {
         <script setup>
         defineOptions({ expose: ['foo'] })
         </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare expose. Use defineExpose() instead',
     )
 
     expect(() =>
@@ -141,9 +141,9 @@ describe('defineOptions()', () => {
         <script setup lang="ts">
         defineOptions({ slots: Object })
         </script>
-      `)
+      `),
     ).toThrowError(
-      '[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead'
+      '[@vue/compiler-sfc] defineOptions() cannot be used to declare slots. Use defineSlots() instead',
     )
   })
 })
index 7d46c4d2187de8870e9a4041919d670c721fa37e..c139a3d7b735ba379715ee5e553b92b06e3f9341 100644 (file)
@@ -1,5 +1,5 @@
 import { BindingTypes } from '@vue/compiler-core'
-import { compileSFCScript as compile, assertCode } from '../utils'
+import { assertCode, compileSFCScript as compile } from '../utils'
 
 describe('defineProps', () => {
   test('basic usage', () => {
@@ -17,7 +17,7 @@ const bar = 1
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
       bar: BindingTypes.LITERAL_CONST,
-      props: BindingTypes.SETUP_REACTIVE_CONST
+      props: BindingTypes.SETUP_REACTIVE_CONST,
     })
 
     // should remove defineOptions import and call
@@ -146,11 +146,11 @@ const props = defineProps({ foo: String })
     expect(content).toMatch(`symbol: { type: Symbol, required: true }`)
     expect(content).toMatch(`error: { type: Error, required: true }`)
     expect(content).toMatch(
-      `objectOrFn: { type: [Function, Object], required: true },`
+      `objectOrFn: { type: [Function, Object], required: true },`,
     )
     expect(content).toMatch(`extract: { type: Number, required: true }`)
     expect(content).toMatch(
-      `exclude: { type: [Number, Boolean], required: true }`
+      `exclude: { type: [Number, Boolean], required: true }`,
     )
     expect(content).toMatch(`uppercase: { type: String, required: true }`)
     expect(content).toMatch(`params: { type: Array, required: true }`)
@@ -158,10 +158,10 @@ const props = defineProps({ foo: String })
     expect(content).toMatch(`union: { type: [String, Number], required: true }`)
     expect(content).toMatch(`literalUnion: { type: String, required: true }`)
     expect(content).toMatch(
-      `literalUnionNumber: { type: Number, required: true }`
+      `literalUnionNumber: { type: Number, required: true }`,
     )
     expect(content).toMatch(
-      `literalUnionMixed: { type: [String, Number, Boolean], required: true }`
+      `literalUnionMixed: { type: [String, Number, Boolean], required: true }`,
     )
     expect(content).toMatch(`intersection: { type: Object, required: true }`)
     expect(content).toMatch(`intersection2: { type: String, required: true }`)
@@ -171,13 +171,13 @@ const props = defineProps({ foo: String })
     expect(content).toMatch(`unknownUnion: { type: null, required: true }`)
     // intersection containing unknown type: narrow to the known types
     expect(content).toMatch(
-      `unknownIntersection: { type: Object, required: true },`
+      `unknownIntersection: { type: Object, required: true },`,
     )
     expect(content).toMatch(
-      `unknownUnionWithBoolean: { type: Boolean, required: true, skipCheck: true },`
+      `unknownUnionWithBoolean: { type: Boolean, required: true, skipCheck: true },`,
     )
     expect(content).toMatch(
-      `unknownUnionWithFunction: { type: Function, required: true, skipCheck: true }`
+      `unknownUnionWithFunction: { type: Function, required: true, skipCheck: true }`,
     )
     expect(bindings).toStrictEqual({
       string: BindingTypes.PROPS,
@@ -218,7 +218,7 @@ const props = defineProps({ foo: String })
       unknownUnion: BindingTypes.PROPS,
       unknownIntersection: BindingTypes.PROPS,
       unknownUnionWithBoolean: BindingTypes.PROPS,
-      unknownUnionWithFunction: BindingTypes.PROPS
+      unknownUnionWithFunction: BindingTypes.PROPS,
     })
   })
 
@@ -232,7 +232,7 @@ const props = defineProps({ foo: String })
     assertCode(content)
     expect(content).toMatch(`x: { type: Number, required: false }`)
     expect(bindings).toStrictEqual({
-      x: BindingTypes.PROPS
+      x: BindingTypes.PROPS,
     })
   })
 
@@ -257,7 +257,7 @@ const props = defineProps({ foo: String })
     expect(bindings).toStrictEqual({
       x: BindingTypes.PROPS,
       y: BindingTypes.PROPS,
-      z: BindingTypes.PROPS
+      z: BindingTypes.PROPS,
     })
   })
 
@@ -271,7 +271,7 @@ const props = defineProps({ foo: String })
     assertCode(content)
     expect(content).toMatch(`x: { type: Number, required: false }`)
     expect(bindings).toStrictEqual({
-      x: BindingTypes.PROPS
+      x: BindingTypes.PROPS,
     })
   })
 
@@ -287,7 +287,7 @@ const props = defineProps({ foo: String })
     assertCode(content)
     expect(content).toMatch(`x: { type: Number, required: false }`)
     expect(bindings).toStrictEqual({
-      x: BindingTypes.PROPS
+      x: BindingTypes.PROPS,
     })
   })
 
@@ -301,7 +301,7 @@ const props = defineProps({ foo: String })
     assertCode(content)
     expect(content).toMatch(`x: { type: Number, required: false }`)
     expect(bindings).toStrictEqual({
-      x: BindingTypes.PROPS
+      x: BindingTypes.PROPS,
     })
   })
 
@@ -315,7 +315,7 @@ const props = defineProps({ foo: String })
     assertCode(content)
     expect(content).toMatch(`x: { type: Number, required: false }`)
     expect(bindings).toStrictEqual({
-      x: BindingTypes.PROPS
+      x: BindingTypes.PROPS,
     })
   })
 
@@ -328,7 +328,7 @@ const props = defineProps({ foo: String })
     expect(content).toMatch(`props: ['foo']`)
     assertCode(content)
     expect(bindings).toStrictEqual({
-      foo: BindingTypes.PROPS
+      foo: BindingTypes.PROPS,
     })
   })
 
@@ -354,21 +354,21 @@ const props = defineProps({ foo: String })
     `)
     assertCode(content)
     expect(content).toMatch(
-      `foo: { type: String, required: false, default: 'hi' }`
+      `foo: { type: String, required: false, default: 'hi' }`,
     )
     expect(content).toMatch(`bar: { type: Number, required: false }`)
     expect(content).toMatch(`baz: { type: Boolean, required: true }`)
     expect(content).toMatch(
-      `qux: { type: Function, required: false, default() { return 1 } }`
+      `qux: { type: Function, required: false, default() { return 1 } }`,
     )
     expect(content).toMatch(
-      `quux: { type: Function, required: false, default() { } }`
+      `quux: { type: Function, required: false, default() { } }`,
     )
     expect(content).toMatch(
-      `quuxx: { type: Promise, required: false, async default() { return await Promise.resolve('hi') } }`
+      `quuxx: { type: Promise, required: false, async default() { return await Promise.resolve('hi') } }`,
     )
     expect(content).toMatch(
-      `fred: { type: String, required: false, get default() { return 'fred' } }`
+      `fred: { type: String, required: false, get default() { return 'fred' } }`,
     )
     expect(content).toMatch(`const props = __props`)
     expect(bindings).toStrictEqual({
@@ -379,7 +379,7 @@ const props = defineProps({ foo: String })
       quux: BindingTypes.PROPS,
       quuxx: BindingTypes.PROPS,
       fred: BindingTypes.PROPS,
-      props: BindingTypes.SETUP_CONST
+      props: BindingTypes.SETUP_CONST,
     })
   })
 
@@ -415,7 +415,7 @@ const props = defineProps({ foo: String })
     })
     </script>
     `,
-      { isProd: true }
+      { isProd: true },
     )
     assertCode(content)
     expect(content).toMatch(`const props = __props`)
@@ -446,7 +446,7 @@ const props = defineProps({ foo: String })
     foo: { type: String, required: false },
     bar: { type: Number, required: false },
     baz: { type: Boolean, required: true }
-  }, { ...defaults })`.trim()
+  }, { ...defaults })`.trim(),
     )
   })
 
@@ -469,7 +469,7 @@ const props = defineProps({ foo: String })
     foo: { type: String, required: false },
     bar: { type: Number, required: false },
     baz: { type: Boolean, required: true }
-  }, defaults)`.trim()
+  }, defaults)`.trim(),
     )
   })
 
@@ -487,7 +487,7 @@ const props = defineProps({ foo: String })
     }>(), { ...defaults })
     </script>
     `,
-      { isProd: true }
+      { isProd: true },
     )
     assertCode(content)
     expect(content).toMatch(`import { mergeDefaults as _mergeDefaults`)
@@ -498,7 +498,7 @@ const props = defineProps({ foo: String })
     bar: { type: Boolean },
     baz: { type: [Boolean, Function] },
     qux: {}
-  }, { ...defaults })`.trim()
+  }, { ...defaults })`.trim(),
     )
   })
 
@@ -520,7 +520,7 @@ const props = defineProps({ foo: String })
     foo: { type: Function, required: false }
   }, {
       ['fo' + 'o']() { return 'foo' }
-    })`.trim()
+    })`.trim(),
     )
   })
 
@@ -533,8 +533,8 @@ const props = defineProps({ foo: String })
         foo: Foo
       }>()
       </script>`,
-        { hoistStatic: true }
-      ).content
+        { hoistStatic: true },
+      ).content,
     ).toMatch(`foo: { type: Number`)
 
     expect(
@@ -545,8 +545,8 @@ const props = defineProps({ foo: String })
         foo: Foo
       }>()
       </script>`,
-        { hoistStatic: true }
-      ).content
+        { hoistStatic: true },
+      ).content,
     ).toMatch(`foo: { type: String`)
 
     expect(
@@ -557,8 +557,8 @@ const props = defineProps({ foo: String })
         foo: Foo
       }>()
       </script>`,
-        { hoistStatic: true }
-      ).content
+        { hoistStatic: true },
+      ).content,
     ).toMatch(`foo: { type: [String, Number]`)
 
     expect(
@@ -569,8 +569,8 @@ const props = defineProps({ foo: String })
         foo: Foo
       }>()
       </script>`,
-        { hoistStatic: true }
-      ).content
+        { hoistStatic: true },
+      ).content,
     ).toMatch(`foo: { type: Number`)
   })
 
@@ -585,7 +585,7 @@ const props = defineProps({ foo: String })
   `)
     expect(bindings).toStrictEqual({
       bar: BindingTypes.SETUP_REF,
-      computed: BindingTypes.SETUP_CONST
+      computed: BindingTypes.SETUP_CONST,
     })
   })
 
@@ -596,7 +596,7 @@ const props = defineProps({ foo: String })
       const { foo } = defineProps<{
         foo: Foo
       }>()
-      </script>`
+      </script>`,
     )
     expect(content).toMatch(`const { foo } = __props`)
     assertCode(content)
@@ -649,7 +649,7 @@ const props = defineProps({ foo: String })
     assertCode(content)
     expect(content).toMatch(`"spa ce": { type: null, required: true }`)
     expect(content).toMatch(
-      `"exclamation!mark": { type: null, required: true }`
+      `"exclamation!mark": { type: null, required: true }`,
     )
     expect(content).toMatch(`"double\\"quote": { type: null, required: true }`)
     expect(content).toMatch(`"hash#tag": { type: null, required: true }`)
@@ -670,7 +670,7 @@ const props = defineProps({ foo: String })
     expect(content).toMatch(`"question?mark": { type: null, required: true }`)
     expect(content).toMatch(`"at@sign": { type: null, required: true }`)
     expect(content).toMatch(
-      `"square[brack]ets": { type: null, required: true }`
+      `"square[brack]ets": { type: null, required: true }`,
     )
     expect(content).toMatch(`"back\\\\slash": { type: null, required: true }`)
     expect(content).toMatch(`"ca^ret": { type: null, required: true }`)
@@ -707,7 +707,7 @@ const props = defineProps({ foo: String })
       'curly{bra}ces': BindingTypes.PROPS,
       'pi|pe': BindingTypes.PROPS,
       'til~de': BindingTypes.PROPS,
-      'da-sh': BindingTypes.PROPS
+      'da-sh': BindingTypes.PROPS,
     })
   })
 
@@ -718,7 +718,7 @@ const props = defineProps({ foo: String })
       const props = defineProps<{ foo: number}>()
       </script>`,
       { isProd: true, customElement: filename => /\.ce\.vue$/.test(filename) },
-      { filename: 'app.ce.vue' }
+      { filename: 'app.ce.vue' },
     )
 
     expect(content).toMatch(`foo: {type: Number}`)
@@ -736,7 +736,7 @@ const props = defineProps({ foo: String })
       });
       </script>`,
       { isProd: true, customElement: filename => /\.ce\.vue$/.test(filename) },
-      { filename: 'app.ce.vue' }
+      { filename: 'app.ce.vue' },
     )
     expect(content).toMatch(`foo: { default: 5.5, type: Number }`)
     assertCode(content)
index 89cc31340afb19e86deb54453f423779e7ba6d46..3843ef921909e0f91527de179f8baf1c208f81bc 100644 (file)
@@ -1,13 +1,13 @@
 import { BindingTypes } from '@vue/compiler-core'
-import { SFCScriptCompileOptions } from '../../src'
-import { compileSFCScript, assertCode } from '../utils'
+import type { SFCScriptCompileOptions } from '../../src'
+import { assertCode, compileSFCScript } from '../utils'
 
 describe('sfc reactive props destructure', () => {
   function compile(src: string, options?: Partial<SFCScriptCompileOptions>) {
     return compileSFCScript(src, {
       inlineTemplate: true,
       propsDestructure: true,
-      ...options
+      ...options,
     })
   }
 
@@ -24,7 +24,7 @@ describe('sfc reactive props destructure', () => {
     expect(content).toMatch(`_toDisplayString(__props.foo)`)
     assertCode(content)
     expect(bindings).toStrictEqual({
-      foo: BindingTypes.PROPS
+      foo: BindingTypes.PROPS,
     })
   })
 
@@ -44,7 +44,7 @@ describe('sfc reactive props destructure', () => {
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
       bar: BindingTypes.LITERAL_CONST,
-      hello: BindingTypes.LITERAL_CONST
+      hello: BindingTypes.LITERAL_CONST,
     })
   })
 
@@ -65,7 +65,7 @@ describe('sfc reactive props destructure', () => {
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
       bar: BindingTypes.PROPS,
-      test: BindingTypes.SETUP_CONST
+      test: BindingTypes.SETUP_CONST,
     })
   })
 
@@ -115,11 +115,11 @@ describe('sfc reactive props destructure', () => {
     `)
     expect(bindings).toStrictEqual({
       __propsAliases: {
-        fooBar: 'foo:bar'
+        fooBar: 'foo:bar',
       },
       foo: BindingTypes.PROPS,
       'foo:bar': BindingTypes.PROPS,
-      fooBar: BindingTypes.PROPS_ALIASED
+      fooBar: BindingTypes.PROPS_ALIASED,
     })
 
     expect(content).toMatch(`
@@ -159,13 +159,13 @@ describe('sfc reactive props destructure', () => {
     `)
     expect(bindings).toStrictEqual({
       __propsAliases: {
-        fooBar: 'foo:bar'
+        fooBar: 'foo:bar',
       },
       foo: BindingTypes.PROPS,
       bar: BindingTypes.PROPS,
       'foo:bar': BindingTypes.PROPS,
       fooBar: BindingTypes.PROPS_ALIASED,
-      'onUpdate:modelValue': BindingTypes.PROPS
+      'onUpdate:modelValue': BindingTypes.PROPS,
     })
     expect(content).toMatch(`
   props: {
@@ -184,7 +184,7 @@ describe('sfc reactive props destructure', () => {
       const { foo = 1, bar = {}, func = () => {} } = defineProps<{ foo?: number, bar?: object, baz?: any, boola?: boolean, boolb?: boolean | number, func?: Function }>()
       </script>
     `,
-      { isProd: true }
+      { isProd: true },
     )
     assertCode(content)
     // literals can be used as-is, non-literals are always returned from a
@@ -220,8 +220,8 @@ describe('sfc reactive props destructure', () => {
       foo: BindingTypes.PROPS,
       bar: BindingTypes.PROPS_ALIASED,
       __propsAliases: {
-        bar: 'foo'
-      }
+        bar: 'foo',
+      },
     })
   })
 
@@ -242,8 +242,8 @@ describe('sfc reactive props destructure', () => {
       'foo.bar': BindingTypes.PROPS,
       fooBar: BindingTypes.PROPS_ALIASED,
       __propsAliases: {
-        fooBar: 'foo.bar'
-      }
+        fooBar: 'foo.bar',
+      },
     })
   })
 
@@ -254,14 +254,14 @@ describe('sfc reactive props destructure', () => {
       </script>
     `)
     expect(content).toMatch(
-      `const rest = _createPropsRestProxy(__props, ["foo","bar"])`
+      `const rest = _createPropsRestProxy(__props, ["foo","bar"])`,
     )
     assertCode(content)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
       bar: BindingTypes.PROPS,
       baz: BindingTypes.PROPS,
-      rest: BindingTypes.SETUP_REACTIVE_CONST
+      rest: BindingTypes.SETUP_REACTIVE_CONST,
     })
   })
 
@@ -279,7 +279,7 @@ describe('sfc reactive props destructure', () => {
     expect(content).toMatch(`_toDisplayString(__props.foo)`)
     assertCode(content)
     expect(bindings).toStrictEqual({
-      foo: BindingTypes.PROPS
+      foo: BindingTypes.PROPS,
     })
   })
 
@@ -339,22 +339,22 @@ describe('sfc reactive props destructure', () => {
     test('should error on deep destructure', () => {
       expect(() =>
         compile(
-          `<script setup>const { foo: [bar] } = defineProps(['foo'])</script>`
-        )
+          `<script setup>const { foo: [bar] } = defineProps(['foo'])</script>`,
+        ),
       ).toThrow(`destructure does not support nested patterns`)
 
       expect(() =>
         compile(
-          `<script setup>const { foo: { bar } } = defineProps(['foo'])</script>`
-        )
+          `<script setup>const { foo: { bar } } = defineProps(['foo'])</script>`,
+        ),
       ).toThrow(`destructure does not support nested patterns`)
     })
 
     test('should error on computed key', () => {
       expect(() =>
         compile(
-          `<script setup>const { [foo]: bar } = defineProps(['foo'])</script>`
-        )
+          `<script setup>const { [foo]: bar } = defineProps(['foo'])</script>`,
+        ),
       ).toThrow(`destructure cannot use computed key`)
     })
 
@@ -363,8 +363,8 @@ describe('sfc reactive props destructure', () => {
         compile(
           `<script setup lang="ts">
           const { foo } = withDefaults(defineProps<{ foo: string }>(), { foo: 'foo' })
-          </script>`
-        )
+          </script>`,
+        ),
       ).toThrow(`withDefaults() is unnecessary when using destructure`)
     })
 
@@ -376,8 +376,8 @@ describe('sfc reactive props destructure', () => {
           const {
             foo = () => x
           } = defineProps(['foo'])
-          </script>`
-        )
+          </script>`,
+        ),
       ).toThrow(`cannot reference locally declared variables`)
     })
 
@@ -387,8 +387,8 @@ describe('sfc reactive props destructure', () => {
           `<script setup>
           const { foo } = defineProps(['foo'])
           foo = 'bar'
-          </script>`
-        )
+          </script>`,
+        ),
       ).toThrow(`Cannot assign to destructured props`)
 
       expect(() =>
@@ -396,8 +396,8 @@ describe('sfc reactive props destructure', () => {
           `<script setup>
           let { foo } = defineProps(['foo'])
           foo = 'bar'
-          </script>`
-        )
+          </script>`,
+        ),
       ).toThrow(`Cannot assign to destructured props`)
     })
 
@@ -408,10 +408,10 @@ describe('sfc reactive props destructure', () => {
         import { watch } from 'vue'
         const { foo } = defineProps(['foo'])
         watch(foo, () => {})
-        </script>`
-        )
+        </script>`,
+        ),
       ).toThrow(
-        `"foo" is a destructured prop and should not be passed directly to watch().`
+        `"foo" is a destructured prop and should not be passed directly to watch().`,
       )
 
       expect(() =>
@@ -420,10 +420,10 @@ describe('sfc reactive props destructure', () => {
         import { watch as w } from 'vue'
         const { foo } = defineProps(['foo'])
         w(foo, () => {})
-        </script>`
-        )
+        </script>`,
+        ),
       ).toThrow(
-        `"foo" is a destructured prop and should not be passed directly to watch().`
+        `"foo" is a destructured prop and should not be passed directly to watch().`,
       )
 
       expect(() =>
@@ -432,10 +432,10 @@ describe('sfc reactive props destructure', () => {
         import { toRef } from 'vue'
         const { foo } = defineProps(['foo'])
         toRef(foo)
-        </script>`
-        )
+        </script>`,
+        ),
       ).toThrow(
-        `"foo" is a destructured prop and should not be passed directly to toRef().`
+        `"foo" is a destructured prop and should not be passed directly to toRef().`,
       )
 
       expect(() =>
@@ -444,10 +444,10 @@ describe('sfc reactive props destructure', () => {
         import { toRef as r } from 'vue'
         const { foo } = defineProps(['foo'])
         r(foo)
-        </script>`
-        )
+        </script>`,
+        ),
       ).toThrow(
-        `"foo" is a destructured prop and should not be passed directly to toRef().`
+        `"foo" is a destructured prop and should not be passed directly to toRef().`,
       )
     })
 
@@ -457,8 +457,8 @@ describe('sfc reactive props destructure', () => {
         compile(
           `<script setup lang="ts">
         const { foo = 'hello' } = defineProps<{ foo?: number }>()
-        </script>`
-        )
+        </script>`,
+        ),
       ).toThrow(`Default value of prop "foo" does not match declared type.`)
     })
 
@@ -472,8 +472,8 @@ describe('sfc reactive props destructure', () => {
         const { error: e, info } = useRequest();
         watch(e, () => {});
         watch(info, () => {});
-        </script>`
-        )
+        </script>`,
+        ),
       ).not.toThrowError()
     })
   })
index c7becacc02a15917e835d721ed917d4496e49278..357709afdf3a2f448f8ee64b1ed60984138790bc 100644 (file)
@@ -1,4 +1,4 @@
-import { compileSFCScript as compile, assertCode } from '../utils'
+import { assertCode, compileSFCScript as compile } from '../utils'
 
 describe('defineSlots()', () => {
   test('basic usage', () => {
index d2c76c9a2ccd5443494018c6b261e0ade6963b07..ce6191777cc0c644c10bc98bce65b3a4f80260c4 100644 (file)
@@ -1,13 +1,13 @@
 import { BindingTypes } from '@vue/compiler-core'
-import { SFCScriptCompileOptions } from '../../src'
-import { compileSFCScript, assertCode } from '../utils'
+import type { SFCScriptCompileOptions } from '../../src'
+import { assertCode, compileSFCScript } from '../utils'
 
 describe('sfc hoist static', () => {
   function compile(src: string, options?: Partial<SFCScriptCompileOptions>) {
     return compileSFCScript(src, {
       inlineTemplate: true,
       hoistStatic: true,
-      ...options
+      ...options,
     })
   }
 
@@ -34,7 +34,7 @@ describe('sfc hoist static', () => {
       boolean: BindingTypes.LITERAL_CONST,
       nil: BindingTypes.LITERAL_CONST,
       bigint: BindingTypes.LITERAL_CONST,
-      template: BindingTypes.LITERAL_CONST
+      template: BindingTypes.LITERAL_CONST,
     })
     assertCode(content)
   })
@@ -57,7 +57,7 @@ describe('sfc hoist static', () => {
       binary: BindingTypes.LITERAL_CONST,
       conditional: BindingTypes.LITERAL_CONST,
       unary: BindingTypes.LITERAL_CONST,
-      sequence: BindingTypes.LITERAL_CONST
+      sequence: BindingTypes.LITERAL_CONST,
     })
     assertCode(content)
   })
@@ -79,7 +79,7 @@ describe('sfc hoist static', () => {
     expect(content.startsWith(hoistCode)).toBe(true)
     expect(bindings).toStrictEqual({
       foo: BindingTypes.PROPS,
-      defaultValue: BindingTypes.LITERAL_CONST
+      defaultValue: BindingTypes.LITERAL_CONST,
     })
     assertCode(content)
   })
@@ -100,7 +100,7 @@ describe('sfc hoist static', () => {
       KEY1: BindingTypes.SETUP_LET,
       KEY2: BindingTypes.SETUP_LET,
       regex: BindingTypes.SETUP_CONST,
-      undef: BindingTypes.SETUP_MAYBE_REF
+      undef: BindingTypes.SETUP_MAYBE_REF,
     })
     expect(content).toMatch(`setup(__props) {\n\n    ${code}`)
     assertCode(content)
@@ -131,7 +131,7 @@ describe('sfc hoist static', () => {
       KEY4: BindingTypes.SETUP_CONST,
       KEY5: BindingTypes.SETUP_CONST,
       KEY6: BindingTypes.SETUP_CONST,
-      i: BindingTypes.SETUP_LET
+      i: BindingTypes.SETUP_LET,
     })
     expect(content).toMatch(`setup(__props) {\n\n    ${code}`)
     assertCode(content)
@@ -149,7 +149,7 @@ describe('sfc hoist static', () => {
     `)
     expect(bindings).toStrictEqual({
       arr: BindingTypes.SETUP_CONST,
-      obj: BindingTypes.SETUP_CONST
+      obj: BindingTypes.SETUP_CONST,
     })
     expect(content).toMatch(`setup(__props) {\n\n    ${code}`)
     assertCode(content)
@@ -169,7 +169,7 @@ describe('sfc hoist static', () => {
     expect(bindings).toStrictEqual({
       Foo: BindingTypes.SETUP_CONST,
       fn: BindingTypes.SETUP_CONST,
-      fn2: BindingTypes.SETUP_CONST
+      fn2: BindingTypes.SETUP_CONST,
     })
     expect(content).toMatch(`setup(__props) {\n\n    ${code}`)
     assertCode(content)
@@ -185,7 +185,7 @@ describe('sfc hoist static', () => {
     </script>
     `)
     expect(bindings).toStrictEqual({
-      foo: BindingTypes.SETUP_CONST
+      foo: BindingTypes.SETUP_CONST,
     })
     assertCode(content)
   })
@@ -197,10 +197,10 @@ describe('sfc hoist static', () => {
     const foo = 'bar'
     </script>
     `,
-      { hoistStatic: false }
+      { hoistStatic: false },
     )
     expect(bindings).toStrictEqual({
-      foo: BindingTypes.SETUP_CONST
+      foo: BindingTypes.SETUP_CONST,
     })
     assertCode(content)
   })
@@ -212,7 +212,7 @@ describe('sfc hoist static', () => {
     const foo = 'bar'
     </script>
     <template>{{ foo }}</template>
-    `
+    `,
     )
     expect(content).toMatch('_toDisplayString(foo)')
   })
index a8074419c38b23984c29d12c898882236ee12bb6..0c5c95cd17fffdfc59b61955e52465dcd7fac168 100644 (file)
@@ -1,13 +1,13 @@
 import { normalize } from 'node:path'
-import { Identifier } from '@babel/types'
-import { SFCScriptCompileOptions, parse } from '../../src'
+import type { Identifier } from '@babel/types'
+import { type SFCScriptCompileOptions, parse } from '../../src'
 import { ScriptCompileContext } from '../../src/script/context'
 import {
   inferRuntimeType,
   invalidateTypeCache,
   recordImports,
+  registerTS,
   resolveTypeElements,
-  registerTS
 } from '../../src/script/resolveType'
 
 import ts from 'typescript'
@@ -25,7 +25,7 @@ describe('resolveType', () => {
     expect(props).toStrictEqual({
       foo: ['Number'],
       bar: ['Function'],
-      baz: ['String']
+      baz: ['String'],
     })
     expect(calls?.length).toBe(2)
   })
@@ -35,9 +35,9 @@ describe('resolveType', () => {
       resolve(`
     type Aliased = { foo: number }
     defineProps<Aliased>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -46,9 +46,9 @@ describe('resolveType', () => {
       resolve(`
     export type Aliased = { foo: number }
     defineProps<Aliased>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -57,9 +57,9 @@ describe('resolveType', () => {
       resolve(`
     interface Aliased { foo: number }
     defineProps<Aliased>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -68,9 +68,9 @@ describe('resolveType', () => {
       resolve(`
     export interface Aliased { foo: number }
     defineProps<Aliased>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -82,12 +82,12 @@ describe('resolveType', () => {
     interface C { c: string }
     interface Aliased extends B, C { foo: number }
     defineProps<Aliased>()
-    `).props
+    `).props,
     ).toStrictEqual({
       a: ['Function'],
       b: ['Boolean'],
       c: ['String'],
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -96,9 +96,9 @@ describe('resolveType', () => {
       resolve(`
     class Foo {}
     defineProps<{ foo: Foo }>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Object']
+      foo: ['Object'],
     })
   })
 
@@ -106,7 +106,7 @@ describe('resolveType', () => {
     expect(
       resolve(`
     defineProps<(e: 'foo') => void>()
-    `).calls?.length
+    `).calls?.length,
     ).toBe(1)
   })
 
@@ -115,7 +115,7 @@ describe('resolveType', () => {
       resolve(`
     type Fn = (e: 'foo') => void
     defineProps<Fn>()
-    `).calls?.length
+    `).calls?.length,
     ).toBe(1)
   })
 
@@ -126,13 +126,13 @@ describe('resolveType', () => {
     type Bar = { bar: string }
     type Baz = { bar: string | boolean }
     defineProps<{ self: any } & Foo & Bar & Baz>()
-    `).props
+    `).props,
     ).toStrictEqual({
       self: ['Unknown'],
       foo: ['Number'],
       // both Bar & Baz has 'bar', but Baz['bar] is wider so it should be
       // preferred
-      bar: ['String', 'Boolean']
+      bar: ['String', 'Boolean'],
     })
   })
 
@@ -156,12 +156,12 @@ describe('resolveType', () => {
         }
 
     defineProps<CommonProps & ConditionalProps>()
-    `).props
+    `).props,
     ).toStrictEqual({
       size: ['String'],
       color: ['String', 'Number'],
       appearance: ['String'],
-      note: ['String']
+      note: ['String'],
     })
   })
 
@@ -173,12 +173,12 @@ describe('resolveType', () => {
     defineProps<{
       [\`_\${T}_\${S}_\`]: string
     }>()
-    `).props
+    `).props,
     ).toStrictEqual({
       _foo_x_: ['String'],
       _foo_y_: ['String'],
       _bar_x_: ['String'],
-      _bar_y_: ['String']
+      _bar_y_: ['String'],
     })
   })
 
@@ -195,7 +195,7 @@ describe('resolveType', () => {
     } & {
       [K in \`x\${T}\`]: string
     }>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['String', 'Number'],
       bar: ['String', 'Number'],
@@ -204,7 +204,7 @@ describe('resolveType', () => {
       FOO: ['String'],
       xfoo: ['String'],
       xbar: ['String'],
-      optional: ['Boolean']
+      optional: ['Boolean'],
     })
   })
 
@@ -213,14 +213,14 @@ describe('resolveType', () => {
       resolve(`
     type T = { foo: number, bar: string }
     defineProps<Partial<T>>()
-    `).raw.props
+    `).raw.props,
     ).toMatchObject({
       foo: {
-        optional: true
+        optional: true,
       },
       bar: {
-        optional: true
-      }
+        optional: true,
+      },
     })
   })
 
@@ -229,14 +229,14 @@ describe('resolveType', () => {
       resolve(`
     type T = { foo?: number, bar?: string }
     defineProps<Required<T>>()
-    `).raw.props
+    `).raw.props,
     ).toMatchObject({
       foo: {
-        optional: false
+        optional: false,
       },
       bar: {
-        optional: false
-      }
+        optional: false,
+      },
     })
   })
 
@@ -246,10 +246,10 @@ describe('resolveType', () => {
     type T = { foo: number, bar: string, baz: boolean }
     type K = 'foo' | 'bar'
     defineProps<Pick<T, K>>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['Number'],
-      bar: ['String']
+      bar: ['String'],
     })
   })
 
@@ -259,9 +259,9 @@ describe('resolveType', () => {
     type T = { foo: number, bar: string, baz: boolean }
     type K = 'foo' | 'bar'
     defineProps<Omit<T, K>>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      baz: ['Boolean']
+      baz: ['Boolean'],
     })
   })
 
@@ -271,9 +271,9 @@ describe('resolveType', () => {
     type T = { bar: number }
     type S = { nested: { foo: T['bar'] }}
     defineProps<S['nested']>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -284,10 +284,10 @@ describe('resolveType', () => {
     type T = { foo: string, bar: number }
     type S = { foo: { foo: T[string] }, bar: { bar: string } }
     defineProps<S[K]>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['String', 'Number'],
-      bar: ['String']
+      bar: ['String'],
     })
   })
 
@@ -299,12 +299,12 @@ describe('resolveType', () => {
     type T = [1, 'foo']
     type TT = [foo: 1, bar: 'foo']
     defineProps<{ foo: A[number], bar: AA[number], tuple: T[number], namedTuple: TT[number] }>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['String', 'Number'],
       bar: ['String'],
       tuple: ['Number', 'String'],
-      namedTuple: ['Number', 'String']
+      namedTuple: ['Number', 'String'],
     })
   })
 
@@ -321,9 +321,9 @@ describe('resolveType', () => {
         }
       }
       defineProps<Foo.Bar.A>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number']
+      foo: ['Number'],
     })
   })
 
@@ -340,10 +340,10 @@ describe('resolveType', () => {
         foo: Foo['a'],
         bar: Foo['b']
       }>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['String'],
-      bar: ['Number']
+      bar: ['Number'],
     })
   })
 
@@ -360,10 +360,10 @@ describe('resolveType', () => {
         foo: Foo.A,
         bar: Foo.B
       }>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['String'],
-      bar: ['Number']
+      bar: ['Number'],
     })
   })
 
@@ -380,10 +380,10 @@ describe('resolveType', () => {
         foo: Foo.A,
         bar: Foo['b']
       }>()
-    `).props
+    `).props,
     ).toStrictEqual({
       foo: ['String'],
-      bar: ['Number']
+      bar: ['Number'],
     })
   })
 
@@ -399,9 +399,9 @@ describe('resolveType', () => {
       defineProps<{
         foo: Foo
       }>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['Number', 'String']
+      foo: ['Number', 'String'],
     })
   })
 
@@ -410,9 +410,9 @@ describe('resolveType', () => {
       resolve(`
       declare const a: string
       defineProps<{ foo: typeof a }>()
-    `).props
+    `).props,
     ).toStrictEqual({
-      foo: ['String']
+      foo: ['String'],
     })
   })
 
@@ -429,11 +429,11 @@ describe('resolveType', () => {
       }
       type Props = ExtractPropTypes<typeof props>
       defineProps<Props>()
-    `
+    `,
     )
     expect(props).toStrictEqual({
       foo: ['String'],
-      bar: ['Boolean']
+      bar: ['Boolean'],
     })
     expect(raw.props.bar.optional).toBe(false)
   })
@@ -447,11 +447,11 @@ describe('resolveType', () => {
       }
       type Props = Partial<import('vue').ExtractPropTypes<ReturnType<typeof props>>>
       defineProps<Props>()
-    `
+    `,
     )
     expect(props).toStrictEqual({
       foo: ['String'],
-      bar: ['Boolean']
+      bar: ['Boolean'],
     })
   })
 
@@ -461,9 +461,9 @@ describe('resolveType', () => {
         resolve(`
         type Props<T> = T
         defineProps<Props<{ foo: string }>>()
-      `).props
+      `).props,
       ).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
     })
 
@@ -474,11 +474,11 @@ describe('resolveType', () => {
         type Bar = { bar: number; }
         type Props<T,U> = T & U & { baz: boolean }
         defineProps<Props<Foo, Bar>>()
-      `).props
+      `).props,
       ).toStrictEqual({
         foo: ['String'],
         bar: ['Number'],
-        baz: ['Boolean']
+        baz: ['Boolean'],
       })
     })
 
@@ -489,9 +489,9 @@ describe('resolveType', () => {
         type Props<T> = Aliased<T>
         type Foo = { foo: string; }
         defineProps<Props<Foo>>()
-      `).props
+      `).props,
       ).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
     })
 
@@ -500,9 +500,9 @@ describe('resolveType', () => {
         resolve(`
         type Aliased<T> = { foo: T }
         defineProps<Aliased<string>>()
-      `).props
+      `).props,
       ).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
     })
 
@@ -514,25 +514,25 @@ describe('resolveType', () => {
         }
         type Foo = string
         defineProps<Props<Foo>>()
-      `).props
+      `).props,
       ).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
     })
 
     test('generic from external-file', () => {
       const files = {
-        '/foo.ts': 'export type P<T> = { foo: T }'
+        '/foo.ts': 'export type P<T> = { foo: T }',
       }
       const { props } = resolve(
         `
         import { P } from './foo'
         defineProps<P<string>>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
     })
   })
@@ -544,7 +544,7 @@ describe('resolveType', () => {
         '/bar.d.ts':
           'type X = { bar: string }; export { X as Y };' +
           // verify that we can parse syntax that is only valid in d.ts
-          'export const baz: boolean'
+          'export const baz: boolean',
       }
       const { props, deps } = resolve(
         `
@@ -552,11 +552,11 @@ describe('resolveType', () => {
         import { Y as PP } from './bar'
         defineProps<P & PP>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['Number'],
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -568,7 +568,7 @@ describe('resolveType', () => {
           'type X = { bar: string }; export { X as Y };' +
           // verify that we can parse syntax that is only valid in d.ts
           'export const baz: boolean',
-        'C:\\Test\\FolderB\\buz.ts': 'export type Z = { buz: string }'
+        'C:\\Test\\FolderB\\buz.ts': 'export type Z = { buz: string }',
       }
       const { props, deps } = resolve(
         `
@@ -579,32 +579,32 @@ describe('resolveType', () => {
     `,
         files,
         {},
-        'C:\\Test\\FolderA\\Test.vue'
+        'C:\\Test\\FolderA\\Test.vue',
       )
       expect(props).toStrictEqual({
         foo: ['Number'],
         bar: ['String'],
-        buz: ['String']
+        buz: ['String'],
       })
       expect(deps && [...deps].map(normalize)).toStrictEqual(
-        Object.keys(files).map(normalize)
+        Object.keys(files).map(normalize),
       )
     })
 
     // #8244
     test('utility type in external file', () => {
       const files = {
-        '/foo.ts': 'type A = { n?: number }; export type B = Required<A>'
+        '/foo.ts': 'type A = { n?: number }; export type B = Required<A>',
       }
       const { props } = resolve(
         `
         import { B } from './foo'
         defineProps<B>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
-        n: ['Number']
+        n: ['Number'],
       })
     })
 
@@ -613,7 +613,7 @@ describe('resolveType', () => {
         '/foo.vue':
           '<script lang="ts">export type P = { foo: number }</script>',
         '/bar.vue':
-          '<script setup lang="tsx">export type P = { bar: string }</script>'
+          '<script setup lang="tsx">export type P = { bar: string }</script>',
       }
       const { props, deps } = resolve(
         `
@@ -621,11 +621,11 @@ describe('resolveType', () => {
         import { P as PP } from './bar.vue'
         defineProps<P & PP>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['Number'],
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -635,18 +635,18 @@ describe('resolveType', () => {
         '/foo.ts': `import type { P as PP } from './nested/bar.vue'
           export type P = { foo: number } & PP`,
         '/nested/bar.vue':
-          '<script setup lang="ts">export type P = { bar: string }</script>'
+          '<script setup lang="ts">export type P = { bar: string }</script>',
       }
       const { props, deps } = resolve(
         `
         import { P } from './foo'
         defineProps<P>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['Number'],
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -654,17 +654,17 @@ describe('resolveType', () => {
     test('relative (chained, re-export)', () => {
       const files = {
         '/foo.ts': `export { P as PP } from './bar'`,
-        '/bar.ts': 'export type P = { bar: string }'
+        '/bar.ts': 'export type P = { bar: string }',
       }
       const { props, deps } = resolve(
         `
         import { PP as P } from './foo'
         defineProps<P>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -672,17 +672,17 @@ describe('resolveType', () => {
     test('relative (chained, export *)', () => {
       const files = {
         '/foo.ts': `export * from './bar'`,
-        '/bar.ts': 'export type P = { bar: string }'
+        '/bar.ts': 'export type P = { bar: string }',
       }
       const { props, deps } = resolve(
         `
         import { P } from './foo'
         defineProps<P>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -690,7 +690,7 @@ describe('resolveType', () => {
     test('relative (default export)', () => {
       const files = {
         '/foo.ts': `export default interface P { foo: string }`,
-        '/bar.ts': `type X = { bar: string }; export default X`
+        '/bar.ts': `type X = { bar: string }; export default X`,
       }
       const { props, deps } = resolve(
         `
@@ -698,11 +698,11 @@ describe('resolveType', () => {
         import X from './bar'
         defineProps<P & X>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['String'],
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -711,7 +711,7 @@ describe('resolveType', () => {
       const files = {
         '/bar.ts': `export { default } from './foo'`,
         '/foo.ts': `export default interface P { foo: string }; export interface PP { bar: number }`,
-        '/baz.ts': `export { PP as default } from './foo'`
+        '/baz.ts': `export { PP as default } from './foo'`,
       }
       const { props, deps } = resolve(
         `
@@ -719,11 +719,11 @@ describe('resolveType', () => {
         import PP from './baz'
         defineProps<P & PP>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['String'],
-        bar: ['Number']
+        bar: ['Number'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -732,17 +732,17 @@ describe('resolveType', () => {
       const files = {
         '/foo.ts': `export default interface P { foo: string }`,
         '/bar.ts': `export default interface PP { bar: number }`,
-        '/baz.ts': `export { default as X } from './foo'; export { default as XX } from './bar'; `
+        '/baz.ts': `export { default as X } from './foo'; export { default as XX } from './bar'; `,
       }
       const { props, deps } = resolve(
         `import { X, XX } from './baz'
         defineProps<X & XX>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['String'],
-        bar: ['Number']
+        bar: ['Number'],
       })
       expect(deps && [...deps]).toStrictEqual(['/baz.ts', '/foo.ts', '/bar.ts'])
     })
@@ -750,17 +750,17 @@ describe('resolveType', () => {
     test('relative (dynamic import)', () => {
       const files = {
         '/foo.ts': `export type P = { foo: string, bar: import('./bar').N }`,
-        '/bar.ts': 'export type N = number'
+        '/bar.ts': 'export type N = number',
       }
       const { props, deps } = resolve(
         `
         defineProps<import('./foo').P>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
         foo: ['String'],
-        bar: ['Number']
+        bar: ['Number'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -770,17 +770,17 @@ describe('resolveType', () => {
       const files = {
         '/foo.d.ts':
           'import { PP } from "./bar.js"; export type P = { foo: PP }',
-        '/bar.d.ts': 'export type PP = "foo" | "bar"'
+        '/bar.d.ts': 'export type PP = "foo" | "bar"',
       }
       const { props, deps } = resolve(
         `
         import { P } from './foo'
         defineProps<P>()
       `,
-        files
+        files,
       )
       expect(props).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -788,17 +788,17 @@ describe('resolveType', () => {
     test('ts module resolve', () => {
       const files = {
         '/node_modules/foo/package.json': JSON.stringify({
-          types: 'index.d.ts'
+          types: 'index.d.ts',
         }),
         '/node_modules/foo/index.d.ts': 'export type P = { foo: number }',
         '/tsconfig.json': JSON.stringify({
           compilerOptions: {
             paths: {
-              bar: ['./pp.ts']
-            }
-          }
+              bar: ['./pp.ts'],
+            },
+          },
         }),
-        '/pp.ts': 'export type PP = { bar: string }'
+        '/pp.ts': 'export type PP = { bar: string }',
       }
 
       const { props, deps } = resolve(
@@ -807,16 +807,16 @@ describe('resolveType', () => {
         import { PP } from 'bar'
         defineProps<P & PP>()
         `,
-        files
+        files,
       )
 
       expect(props).toStrictEqual({
         foo: ['Number'],
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual([
         '/node_modules/foo/index.d.ts',
-        '/pp.ts'
+        '/pp.ts',
       ])
     })
 
@@ -825,23 +825,23 @@ describe('resolveType', () => {
         '/tsconfig.json': JSON.stringify({
           references: [
             {
-              path: './tsconfig.app.json'
-            }
-          ]
+              path: './tsconfig.app.json',
+            },
+          ],
         }),
         '/tsconfig.app.json': JSON.stringify({
           include: ['**/*.ts', '**/*.vue'],
-          extends: './tsconfig.web.json'
+          extends: './tsconfig.web.json',
         }),
         '/tsconfig.web.json': JSON.stringify({
           compilerOptions: {
             composite: true,
             paths: {
-              bar: ['./user.ts']
-            }
-          }
+              bar: ['./user.ts'],
+            },
+          },
         }),
-        '/user.ts': 'export type User = { bar: string }'
+        '/user.ts': 'export type User = { bar: string }',
       }
 
       const { props, deps } = resolve(
@@ -849,11 +849,11 @@ describe('resolveType', () => {
         import { User } from 'bar'
         defineProps<User>()
         `,
-        files
+        files,
       )
 
       expect(props).toStrictEqual({
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(['/user.ts'])
     })
@@ -864,12 +864,12 @@ describe('resolveType', () => {
           compilerOptions: {
             include: ['**/*.ts', '**/*.vue'],
             paths: {
-              '@/*': ['./src/*']
-            }
-          }
+              '@/*': ['./src/*'],
+            },
+          },
         }),
         '/src/Foo.vue':
-          '<script lang="ts">export type P = { bar: string }</script>'
+          '<script lang="ts">export type P = { bar: string }</script>',
       }
 
       const { props, deps } = resolve(
@@ -877,11 +877,11 @@ describe('resolveType', () => {
         import { P } from '@/Foo.vue'
         defineProps<P>()
         `,
-        files
+        files,
       )
 
       expect(props).toStrictEqual({
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(['/src/Foo.vue'])
     })
@@ -898,16 +898,16 @@ describe('resolveType', () => {
             type PP = { bar: string }
           }
           export {}
-        `
+        `,
       }
 
       const { props, deps } = resolve(`defineProps<App.User & PP>()`, files, {
-        globalTypeFiles: Object.keys(files)
+        globalTypeFiles: Object.keys(files),
       })
 
       expect(props).toStrictEqual({
         name: ['String'],
-        bar: ['String']
+        bar: ['String'],
       })
       expect(deps && [...deps]).toStrictEqual(Object.keys(files))
     })
@@ -927,33 +927,33 @@ describe('resolveType', () => {
               id: string
             }
           }
-        `
+        `,
       }
 
       const { props } = resolve(`defineProps<App.Data.AircraftData>()`, files, {
-        globalTypeFiles: Object.keys(files)
+        globalTypeFiles: Object.keys(files),
       })
 
       expect(props).toStrictEqual({
         id: ['String'],
-        manufacturer: ['Object']
+        manufacturer: ['Object'],
       })
     })
 
     // #9871
     test('shared generics with different args', () => {
       const files = {
-        '/foo.ts': `export interface Foo<T> { value: T }`
+        '/foo.ts': `export interface Foo<T> { value: T }`,
       }
       const { props } = resolve(
         `import type { Foo } from './foo'
         defineProps<Foo<string>>()`,
         files,
         undefined,
-        `/One.vue`
+        `/One.vue`,
       )
       expect(props).toStrictEqual({
-        value: ['String']
+        value: ['String'],
       })
       const { props: props2 } = resolve(
         `import type { Foo } from './foo'
@@ -961,10 +961,10 @@ describe('resolveType', () => {
         files,
         undefined,
         `/Two.vue`,
-        false /* do not invalidate cache */
+        false /* do not invalidate cache */,
       )
       expect(props2).toStrictEqual({
-        value: ['Number']
+        value: ['Number'],
       })
     })
   })
@@ -972,25 +972,25 @@ describe('resolveType', () => {
   describe('errors', () => {
     test('failed type reference', () => {
       expect(() => resolve(`defineProps<X>()`)).toThrow(
-        `Unresolvable type reference`
+        `Unresolvable type reference`,
       )
     })
 
     test('unsupported computed keys', () => {
       expect(() => resolve(`defineProps<{ [Foo]: string }>()`)).toThrow(
-        `Unsupported computed key in type referenced by a macro`
+        `Unsupported computed key in type referenced by a macro`,
       )
     })
 
     test('unsupported index type', () => {
       expect(() => resolve(`defineProps<X[K]>()`)).toThrow(
-        `Unsupported type when resolving index type`
+        `Unsupported type when resolving index type`,
       )
     })
 
     test('failed import source resolve', () => {
       expect(() =>
-        resolve(`import { X } from './foo'; defineProps<X>()`)
+        resolve(`import { X } from './foo'; defineProps<X>()`),
       ).toThrow(`Failed to resolve import source "./foo"`)
     })
 
@@ -1001,7 +1001,7 @@ describe('resolveType', () => {
         resolve(`
         import type P from 'unknown'
         defineProps<{ foo: P }>()
-      `)
+      `),
       ).not.toThrow()
     })
 
@@ -1011,7 +1011,7 @@ describe('resolveType', () => {
         import type Base from 'unknown'
         interface Props extends Base {}
         defineProps<Props>()
-      `)
+      `),
       ).toThrow(`@vue-ignore`)
     })
 
@@ -1026,11 +1026,11 @@ describe('resolveType', () => {
           foo: string
         }
         defineProps<Props>()
-      `))
+      `)),
       ).not.toThrow(`@vue-ignore`)
 
       expect(res.props).toStrictEqual({
-        foo: ['String']
+        foo: ['String'],
       })
     })
   })
@@ -1041,10 +1041,10 @@ function resolve(
   files: Record<string, string> = {},
   options?: Partial<SFCScriptCompileOptions>,
   sourceFileName: string = '/Test.vue',
-  invalidateCache = true
+  invalidateCache = true,
 ) {
   const { descriptor } = parse(`<script setup lang="ts">\n${code}\n</script>`, {
-    filename: sourceFileName
+    filename: sourceFileName,
   })
   const ctx = new ScriptCompileContext(descriptor, {
     id: 'test',
@@ -1054,9 +1054,9 @@ function resolve(
       },
       readFile(file) {
         return files[file] ?? files[normalize(file)]
-      }
+      },
     },
-    ...options
+    ...options,
   })
 
   if (invalidateCache) {
@@ -1088,6 +1088,6 @@ function resolve(
     props,
     calls: raw.calls,
     deps: ctx.deps,
-    raw
+    raw,
   }
 }
index 624cbaa043f230eb11712f3a1a5780dffef18088..1f9ae67225bae3fab8bef26de590943ed78680a5 100644 (file)
@@ -1,20 +1,20 @@
 import {
+  type SFCStyleCompileOptions,
   compileStyle,
   compileStyleAsync,
-  SFCStyleCompileOptions
 } from '../src/compileStyle'
-import path from 'path'
+import path from 'node:path'
 
 export function compileScoped(
   source: string,
-  options?: Partial<SFCStyleCompileOptions>
+  options?: Partial<SFCStyleCompileOptions>,
 ): string {
   const res = compileStyle({
     source,
     filename: 'test.css',
     id: 'data-v-test',
     scoped: true,
-    ...options
+    ...options,
   })
   if (res.errors.length) {
     res.errors.forEach(err => {
@@ -28,34 +28,34 @@ export function compileScoped(
 describe('SFC scoped CSS', () => {
   test('simple selectors', () => {
     expect(compileScoped(`h1 { color: red; }`)).toMatch(
-      `h1[data-v-test] { color: red;`
+      `h1[data-v-test] { color: red;`,
     )
     expect(compileScoped(`.foo { color: red; }`)).toMatch(
-      `.foo[data-v-test] { color: red;`
+      `.foo[data-v-test] { color: red;`,
     )
   })
 
   test('descendent selector', () => {
     expect(compileScoped(`h1 .foo { color: red; }`)).toMatch(
-      `h1 .foo[data-v-test] { color: red;`
+      `h1 .foo[data-v-test] { color: red;`,
     )
   })
 
   test('multiple selectors', () => {
     expect(compileScoped(`h1 .foo, .bar, .baz { color: red; }`)).toMatch(
-      `h1 .foo[data-v-test], .bar[data-v-test], .baz[data-v-test] { color: red;`
+      `h1 .foo[data-v-test], .bar[data-v-test], .baz[data-v-test] { color: red;`,
     )
   })
 
   test('pseudo class', () => {
     expect(compileScoped(`.foo:after { color: red; }`)).toMatch(
-      `.foo[data-v-test]:after { color: red;`
+      `.foo[data-v-test]:after { color: red;`,
     )
   })
 
   test('pseudo element', () => {
     expect(compileScoped(`::selection { display: none; }`)).toMatch(
-      '[data-v-test]::selection {'
+      '[data-v-test]::selection {',
     )
   })
 
@@ -217,30 +217,30 @@ describe('SFC scoped CSS', () => {
   to { opacity: 1; }
 }
     `,
-      { id: 'data-v-test' }
+      { id: 'data-v-test' },
     )
 
     expect(style).toContain(
-      `.anim[data-v-test] {\n  animation: color-test 5s infinite, other 5s;`
+      `.anim[data-v-test] {\n  animation: color-test 5s infinite, other 5s;`,
     )
     expect(style).toContain(
-      `.anim-2[data-v-test] {\n  animation-name: color-test`
+      `.anim-2[data-v-test] {\n  animation-name: color-test`,
     )
     expect(style).toContain(
-      `.anim-3[data-v-test] {\n  animation: 5s color-test infinite, 5s other;`
+      `.anim-3[data-v-test] {\n  animation: 5s color-test infinite, 5s other;`,
     )
     expect(style).toContain(`@keyframes color-test {`)
     expect(style).toContain(`@-webkit-keyframes color-test {`)
 
     expect(style).toContain(
-      `.anim-multiple[data-v-test] {\n  animation: color-test 5s infinite,opacity-test 2s;`
+      `.anim-multiple[data-v-test] {\n  animation: color-test 5s infinite,opacity-test 2s;`,
     )
     expect(style).toContain(
-      `.anim-multiple-2[data-v-test] {\n  animation-name: color-test,opacity-test;`
+      `.anim-multiple-2[data-v-test] {\n  animation-name: color-test,opacity-test;`,
     )
     expect(style).toContain(`@keyframes opacity-test {\nfrom { opacity: 0;`)
     expect(style).toContain(
-      `@-webkit-keyframes opacity-test {\nfrom { opacity: 0;`
+      `@-webkit-keyframes opacity-test {\nfrom { opacity: 0;`,
     )
   })
 
@@ -265,7 +265,7 @@ describe('SFC scoped CSS', () => {
         }"
       `)
       expect(
-        `::v-deep usage as a combinator has been deprecated.`
+        `::v-deep usage as a combinator has been deprecated.`,
       ).toHaveBeenWarned()
     })
 
@@ -276,7 +276,7 @@ describe('SFC scoped CSS', () => {
         }"
       `)
       expect(
-        `the >>> and /deep/ combinators have been deprecated.`
+        `the >>> and /deep/ combinators have been deprecated.`,
       ).toHaveBeenWarned()
     })
 
@@ -287,7 +287,7 @@ describe('SFC scoped CSS', () => {
         }"
       `)
       expect(
-        `the >>> and /deep/ combinators have been deprecated.`
+        `the >>> and /deep/ combinators have been deprecated.`,
       ).toHaveBeenWarned()
     })
   })
@@ -299,7 +299,7 @@ describe('SFC CSS modules', () => {
       source: `.red { color: red }\n.green { color: green }\n:global(.blue) { color: blue }`,
       filename: `test.css`,
       id: 'test',
-      modules: true
+      modules: true,
     })
     expect(result.modules).toBeDefined()
     expect(result.modules!.red).toMatch('_red_')
@@ -316,8 +316,8 @@ describe('SFC CSS modules', () => {
       modulesOptions: {
         scopeBehaviour: 'global',
         generateScopedName: `[name]__[local]__[hash:base64:5]`,
-        localsConvention: 'camelCaseOnly'
-      }
+        localsConvention: 'camelCaseOnly',
+      },
     })
     expect(result.modules).toBeDefined()
     expect(result.modules!.fooBar).toMatch('__foo-bar__')
@@ -333,11 +333,11 @@ describe('SFC style preprocessors', () => {
       `,
       filename: path.resolve(__dirname, './fixture/test.scss'),
       id: '',
-      preprocessLang: 'scss'
+      preprocessLang: 'scss',
     })
 
     expect([...res.dependencies]).toStrictEqual([
-      path.join(__dirname, './fixture/import.scss')
+      path.join(__dirname, './fixture/import.scss'),
     ])
   })
 
@@ -348,7 +348,7 @@ describe('SFC style preprocessors', () => {
           @mixin square($size) {
             width: $size;
             height: $size;
-          }`
+          }`,
       },
       source: `
         .square {
@@ -357,7 +357,7 @@ describe('SFC style preprocessors', () => {
       `,
       filename: path.resolve(__dirname, './fixture/test.scss'),
       id: '',
-      preprocessLang: 'scss'
+      preprocessLang: 'scss',
     })
 
     expect(res.errors.length).toBe(0)
@@ -380,12 +380,12 @@ describe('SFC style preprocessors', () => {
             width: $size;
             height: $size;
           }`
-        }
+        },
       },
       source,
       filename,
       id: '',
-      preprocessLang: 'scss'
+      preprocessLang: 'scss',
     })
 
     expect(res.errors.length).toBe(0)
index 26a8b573f4e8591bc6b5e819f65a3dfda108fc19..7ab64bb26673bccddc1fdb2c8db5bb19ad621683 100644 (file)
@@ -1,15 +1,15 @@
-import { RawSourceMap, SourceMapConsumer } from 'source-map-js'
+import { type RawSourceMap, SourceMapConsumer } from 'source-map-js'
 import {
+  type SFCTemplateCompileOptions,
   compileTemplate,
-  SFCTemplateCompileOptions
 } from '../src/compileTemplate'
-import { parse, SFCTemplateBlock } from '../src/parse'
+import { type SFCTemplateBlock, parse } from '../src/parse'
 import { compileScript } from '../src'
 
 function compile(opts: Omit<SFCTemplateCompileOptions, 'id'>) {
   return compileTemplate({
     ...opts,
-    id: ''
+    id: '',
   })
 }
 
@@ -50,13 +50,13 @@ body
     p Cool Pug example!
 </template>
 `,
-    { filename: 'example.vue', sourceMap: true }
+    { filename: 'example.vue', sourceMap: true },
   ).descriptor.template as SFCTemplateBlock
 
   const result = compile({
     filename: 'example.vue',
     source: template.content,
-    preprocessLang: template.lang
+    preprocessLang: template.lang,
   })
 
   expect(result.errors.length).toBe(0)
@@ -74,31 +74,31 @@ test('preprocess pug with indents and blank lines', () => {
     p This is the last line.
 </template>
 `,
-    { filename: 'example.vue', sourceMap: true }
+    { filename: 'example.vue', sourceMap: true },
   ).descriptor.template as SFCTemplateBlock
 
   const result = compile({
     filename: 'example.vue',
     source: template.content,
-    preprocessLang: template.lang
+    preprocessLang: template.lang,
   })
 
   expect(result.errors.length).toBe(0)
   expect(result.source).toBe(
-    '<body><h1>The next line contains four spaces.</h1><div class="container"><p>The next line is empty.</p></div><p>This is the last line.</p></body>'
+    '<body><h1>The next line contains four spaces.</h1><div class="container"><p>The next line is empty.</p></div><p>This is the last line.</p></body>',
   )
 })
 
 test('warn missing preprocessor', () => {
   const template = parse(`<template lang="unknownLang">hi</template>\n`, {
     filename: 'example.vue',
-    sourceMap: true
+    sourceMap: true,
   }).descriptor.template as SFCTemplateBlock
 
   const result = compile({
     filename: 'example.vue',
     source: template.content,
-    preprocessLang: template.lang
+    preprocessLang: template.lang,
   })
 
   expect(result.errors.length).toBe(1)
@@ -110,8 +110,8 @@ test('transform asset url options', () => {
   const { code: code1 } = compile({
     ...input,
     transformAssetUrls: {
-      tags: { foo: ['bar'] }
-    }
+      tags: { foo: ['bar'] },
+    },
   })
   expect(code1).toMatch(`import _imports_0 from 'baz'\n`)
 
@@ -119,15 +119,15 @@ test('transform asset url options', () => {
   const { code: code2 } = compile({
     ...input,
     transformAssetUrls: {
-      foo: ['bar']
-    }
+      foo: ['bar'],
+    },
   })
   expect(code2).toMatch(`import _imports_0 from 'baz'\n`)
 
   // false option
   const { code: code3 } = compile({
     ...input,
-    transformAssetUrls: false
+    transformAssetUrls: false,
   })
   expect(code3).not.toMatch(`import _imports_0 from 'baz'\n`)
 })
@@ -139,12 +139,12 @@ test('source map', () => {
   <div><p>{{ foobar }}</p></div>
 </template>
 `,
-    { filename: 'example.vue', sourceMap: true }
+    { filename: 'example.vue', sourceMap: true },
   ).descriptor.template!
 
   const { code, map } = compile({
     filename: 'example.vue',
-    source: template.content
+    source: template.content,
   })
 
   expect(map!.sources).toEqual([`example.vue`])
@@ -152,7 +152,7 @@ test('source map', () => {
 
   const consumer = new SourceMapConsumer(map as RawSourceMap)
   expect(
-    consumer.originalPositionFor(getPositionInCode(code, 'foobar'))
+    consumer.originalPositionFor(getPositionInCode(code, 'foobar')),
   ).toMatchObject(getPositionInCode(template.content, `foobar`))
 })
 
@@ -164,7 +164,7 @@ test('should work w/ AST from descriptor', () => {
   `
   const template = parse(source, {
     filename: 'example.vue',
-    sourceMap: true
+    sourceMap: true,
   }).descriptor.template!
 
   expect(template.ast!.source).toBe(source)
@@ -172,7 +172,7 @@ test('should work w/ AST from descriptor', () => {
   const { code, map } = compile({
     filename: 'example.vue',
     source: template.content,
-    ast: template.ast
+    ast: template.ast,
   })
 
   expect(map!.sources).toEqual([`example.vue`])
@@ -182,14 +182,14 @@ test('should work w/ AST from descriptor', () => {
 
   const consumer = new SourceMapConsumer(map as RawSourceMap)
   expect(
-    consumer.originalPositionFor(getPositionInCode(code, 'foobar'))
+    consumer.originalPositionFor(getPositionInCode(code, 'foobar')),
   ).toMatchObject(getPositionInCode(source, `foobar`))
 
   expect(code).toBe(
     compile({
       filename: 'example.vue',
-      source: template.content
-    }).code
+      source: template.content,
+    }).code,
   )
 })
 
@@ -201,7 +201,7 @@ test('should work w/ AST from descriptor in SSR mode', () => {
   `
   const template = parse(source, {
     filename: 'example.vue',
-    sourceMap: true
+    sourceMap: true,
   }).descriptor.template!
 
   expect(template.ast!.source).toBe(source)
@@ -210,7 +210,7 @@ test('should work w/ AST from descriptor in SSR mode', () => {
     filename: 'example.vue',
     source: '', // make sure it's actually using the AST instead of source
     ast: template.ast,
-    ssr: true
+    ssr: true,
   })
 
   expect(map!.sources).toEqual([`example.vue`])
@@ -220,15 +220,15 @@ test('should work w/ AST from descriptor in SSR mode', () => {
 
   const consumer = new SourceMapConsumer(map as RawSourceMap)
   expect(
-    consumer.originalPositionFor(getPositionInCode(code, 'foobar'))
+    consumer.originalPositionFor(getPositionInCode(code, 'foobar')),
   ).toMatchObject(getPositionInCode(source, `foobar`))
 
   expect(code).toBe(
     compile({
       filename: 'example.vue',
       source: template.content,
-      ssr: true
-    }).code
+      ssr: true,
+    }).code,
   )
 })
 
@@ -240,7 +240,7 @@ test('should not reuse AST if using custom compiler', () => {
   `
   const template = parse(source, {
     filename: 'example.vue',
-    sourceMap: true
+    sourceMap: true,
   }).descriptor.template!
 
   const { code } = compile({
@@ -249,9 +249,9 @@ test('should not reuse AST if using custom compiler', () => {
     ast: template.ast,
     compiler: {
       parse: () => null as any,
-      // @ts-ignore
-      compile: input => ({ code: input })
-    }
+      // @ts-expect-error
+      compile: input => ({ code: input }),
+    },
   })
 
   // what we really want to assert is that the `input` received by the custom
@@ -267,7 +267,7 @@ test('should force re-parse on already transformed AST', () => {
   `
   const template = parse(source, {
     filename: 'example.vue',
-    sourceMap: true
+    sourceMap: true,
   }).descriptor.template!
 
   // force set to empty, if this is reused then it won't generate proper code
@@ -277,14 +277,14 @@ test('should force re-parse on already transformed AST', () => {
   const { code } = compile({
     filename: 'example.vue',
     source: '',
-    ast: template.ast
+    ast: template.ast,
   })
 
   expect(code).toBe(
     compile({
       filename: 'example.vue',
-      source: template.content
-    }).code
+      source: template.content,
+    }).code,
   )
 })
 
@@ -296,7 +296,7 @@ test('should force re-parse with correct compiler in SSR mode', () => {
   `
   const template = parse(source, {
     filename: 'example.vue',
-    sourceMap: true
+    sourceMap: true,
   }).descriptor.template!
 
   // force set to empty, if this is reused then it won't generate proper code
@@ -307,15 +307,15 @@ test('should force re-parse with correct compiler in SSR mode', () => {
     filename: 'example.vue',
     source: '',
     ast: template.ast,
-    ssr: true
+    ssr: true,
   })
 
   expect(code).toBe(
     compile({
       filename: 'example.vue',
       source: template.content,
-      ssr: true
-    }).code
+      ssr: true,
+    }).code,
   )
 })
 
@@ -323,7 +323,7 @@ test('template errors', () => {
   const result = compile({
     filename: 'example.vue',
     source: `<div
-      :bar="a[" v-model="baz"/>`
+      :bar="a[" v-model="baz"/>`,
   })
   expect(result.errors).toMatchSnapshot()
 })
@@ -335,20 +335,20 @@ test('preprocessor errors', () => {
   div(class='class)
 </template>
 `,
-    { filename: 'example.vue', sourceMap: true }
+    { filename: 'example.vue', sourceMap: true },
   ).descriptor.template as SFCTemplateBlock
 
   const result = compile({
     filename: 'example.vue',
     source: template.content,
-    preprocessLang: template.lang
+    preprocessLang: template.lang,
   })
 
   expect(result.errors.length).toBe(1)
   const message = result.errors[0].toString()
   expect(message).toMatch(`Error: example.vue:3:1`)
   expect(message).toMatch(
-    `The end of the string reached with no closing bracket ) found.`
+    `The end of the string reached with no closing bracket ) found.`,
   )
 })
 
@@ -362,7 +362,7 @@ test('should generate the correct imports expression', () => {
         <img src="./bar.svg"/>
       </Comp>
     `,
-    ssr: true
+    ssr: true,
   })
   expect(code).toMatch(`_ssrRenderAttr(\"src\", _imports_1)`)
   expect(code).toMatch(`_createVNode(\"img\", { src: _imports_1 })`)
@@ -384,7 +384,7 @@ test('should not hoist srcset URLs in SSR mode', () => {
       </picture>
     </router-link>
     `,
-    ssr: true
+    ssr: true,
   })
   expect(code).toMatchSnapshot()
 })
@@ -422,7 +422,7 @@ test('prefixing edge case for reused AST', () => {
     id: 'xxx',
     filename: 'test.vue',
     ast: descriptor.template!.ast,
-    source: descriptor.template!.content
+    source: descriptor.template!.content,
   })
   expect(code).not.toMatch(`_ctx.t`)
 })
@@ -436,7 +436,7 @@ interface Pos {
 function getPositionInCode(
   code: string,
   token: string,
-  expectName: string | boolean = false
+  expectName: string | boolean = false,
 ): Pos {
   const generatedOffset = code.indexOf(token)
   let line = 1
@@ -452,7 +452,7 @@ function getPositionInCode(
     column:
       lastNewLinePos === -1
         ? generatedOffset
-        : generatedOffset - lastNewLinePos - 1
+        : generatedOffset - lastNewLinePos - 1,
   }
   if (expectName) {
     res.name = typeof expectName === 'string' ? expectName : token
index d57ad079d24eb06fcd623c5582f3312b122c198d..323c9c7a5993c572e740049f74445c2466b6b03c 100644 (file)
@@ -1,5 +1,5 @@
 import { compileStyle, parse } from '../src'
-import { mockId, compileSFCScript, assertCode } from './utils'
+import { assertCode, compileSFCScript, mockId } from './utils'
 
 describe('CSS vars injection', () => {
   test('generating correct code for nested paths', () => {
@@ -8,7 +8,7 @@ describe('CSS vars injection', () => {
         `<style>div{
           color: v-bind(color);
           font-size: v-bind('font.size');
-        }</style>`
+        }</style>`,
     )
     expect(content).toMatch(`_useCssVars(_ctx => ({
   "${mockId}-color": (_ctx.color),
@@ -32,7 +32,7 @@ describe('CSS vars injection', () => {
           div {
             font-size: v-bind(size);
           }
-        </style>`
+        </style>`,
     )
     expect(content).toMatch(`_useCssVars(_ctx => ({
   "${mockId}-size": (_ctx.size)
@@ -57,7 +57,7 @@ describe('CSS vars injection', () => {
             font-size: v-bind(size);
             border: v-bind(foo);
           }
-        </style>`
+        </style>`,
     )
     // should handle:
     // 1. local const bindings
@@ -69,7 +69,7 @@ describe('CSS vars injection', () => {
   "${mockId}-foo": (__props.foo)
 })`)
     expect(content).toMatch(
-      `import { useCssVars as _useCssVars, unref as _unref } from 'vue'`
+      `import { useCssVars as _useCssVars, unref as _unref } from 'vue'`,
     )
     assertCode(content)
   })
@@ -85,7 +85,7 @@ describe('CSS vars injection', () => {
         font-family: v-bind(フォント);
       }`,
       filename: 'test.css',
-      id: 'data-v-test'
+      id: 'data-v-test',
     })
     expect(code).toMatchInlineSnapshot(`
       ".foo {
@@ -106,7 +106,7 @@ describe('CSS vars injection', () => {
           color: v-bind(color);
           font-size: v-bind('font.size');
         }</style>`,
-      { isProd: true }
+      { isProd: true },
     )
     expect(content).toMatch(`_useCssVars(_ctx => ({
   "4003f1a6": (_ctx.color),
@@ -120,7 +120,7 @@ describe('CSS vars injection', () => {
       }`,
       filename: 'test.css',
       id: mockId,
-      isProd: true
+      isProd: true,
     })
     expect(code).toMatchInlineSnapshot(`
       ".foo {
@@ -135,8 +135,8 @@ describe('CSS vars injection', () => {
       assertCode(
         compileSFCScript(
           `<script>const a = 1</script>\n` +
-            `<style>div{ color: v-bind(color); }</style>`
-        ).content
+            `<style>div{ color: v-bind(color); }</style>`,
+        ).content,
       )
     })
 
@@ -144,8 +144,8 @@ describe('CSS vars injection', () => {
       assertCode(
         compileSFCScript(
           `<script>export default { setup() {} }</script>\n` +
-            `<style>div{ color: v-bind(color); }</style>`
-        ).content
+            `<style>div{ color: v-bind(color); }</style>`,
+        ).content,
       )
     })
 
@@ -155,8 +155,8 @@ describe('CSS vars injection', () => {
           `<script>
           // export default {}
           export default {}
-        </script>\n` + `<style>div{ color: v-bind(color); }</style>`
-        ).content
+        </script>\n` + `<style>div{ color: v-bind(color); }</style>`,
+        ).content,
       )
     })
 
@@ -164,8 +164,8 @@ describe('CSS vars injection', () => {
       assertCode(
         compileSFCScript(
           `<script setup>const color = 'red'</script>\n` +
-            `<style>div{ color: v-bind(color); }</style>`
-        ).content
+            `<style>div{ color: v-bind(color); }</style>`,
+        ).content,
       )
     })
 
@@ -178,7 +178,7 @@ describe('CSS vars injection', () => {
             div{ /* color: v-bind(color); */ width:20; }
             div{ width: v-bind(width); }
             /* comment */
-          </style>`
+          </style>`,
       )
 
       expect(content).not.toMatch(`"${mockId}-color": (color)`)
@@ -198,7 +198,7 @@ describe('CSS vars injection', () => {
           p {
             color: v-bind(color);
           }
-        </style>`
+        </style>`,
       )
       // color should only be injected once, even if it is twice in style
       expect(content).toMatch(`_useCssVars(_ctx => ({
@@ -229,7 +229,7 @@ describe('CSS vars injection', () => {
           p {
             color: v-bind(((a + b)) / (2 * a));
           }
-        </style>`
+        </style>`,
       )
       expect(content).toMatch(`_useCssVars(_ctx => ({
   "${mockId}-foo": (_unref(foo)),
@@ -243,7 +243,7 @@ describe('CSS vars injection', () => {
     // #6022
     test('should be able to parse incomplete expressions', () => {
       const {
-        descriptor: { cssVars }
+        descriptor: { cssVars },
       } = parse(
         `<script setup>let xxx = 1</script>
         <style scoped>
@@ -251,7 +251,7 @@ describe('CSS vars injection', () => {
           font-weight: v-bind("count.toString(");
           font-weight: v-bind(xxx);
         }
-        </style>`
+        </style>`,
       )
       expect(cssVars).toMatchObject([`count.toString(`, `xxx`])
     })
@@ -266,10 +266,10 @@ describe('CSS vars injection', () => {
              label {
                background: v-bind(background);
              }
-             </style>`
+             </style>`,
       )
       expect(content).toMatch(
-        `export default {\n  setup(__props, { expose: __expose }) {\n  __expose();\n\n_useCssVars(_ctx => ({\n  "xxxxxxxx-background": (_unref(background))\n}))`
+        `export default {\n  setup(__props, { expose: __expose }) {\n  __expose();\n\n_useCssVars(_ctx => ({\n  "xxxxxxxx-background": (_unref(background))\n}))`,
       )
     })
 
@@ -287,9 +287,9 @@ describe('CSS vars injection', () => {
           {
             inlineTemplate: true,
             templateOptions: {
-              ssr: true
-            }
-          }
+              ssr: true,
+            },
+          },
         )
         expect(content).not.toMatch(`_useCssVars`)
       })
@@ -308,9 +308,9 @@ describe('CSS vars injection', () => {
           {
             inlineTemplate: false,
             templateOptions: {
-              ssr: true
-            }
-          }
+              ssr: true,
+            },
+          },
         )
         expect(content).not.toMatch(`_useCssVars`)
       })
@@ -333,9 +333,9 @@ describe('CSS vars injection', () => {
             </style>`,
           {
             templateOptions: {
-              ssr: true
-            }
-          }
+              ssr: true,
+            },
+          },
         )
         expect(content).not.toMatch(`_useCssVars`)
       })
index 9b3e3e8a672f045a57a032033c8f470f349abde1..e650a850abd803b8b05942577e41a8c335eb3fda 100644 (file)
@@ -37,7 +37,7 @@ font-weight: bold;
 }
 </style>`
       const {
-        descriptor: { styles }
+        descriptor: { styles },
       } = parse(src)
 
       expect(styles[0].map).not.toBeUndefined()
@@ -69,7 +69,7 @@ font-weight: bold;
       // Padding determines how many blank lines will there be before the style block
       const padding = Math.round(Math.random() * 10)
       const script = parse(
-        `${'\n'.repeat(padding)}<script>\nconsole.log(1)\n }\n</script>\n`
+        `${'\n'.repeat(padding)}<script>\nconsole.log(1)\n }\n</script>\n`,
       ).descriptor.script
 
       expect(script!.map).not.toBeUndefined()
@@ -88,7 +88,7 @@ font-weight: bold;
   h1 foo
     div bar
     span baz
-</template>\n`
+</template>\n`,
       ).descriptor.template!
 
       expect(template.map).not.toBeUndefined()
@@ -103,7 +103,7 @@ font-weight: bold;
     test('custom block', () => {
       const padding = Math.round(Math.random() * 10)
       const custom = parse(
-        `${'\n'.repeat(padding)}<i18n>\n{\n  "greeting": "hello"\n}\n</i18n>\n`
+        `${'\n'.repeat(padding)}<i18n>\n{\n  "greeting": "hello"\n}\n</i18n>\n`,
       ).descriptor.customBlocks[0]
 
       expect(custom!.map).not.toBeUndefined()
@@ -138,42 +138,42 @@ h1 { color: red }
 
     const padTrue = parse(content.trim(), { pad: true }).descriptor
     expect(padTrue.script!.content).toBe(
-      Array(3 + 1).join('//\n') + '\nexport default {}\n'
+      Array(3 + 1).join('//\n') + '\nexport default {}\n',
     )
     expect(padTrue.styles[0].content).toBe(
-      Array(6 + 1).join('\n') + '\nh1 { color: red }\n'
+      Array(6 + 1).join('\n') + '\nh1 { color: red }\n',
     )
     expect(padTrue.customBlocks[0].content).toBe(
-      Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n'
+      Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n',
     )
 
     const padLine = parse(content.trim(), { pad: 'line' }).descriptor
     expect(padLine.script!.content).toBe(
-      Array(3 + 1).join('//\n') + '\nexport default {}\n'
+      Array(3 + 1).join('//\n') + '\nexport default {}\n',
     )
     expect(padLine.styles[0].content).toBe(
-      Array(6 + 1).join('\n') + '\nh1 { color: red }\n'
+      Array(6 + 1).join('\n') + '\nh1 { color: red }\n',
     )
     expect(padLine.customBlocks[0].content).toBe(
-      Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n'
+      Array(9 + 1).join('\n') + '\n{ "greeting": "hello" }\n',
     )
 
     const padSpace = parse(content.trim(), { pad: 'space' }).descriptor
     expect(padSpace.script!.content).toBe(
       `<template>\n<div></div>\n</template>\n<script>`.replace(/./g, ' ') +
-        '\nexport default {}\n'
+        '\nexport default {}\n',
     )
     expect(padSpace.styles[0].content).toBe(
       `<template>\n<div></div>\n</template>\n<script>\nexport default {}\n</script>\n<style>`.replace(
         /./g,
-        ' '
-      ) + '\nh1 { color: red }\n'
+        ' ',
+      ) + '\nh1 { color: red }\n',
     )
     expect(padSpace.customBlocks[0].content).toBe(
       `<template>\n<div></div>\n</template>\n<script>\nexport default {}\n</script>\n<style>\nh1 { color: red }\n</style>\n<i18n>`.replace(
         /./g,
-        ' '
-      ) + '\n{ "greeting": "hello" }\n'
+        ' ',
+      ) + '\n{ "greeting": "hello" }\n',
     )
   })
 
@@ -187,8 +187,8 @@ h1 { color: red }
       end: {
         line: 3,
         column: 1,
-        offset: 10 + content.length
-      }
+        offset: 10 + content.length,
+      },
     })
   })
 
@@ -198,7 +198,7 @@ h1 { color: red }
     expect(descriptor.template!.content).toBeFalsy()
     expect(descriptor.template!.loc).toMatchObject({
       start: { line: 1, column: 12, offset: 11 },
-      end: { line: 1, column: 12, offset: 11 }
+      end: { line: 1, column: 12, offset: 11 },
     })
   })
 
@@ -208,7 +208,7 @@ h1 { color: red }
     expect(descriptor.template!.content).toBeFalsy()
     expect(descriptor.template!.loc).toMatchObject({
       start: { line: 1, column: 11, offset: 10 },
-      end: { line: 1, column: 11, offset: 10 }
+      end: { line: 1, column: 11, offset: 10 },
     })
   })
 
@@ -219,7 +219,7 @@ h1 { color: red }
     expect(parse(`<style> \n\t </style>`).descriptor.styles.length).toBe(0)
     expect(parse(`<custom/>`).descriptor.customBlocks.length).toBe(0)
     expect(
-      parse(`<custom> \n\t </custom>`).descriptor.customBlocks.length
+      parse(`<custom> \n\t </custom>`).descriptor.customBlocks.length,
     ).toBe(0)
   })
 
@@ -239,19 +239,19 @@ h1 { color: red }
     const { descriptor } = parse(
       `<script></script>\n<script setup>\n</script>`,
       {
-        ignoreEmpty: false
-      }
+        ignoreEmpty: false,
+      },
     )
     expect(descriptor.script).toBeTruthy()
     expect(descriptor.script!.loc).toMatchObject({
       start: { line: 1, column: 9, offset: 8 },
-      end: { line: 1, column: 9, offset: 8 }
+      end: { line: 1, column: 9, offset: 8 },
     })
 
     expect(descriptor.scriptSetup).toBeTruthy()
     expect(descriptor.scriptSetup!.loc).toMatchObject({
       start: { line: 2, column: 15, offset: 32 },
-      end: { line: 3, column: 1, offset: 33 }
+      end: { line: 3, column: 1, offset: 33 },
     })
   })
 
@@ -267,7 +267,7 @@ h1 { color: red }
   test('treat empty lang attribute as the html', () => {
     const content = `<div><template v-if="ok">ok</template></div>`
     const { descriptor, errors } = parse(
-      `<template lang="">${content}</template>`
+      `<template lang="">${content}</template>`,
     )
     expect(descriptor.template!.content).toBe(content)
     expect(errors.length).toBe(0)
@@ -277,7 +277,7 @@ h1 { color: red }
   test('template with preprocessor lang should be treated as plain text', () => {
     const content = `p(v-if="1 < 2") test <div/>`
     const { descriptor, errors } = parse(
-      `<template lang="pug">` + content + `</template>`
+      `<template lang="pug">` + content + `</template>`,
     )
     expect(errors.length).toBe(0)
     expect(descriptor.template!.content).toBe(content)
@@ -301,17 +301,17 @@ h1 { color: red }
     expect(parse(`<template>hi</template>`).descriptor.slotted).toBe(false)
     expect(
       parse(`<template>hi</template><style>h1{color:red;}</style>`).descriptor
-        .slotted
+        .slotted,
     ).toBe(false)
     expect(
       parse(
-        `<template>hi</template><style scoped>:slotted(h1){color:red;}</style>`
-      ).descriptor.slotted
+        `<template>hi</template><style scoped>:slotted(h1){color:red;}</style>`,
+      ).descriptor.slotted,
     ).toBe(true)
     expect(
       parse(
-        `<template>hi</template><style scoped>::v-slotted(h1){color:red;}</style>`
-      ).descriptor.slotted
+        `<template>hi</template><style scoped>::v-slotted(h1){color:red;}</style>`,
+      ).descriptor.slotted,
     ).toBe(true)
   })
 
@@ -332,8 +332,8 @@ h1 { color: red }
           options.onError!(new Error('foo') as any)
           return createRoot([])
         },
-        compile: baseCompile
-      }
+        compile: baseCompile,
+      },
     })
     expect(errors.length).toBe(2)
     // error thrown by the custom parse
@@ -344,7 +344,7 @@ h1 { color: red }
 
   test('treat custom blocks as raw text', () => {
     const { errors, descriptor } = parse(
-      `<template><input></template><foo> <-& </foo>`
+      `<template><input></template><foo> <-& </foo>`,
     )
     expect(errors.length).toBe(0)
     expect(descriptor.customBlocks[0].content).toBe(` <-& `)
@@ -358,7 +358,7 @@ h1 { color: red }
     test('should only allow single template element', () => {
       assertWarning(
         parse(`<template><div/></template><template><div/></template>`).errors,
-        `Single file component can contain only one <template> element`
+        `Single file component can contain only one <template> element`,
       )
     })
 
@@ -366,24 +366,24 @@ h1 { color: red }
       assertWarning(
         parse(`<script>console.log(1)</script><script>console.log(1)</script>`)
           .errors,
-        `Single file component can contain only one <script> element`
+        `Single file component can contain only one <script> element`,
       )
     })
 
     test('should only allow single script setup element', () => {
       assertWarning(
         parse(
-          `<script setup>console.log(1)</script><script setup>console.log(1)</script>`
+          `<script setup>console.log(1)</script><script setup>console.log(1)</script>`,
         ).errors,
-        `Single file component can contain only one <script setup> element`
+        `Single file component can contain only one <script setup> element`,
       )
     })
 
     test('should not warn script & script setup', () => {
       expect(
         parse(
-          `<script setup>console.log(1)</script><script>console.log(1)</script>`
-        ).errors.length
+          `<script setup>console.log(1)</script><script>console.log(1)</script>`,
+        ).errors.length,
       ).toBe(0)
     })
 
@@ -391,7 +391,7 @@ h1 { color: red }
     test('should throw error if no <template> or <script> is present', () => {
       assertWarning(
         parse(`import { ref } from 'vue'`).errors,
-        `At least one <template> or <script> is required in a single file component`
+        `At least one <template> or <script> is required in a single file component`,
       )
     })
   })
index bed27e3ae81b2c09c63d5fe5f14a7a8987473ed1..5b30b2062ada396b64d8521166d2567a6d4c15ae 100644 (file)
@@ -11,7 +11,7 @@ describe('compiler sfc: rewriteDefault', () => {
 
   test('rewrite export default', () => {
     expect(
-      rewriteDefault(`export  default {}`, 'script')
+      rewriteDefault(`export  default {}`, 'script'),
     ).toMatchInlineSnapshot(`"const script = {}"`)
   })
 
@@ -27,8 +27,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `const a = 1 \n export { a as b, a as default, a as c}`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const a = 1 
        export { a as b,  a as c}
@@ -38,8 +38,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `const a = 1 \n export { a as b, a as default    , a as c}`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const a = 1 
        export { a as b,  a as c}
@@ -49,8 +49,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `const a = 1 \n export { a as b } \n export { a as default, a as c }`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const a = 1 
        export { a as b } 
@@ -69,7 +69,7 @@ describe('compiler sfc: rewriteDefault', () => {
 
   test('export named default multiline', () => {
     expect(
-      rewriteDefault(`let App = {}\n export {\nApp as default\n}`, '_sfc_main')
+      rewriteDefault(`let App = {}\n export {\nApp as default\n}`, '_sfc_main'),
     ).toMatchInlineSnapshot(`
       "let App = {}
        export {
@@ -84,8 +84,8 @@ describe('compiler sfc: rewriteDefault', () => {
       rewriteDefault(
         `const a = 1 \n export {\n a as b,\n a as default,\n a as c}\n` +
           `// export { myFunction as default }`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const a = 1 
        export {
@@ -100,8 +100,8 @@ describe('compiler sfc: rewriteDefault', () => {
       rewriteDefault(
         `const a = 1 \n export {\n a as b,\n a as default      ,\n a as c}\n` +
           `// export { myFunction as default }`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const a = 1 
        export {
@@ -115,7 +115,7 @@ describe('compiler sfc: rewriteDefault', () => {
 
   test(`export { default } from '...'`, async () => {
     expect(
-      rewriteDefault(`export { default, foo } from './index.js'`, 'script')
+      rewriteDefault(`export { default, foo } from './index.js'`, 'script'),
     ).toMatchInlineSnapshot(`
       "import { default as __VUE_DEFAULT__ } from './index.js'
       export {  foo } from './index.js'
@@ -123,7 +123,7 @@ describe('compiler sfc: rewriteDefault', () => {
     `)
 
     expect(
-      rewriteDefault(`export { default    , foo } from './index.js'`, 'script')
+      rewriteDefault(`export { default    , foo } from './index.js'`, 'script'),
     ).toMatchInlineSnapshot(`
       "import { default as __VUE_DEFAULT__ } from './index.js'
       export {  foo } from './index.js'
@@ -131,7 +131,7 @@ describe('compiler sfc: rewriteDefault', () => {
     `)
 
     expect(
-      rewriteDefault(`export { foo,   default } from './index.js'`, 'script')
+      rewriteDefault(`export { foo,   default } from './index.js'`, 'script'),
     ).toMatchInlineSnapshot(`
       "import { default as __VUE_DEFAULT__ } from './index.js'
       export { foo,    } from './index.js'
@@ -141,8 +141,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `export { foo as default, bar } from './index.js'`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "import { foo as __VUE_DEFAULT__ } from './index.js'
       export {  bar } from './index.js'
@@ -152,8 +152,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `export { foo as default     , bar } from './index.js'`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "import { foo as __VUE_DEFAULT__ } from './index.js'
       export {  bar } from './index.js'
@@ -163,8 +163,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `export { bar,   foo as default } from './index.js'`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "import { foo as __VUE_DEFAULT__ } from './index.js'
       export { bar,    } from './index.js'
@@ -174,8 +174,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `export { foo as default } from './index.js' \n const foo = 1`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "import { foo as __VUE_DEFAULT__ } from './index.js'
       export {  } from './index.js' 
@@ -186,8 +186,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `const a = 1 \nexport { a as default } from 'xxx'`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "import { a as __VUE_DEFAULT__ } from 'xxx'
       const a = 1 
@@ -206,7 +206,10 @@ describe('compiler sfc: rewriteDefault', () => {
 
   test('export default class w/ comments', async () => {
     expect(
-      rewriteDefault(`// export default\nexport default class Foo {}`, 'script')
+      rewriteDefault(
+        `// export default\nexport default class Foo {}`,
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "// export default
        class Foo {}
@@ -218,8 +221,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `export default {}\n` + `// export default class Foo {}`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const script = {}
       // export default class Foo {}"
@@ -230,8 +233,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `/*\nexport default class Foo {}*/\n` + `export default class Bar {}`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "/*
       export default class Foo {}*/
@@ -243,8 +246,8 @@ describe('compiler sfc: rewriteDefault', () => {
   test('@Component\nexport default class', async () => {
     expect(
       rewriteDefault(`@Component\nexport default class Foo {}`, 'script', [
-        'decorators-legacy'
-      ])
+        'decorators-legacy',
+      ]),
     ).toMatchInlineSnapshot(`
       "@Component class Foo {}
       const script = Foo"
@@ -256,8 +259,8 @@ describe('compiler sfc: rewriteDefault', () => {
       rewriteDefault(
         `// export default\n@Component\nexport default class Foo {}`,
         'script',
-        ['decorators-legacy']
-      )
+        ['decorators-legacy'],
+      ),
     ).toMatchInlineSnapshot(`
       "// export default
       @Component class Foo {}
@@ -269,8 +272,8 @@ describe('compiler sfc: rewriteDefault', () => {
     expect(
       rewriteDefault(
         `export default {}\n` + `// @Component\n// export default class Foo {}`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "const script = {}
       // @Component
@@ -283,8 +286,8 @@ describe('compiler sfc: rewriteDefault', () => {
       rewriteDefault(
         `/*\n@Component\nexport default class Foo {}*/\n` +
           `export default class Bar {}`,
-        'script'
-      )
+        'script',
+      ),
     ).toMatchInlineSnapshot(`
       "/*
       @Component
index 44c13e47ea2108742cac0fa7107198b813d6344c..a1f62f43a3c9dfa828554d88173a4279958a13e4 100644 (file)
@@ -1,14 +1,14 @@
 import {
-  generate,
+  type TransformOptions,
   baseParse,
+  generate,
   transform,
-  TransformOptions
 } from '@vue/compiler-core'
 import {
-  transformAssetUrl,
+  type AssetURLOptions,
   createAssetUrlTransformWithOptions,
-  AssetURLOptions,
-  normalizeOptions
+  normalizeOptions,
+  transformAssetUrl,
 } from '../src/template/transformAssetUrl'
 import { transformElement } from '../../compiler-core/src/transforms/transformElement'
 import { transformBind } from '../../compiler-core/src/transforms/vBind'
@@ -17,7 +17,7 @@ import { stringifyStatic } from '../../compiler-dom/src/transforms/stringifyStat
 function compileWithAssetUrls(
   template: string,
   options?: AssetURLOptions,
-  transformOptions?: TransformOptions
+  transformOptions?: TransformOptions,
 ) {
   const ast = baseParse(template)
   const t = options
@@ -26,9 +26,9 @@ function compileWithAssetUrls(
   transform(ast, {
     nodeTransforms: [t, transformElement],
     directiveTransforms: {
-      bind: transformBind
+      bind: transformBind,
     },
-    ...transformOptions
+    ...transformOptions,
   })
   return generate(ast, { mode: 'module' })
 }
@@ -57,8 +57,8 @@ describe('compiler sfc: transform asset url', () => {
         '<use href="~@svg/file.svg#fragment"></use>',
       {},
       {
-        hoistStatic: true
-      }
+        hoistStatic: true,
+      },
     )
     expect(result.code).toMatchSnapshot()
   })
@@ -79,8 +79,8 @@ describe('compiler sfc: transform asset url', () => {
         `<img src="~bar.png"></img>` + // -> still converts to import
         `<img src="@theme/bar.png"></img>`, // -> still converts to import
       {
-        base: '/foo'
-      }
+        base: '/foo',
+      },
     )
     expect(code).toMatch(`import _imports_0 from 'bar.png'`)
     expect(code).toMatch(`import _imports_1 from '@theme/bar.png'`)
@@ -94,8 +94,8 @@ describe('compiler sfc: transform asset url', () => {
         `<img src="https://foo.bar/baz.png"/>` +
         `<img src="//foo.bar/baz.png"/>`,
       {
-        includeAbsolute: true
-      }
+        includeAbsolute: true,
+      },
     )
     expect(code).toMatchSnapshot()
   })
@@ -108,7 +108,7 @@ describe('compiler sfc: transform asset url', () => {
           <circle id="myCircle" cx="0" cy="0" r="5" />
         </defs>
         <use x="5" y="5" xlink:href="#myCircle" />
-      </svg>`
+      </svg>`,
     )
     // should not remove it
     expect(code).toMatch(`"xlink:href": "#myCircle"`)
@@ -116,7 +116,7 @@ describe('compiler sfc: transform asset url', () => {
 
   test('should allow for full base URLs, with paths', () => {
     const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
-      base: 'http://localhost:3000/src/'
+      base: 'http://localhost:3000/src/',
     })
 
     expect(code).toMatchSnapshot()
@@ -124,7 +124,7 @@ describe('compiler sfc: transform asset url', () => {
 
   test('should allow for full base URLs, without paths', () => {
     const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
-      base: 'http://localhost:3000'
+      base: 'http://localhost:3000',
     })
 
     expect(code).toMatchSnapshot()
@@ -132,7 +132,7 @@ describe('compiler sfc: transform asset url', () => {
 
   test('should allow for full base URLs, without port', () => {
     const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
-      base: 'http://localhost'
+      base: 'http://localhost',
     })
 
     expect(code).toMatchSnapshot()
@@ -140,7 +140,7 @@ describe('compiler sfc: transform asset url', () => {
 
   test('should allow for full base URLs, without protocol', () => {
     const { code } = compileWithAssetUrls(`<img src="./logo.png" />`, {
-      base: '//localhost'
+      base: '//localhost',
     })
 
     expect(code).toMatchSnapshot()
@@ -156,12 +156,12 @@ describe('compiler sfc: transform asset url', () => {
         `<img src="./bar.png"/>` +
         `</div>`,
       {
-        includeAbsolute: true
+        includeAbsolute: true,
       },
       {
         hoistStatic: true,
-        transformHoist: stringifyStatic
-      }
+        transformHoist: stringifyStatic,
+      },
     )
     expect(code).toMatch(`_createStaticVNode`)
     expect(code).toMatchSnapshot()
@@ -171,12 +171,12 @@ describe('compiler sfc: transform asset url', () => {
     const { code } = compileWithAssetUrls(
       `<div><img src="/foo bar.png"/></div>`,
       {
-        includeAbsolute: true
+        includeAbsolute: true,
       },
       {
         hoistStatic: true,
-        transformHoist: stringifyStatic
-      }
+        transformHoist: stringifyStatic,
+      },
     )
     expect(code).toMatch(`_createElementVNode`)
     expect(code).toContain(`import _imports_0 from '/foo bar.png'`)
@@ -186,12 +186,12 @@ describe('compiler sfc: transform asset url', () => {
     const { code } = compileWithAssetUrls(
       `<div><img src="./foo bar.png"/></div>`,
       {
-        includeAbsolute: true
+        includeAbsolute: true,
       },
       {
         hoistStatic: true,
-        transformHoist: stringifyStatic
-      }
+        transformHoist: stringifyStatic,
+      },
     )
     expect(code).toMatch(`_createElementVNode`)
     expect(code).toContain(`import _imports_0 from './foo bar.png'`)
index 174e3ca9f79ccc8d295d32c5fad36cf2ec259cfb..491731f94e589640251612191609f7fb7a38dde6 100644 (file)
@@ -1,25 +1,25 @@
 import {
-  generate,
+  type TransformOptions,
   baseParse,
+  generate,
   transform,
-  TransformOptions
 } from '@vue/compiler-core'
 import {
+  createSrcsetTransformWithOptions,
   transformSrcset,
-  createSrcsetTransformWithOptions
 } from '../src/template/transformSrcset'
 import { transformElement } from '../../compiler-core/src/transforms/transformElement'
 import { transformBind } from '../../compiler-core/src/transforms/vBind'
 import {
-  AssetURLOptions,
-  normalizeOptions
+  type AssetURLOptions,
+  normalizeOptions,
 } from '../src/template/transformAssetUrl'
 import { stringifyStatic } from '../../compiler-dom/src/transforms/stringifyStatic'
 
 function compileWithSrcset(
   template: string,
   options?: AssetURLOptions,
-  transformOptions?: TransformOptions
+  transformOptions?: TransformOptions,
 ) {
   const ast = baseParse(template)
   const srcsetTransform = options
@@ -29,9 +29,9 @@ function compileWithSrcset(
     hoistStatic: true,
     nodeTransforms: [srcsetTransform, transformElement],
     directiveTransforms: {
-      bind: transformBind
+      bind: transformBind,
     },
-    ...transformOptions
+    ...transformOptions,
   })
   return generate(ast, { mode: 'module' })
 }
@@ -59,16 +59,16 @@ describe('compiler sfc: transform srcset', () => {
   test('transform srcset w/ base', () => {
     expect(
       compileWithSrcset(src, {
-        base: '/foo'
-      }).code
+        base: '/foo',
+      }).code,
     ).toMatchSnapshot()
   })
 
   test('transform srcset w/ includeAbsolute: true', () => {
     expect(
       compileWithSrcset(src, {
-        includeAbsolute: true
-      }).code
+        includeAbsolute: true,
+      }).code,
     ).toMatchSnapshot()
   })
 
@@ -76,12 +76,12 @@ describe('compiler sfc: transform srcset', () => {
     const code = compileWithSrcset(
       `<div>${src}</div>`,
       {
-        includeAbsolute: true
+        includeAbsolute: true,
       },
       {
         hoistStatic: true,
-        transformHoist: stringifyStatic
-      }
+        transformHoist: stringifyStatic,
+      },
     ).code
     expect(code).toMatch(`_createStaticVNode`)
     expect(code).toMatchSnapshot()
@@ -94,7 +94,7 @@ describe('compiler sfc: transform srcset', () => {
       <img srcset="@/logo.png 1x, ./logo.png 2x"/>
     `,
       { base: '/foo/' },
-      { hoistStatic: true }
+      { hoistStatic: true },
     ).code
     expect(code).toMatchSnapshot()
   })
index 7e20603848c0e786ae11e1b7d7857d7eefb3ce13..b2adbf36c95c7716ac0aab181517389afe734d0f 100644 (file)
@@ -1,7 +1,7 @@
 import {
-  isRelativeUrl,
+  isDataUrl,
   isExternalUrl,
-  isDataUrl
+  isRelativeUrl,
 } from '../src/template/templateUtils'
 
 describe('compiler sfc:templateUtils isRelativeUrl', () => {
index 5fcc6f0b7f88e22c5bc7f747d04fd0eeaff4e342..5498ede2717c75f757b09a52eea3bbd0bfcff196 100644 (file)
@@ -1,8 +1,8 @@
 import {
-  parse,
-  SFCScriptCompileOptions,
+  type SFCParseOptions,
+  type SFCScriptCompileOptions,
   compileScript,
-  SFCParseOptions
+  parse,
 } from '../src'
 import { parse as babelParse } from '@babel/parser'
 
@@ -11,7 +11,7 @@ export const mockId = 'xxxxxxxx'
 export function compileSFCScript(
   src: string,
   options?: Partial<SFCScriptCompileOptions>,
-  parseOptions?: SFCParseOptions
+  parseOptions?: SFCParseOptions,
 ) {
   const { descriptor, errors } = parse(src, parseOptions)
   if (errors.length) {
@@ -19,7 +19,7 @@ export function compileSFCScript(
   }
   return compileScript(descriptor, {
     ...options,
-    id: mockId
+    id: mockId,
   })
 }
 
@@ -30,8 +30,8 @@ export function assertCode(code: string) {
       sourceType: 'module',
       plugins: [
         'typescript',
-        ['importAttributes', { deprecatedAssertSyntax: true }]
-      ]
+        ['importAttributes', { deprecatedAssertSyntax: true }],
+      ],
     })
   } catch (e: any) {
     console.log(code)
index f04b231f6d9e8fe4bea7b8e51e068bb12344d139..38fedcaf85ddecfe5384dc7954e73228d513d51b 100644 (file)
@@ -1,7 +1,7 @@
 import { LRUCache } from 'lru-cache'
 
 export function createCache<T extends {}>(
-  max = 500
+  max = 500,
 ): Map<string, T> | LRUCache<string, T> {
   if (__GLOBAL__ || __ESM_BROWSER__) {
     return new Map<string, T>()
index 5982b02ec34f6ab9a7ccebdaf4ab6b1e1f0ff166..b0b79f8c88d13bee0d8f162d627dc7a889950503 100644 (file)
@@ -2,49 +2,56 @@ import {
   BindingTypes,
   UNREF,
   isFunctionType,
+  unwrapTSNode,
   walkIdentifiers,
-  unwrapTSNode
 } from '@vue/compiler-dom'
-import { DEFAULT_FILENAME, SFCDescriptor, SFCScriptBlock } from './parse'
-import { ParserPlugin } from '@babel/parser'
-import { generateCodeFrame } from '@vue/shared'
 import {
-  Node,
-  Declaration,
-  ObjectPattern,
+  DEFAULT_FILENAME,
+  type SFCDescriptor,
+  type SFCScriptBlock,
+} from './parse'
+import type { ParserPlugin } from '@babel/parser'
+import { generateCodeFrame } from '@vue/shared'
+import type {
   ArrayPattern,
-  Identifier,
+  CallExpression,
+  Declaration,
   ExportSpecifier,
+  Identifier,
+  Node,
+  ObjectPattern,
   Statement,
-  CallExpression
 } from '@babel/types'
 import { walk } from 'estree-walker'
-import { RawSourceMap } from 'source-map-js'
+import type { RawSourceMap } from 'source-map-js'
 import {
+  normalScriptDefaultVar,
   processNormalScript,
-  normalScriptDefaultVar
 } from './script/normalScript'
 import { CSS_VARS_HELPER, genCssVarsCode } from './style/cssVars'
-import { compileTemplate, SFCTemplateCompileOptions } from './compileTemplate'
+import {
+  type SFCTemplateCompileOptions,
+  compileTemplate,
+} from './compileTemplate'
 import { warnOnce } from './warn'
 import { transformDestructuredProps } from './script/definePropsDestructure'
 import { ScriptCompileContext } from './script/context'
 import {
-  processDefineProps,
-  genRuntimeProps,
   DEFINE_PROPS,
-  WITH_DEFAULTS
+  WITH_DEFAULTS,
+  genRuntimeProps,
+  processDefineProps,
 } from './script/defineProps'
 import {
-  processDefineEmits,
+  DEFINE_EMITS,
   genRuntimeEmits,
-  DEFINE_EMITS
+  processDefineEmits,
 } from './script/defineEmits'
 import { DEFINE_EXPOSE, processDefineExpose } from './script/defineExpose'
 import { DEFINE_OPTIONS, processDefineOptions } from './script/defineOptions'
 import { processDefineSlots } from './script/defineSlots'
 import { DEFINE_MODEL, processDefineModel } from './script/defineModel'
-import { isLiteralNode, isCallOf, getImportedName } from './script/utils'
+import { getImportedName, isCallOf, isLiteralNode } from './script/utils'
 import { analyzeScriptBindings } from './script/analyzeScriptBindings'
 import { isImportUsed } from './script/importUsageCheck'
 import { processAwait } from './script/topLevelAwait'
@@ -134,13 +141,13 @@ export interface ImportBinding {
  */
 export function compileScript(
   sfc: SFCDescriptor,
-  options: SFCScriptCompileOptions
+  options: SFCScriptCompileOptions,
 ): SFCScriptBlock {
   if (!options.id) {
     warnOnce(
       `compileScript now requires passing the \`id\` option.\n` +
         `Upgrade your vite or vue-loader version for compatibility with ` +
-        `the latest experimental proposals.`
+        `the latest experimental proposals.`,
     )
   }
 
@@ -164,7 +171,7 @@ export function compileScript(
   if (script && scriptLang !== scriptSetupLang) {
     throw new Error(
       `[@vue/compiler-sfc] <script> and <script setup> must have the same ` +
-        `language type.`
+        `language type.`,
     )
   }
 
@@ -213,7 +220,7 @@ export function compileScript(
     imported: string,
     isType: boolean,
     isFromSetup: boolean,
-    needTemplateUsageCheck: boolean
+    needTemplateUsageCheck: boolean,
   ) {
     // template usage check is only needed in non-inline mode, so we can skip
     // the work if inlineTemplate is true.
@@ -234,7 +241,7 @@ export function compileScript(
       local,
       source,
       isFromSetup,
-      isUsedInTemplate
+      isUsedInTemplate,
     }
   }
 
@@ -249,7 +256,7 @@ export function compileScript(
             `setup() function. If your component options require initialization ` +
             `in the module scope, use a separate normal <script> to export ` +
             `the options instead.`,
-          id
+          id,
         )
       }
     })
@@ -273,7 +280,7 @@ export function compileScript(
               (specifier.type === 'ImportSpecifier' &&
                 specifier.importKind === 'type'),
             false,
-            !options.inlineTemplate
+            !options.inlineTemplate,
           )
         }
       }
@@ -299,7 +306,7 @@ export function compileScript(
             : current.start! + startOffset,
           next && !removeLeft
             ? next.start! + startOffset
-            : current.end! + startOffset
+            : current.end! + startOffset,
         )
       }
 
@@ -316,7 +323,7 @@ export function compileScript(
             imported === DEFINE_EXPOSE)
         ) {
           warnOnce(
-            `\`${imported}\` is a compiler macro and no longer needs to be imported.`
+            `\`${imported}\` is a compiler macro and no longer needs to be imported.`,
           )
           removeSpecifier(i)
         } else if (existing) {
@@ -326,7 +333,7 @@ export function compileScript(
           } else {
             ctx.error(
               `different imports aliased to same local name.`,
-              specifier
+              specifier,
             )
           }
         } else {
@@ -338,7 +345,7 @@ export function compileScript(
               (specifier.type === 'ImportSpecifier' &&
                 specifier.importKind === 'type'),
             true,
-            !options.inlineTemplate
+            !options.inlineTemplate,
           )
         }
       }
@@ -403,7 +410,8 @@ export function compileScript(
         ctx.s.overwrite(start, end, `const ${normalScriptDefaultVar} = `)
       } else if (node.type === 'ExportNamedDeclaration') {
         const defaultSpecifier = node.specifiers.find(
-          s => s.exported.type === 'Identifier' && s.exported.name === 'default'
+          s =>
+            s.exported.type === 'Identifier' && s.exported.name === 'default',
         ) as ExportSpecifier
         if (defaultSpecifier) {
           defaultExport = node
@@ -411,12 +419,12 @@ export function compileScript(
           if (node.specifiers.length > 1) {
             ctx.s.remove(
               defaultSpecifier.start! + scriptStartOffset!,
-              defaultSpecifier.end! + scriptStartOffset!
+              defaultSpecifier.end! + scriptStartOffset!,
             )
           } else {
             ctx.s.remove(
               node.start! + scriptStartOffset!,
-              node.end! + scriptStartOffset!
+              node.end! + scriptStartOffset!,
             )
           }
           if (node.source) {
@@ -424,14 +432,14 @@ export function compileScript(
             // rewrite to `import { x as __default__ } from './x'` and
             // add to top
             ctx.s.prepend(
-              `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'\n`
+              `import { ${defaultSpecifier.local.name} as ${normalScriptDefaultVar} } from '${node.source.value}'\n`,
             )
           } else {
             // export { x as default }
             // rewrite to `const __default__ = x` and move to end
             ctx.s.appendLeft(
               scriptEndOffset!,
-              `\nconst ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}\n`
+              `\nconst ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}\n`,
             )
           }
         }
@@ -441,7 +449,7 @@ export function compileScript(
             node.declaration,
             scriptBindings,
             vueImportAliases,
-            hoistStatic
+            hoistStatic,
           )
         }
       } else if (
@@ -456,7 +464,7 @@ export function compileScript(
           node,
           scriptBindings,
           vueImportAliases,
-          hoistStatic
+          hoistStatic,
         )
       }
     }
@@ -491,7 +499,7 @@ export function compileScript(
         ctx.s.overwrite(
           callee.start! + startOffset,
           callee.end! + startOffset,
-          '__expose'
+          '__expose',
         )
       } else {
         processDefineModel(ctx, expr)
@@ -510,7 +518,7 @@ export function compileScript(
           if (processDefineOptions(ctx, init)) {
             ctx.error(
               `${DEFINE_OPTIONS}() has no returning value, it cannot be assigned.`,
-              node
+              node,
             )
           }
 
@@ -548,7 +556,7 @@ export function compileScript(
             ctx.s.overwrite(
               startOffset + init.start!,
               startOffset + init.end!,
-              '__emit'
+              '__emit',
             )
           } else {
             lastNonRemoved = i
@@ -571,7 +579,7 @@ export function compileScript(
         node,
         setupBindings,
         vueImportAliases,
-        hoistStatic
+        hoistStatic,
       )
     }
 
@@ -613,13 +621,13 @@ export function compileScript(
               ctx,
               child,
               needsSemi,
-              parent!.type === 'ExpressionStatement'
+              parent!.type === 'ExpressionStatement',
             )
           }
         },
         exit(node: Node) {
           if (node.type === 'BlockStatement') scope.pop()
-        }
+        },
       })
     }
 
@@ -632,7 +640,7 @@ export function compileScript(
         `<script setup> cannot contain ES module exports. ` +
           `If you are using a previous version of <script setup>, please ` +
           `consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.`,
-        node
+        node,
       )
     }
 
@@ -689,7 +697,7 @@ export function compileScript(
     Object.assign(ctx.bindingMetadata, analyzeScriptBindings(scriptAst.body))
   }
   for (const [key, { isType, imported, source }] of Object.entries(
-    ctx.userImports
+    ctx.userImports,
   )) {
     if (isType) continue
     ctx.bindingMetadata[key] =
@@ -726,8 +734,8 @@ export function compileScript(
         sfc.cssVars,
         ctx.bindingMetadata,
         scopeId,
-        !!options.isProd
-      )}\n`
+        !!options.isProd,
+      )}\n`,
     )
   }
 
@@ -748,19 +756,19 @@ export function compileScript(
         startOffset + ctx.propsCall!.start!,
         startOffset + ctx.propsCall!.end!,
         `${ctx.helper(`createPropsRestProxy`)}(__props, ${JSON.stringify(
-          Object.keys(ctx.propsDestructuredBindings)
-        )})`
+          Object.keys(ctx.propsDestructuredBindings),
+        )})`,
       )
       ctx.s.overwrite(
         startOffset + ctx.propsDestructureDecl!.start!,
         startOffset + ctx.propsDestructureDecl!.end!,
-        ctx.propsDestructureRestId
+        ctx.propsDestructureRestId,
       )
     } else if (!ctx.propsDestructureDecl) {
       ctx.s.overwrite(
         startOffset + ctx.propsCall!.start!,
         startOffset + ctx.propsCall!.end!,
-        '__props'
+        '__props',
       )
     }
   }
@@ -792,7 +800,7 @@ export function compileScript(
     // return bindings from script and script setup
     const allBindings: Record<string, any> = {
       ...scriptBindings,
-      ...setupBindings
+      ...setupBindings,
     }
     for (const key in ctx.userImports) {
       if (
@@ -846,8 +854,8 @@ export function compileScript(
             options.templateOptions.compilerOptions),
           inline: true,
           isTS: ctx.isTS,
-          bindingMetadata: ctx.bindingMetadata
-        }
+          bindingMetadata: ctx.bindingMetadata,
+        },
       })
       if (tips.length) {
         tips.forEach(warnOnce)
@@ -864,7 +872,7 @@ export function compileScript(
             generateCodeFrame(
               source,
               err.loc.start.offset,
-              err.loc.end.offset
+              err.loc.end.offset,
             ) +
             `\n`
         }
@@ -893,7 +901,7 @@ export function compileScript(
       `\nconst __returned__ = ${returned}\n` +
         `Object.defineProperty(__returned__, '__isScriptSetup', { enumerable: false, value: true })\n` +
         `return __returned__` +
-        `\n}\n\n`
+        `\n}\n\n`,
     )
   } else {
     ctx.s.appendRight(endOffset, `\nreturn ${returned}\n}\n\n`)
@@ -945,10 +953,10 @@ export function compileScript(
     ctx.s.prependLeft(
       startOffset,
       `\n${genDefaultAs} /*#__PURE__*/${ctx.helper(
-        `defineComponent`
+        `defineComponent`,
       )}({${def}${runtimeOptions}\n  ${
         hasAwait ? `async ` : ``
-      }setup(${args}) {\n${exposeCall}`
+      }setup(${args}) {\n${exposeCall}`,
     )
     ctx.s.appendRight(endOffset, `})`)
   } else {
@@ -960,14 +968,14 @@ export function compileScript(
         `\n${genDefaultAs} /*#__PURE__*/Object.assign(${
           defaultExport ? `${normalScriptDefaultVar}, ` : ''
         }${definedOptions ? `${definedOptions}, ` : ''}{${runtimeOptions}\n  ` +
-          `${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`
+          `${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`,
       )
       ctx.s.appendRight(endOffset, `})`)
     } else {
       ctx.s.prependLeft(
         startOffset,
         `\n${genDefaultAs} {${runtimeOptions}\n  ` +
-          `${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`
+          `${hasAwait ? `async ` : ``}setup(${args}) {\n${exposeCall}`,
       )
       ctx.s.appendRight(endOffset, `}`)
     }
@@ -978,7 +986,7 @@ export function compileScript(
     ctx.s.prepend(
       `import { ${[...ctx.helperImports]
         .map(h => `${h} as _${h}`)
-        .join(', ')} } from 'vue'\n`
+        .join(', ')} } from 'vue'\n`,
     )
   }
 
@@ -992,19 +1000,19 @@ export function compileScript(
         ? (ctx.s.generateMap({
             source: filename,
             hires: true,
-            includeContent: true
+            includeContent: true,
           }) as unknown as RawSourceMap)
         : undefined,
     scriptAst: scriptAst?.body,
     scriptSetupAst: scriptSetupAst?.body,
-    deps: ctx.deps ? [...ctx.deps] : undefined
+    deps: ctx.deps ? [...ctx.deps] : undefined,
   }
 }
 
 function registerBinding(
   bindings: Record<string, BindingTypes>,
   node: Identifier,
-  type: BindingTypes
+  type: BindingTypes,
 ) {
   bindings[node.name] = type
 }
@@ -1014,7 +1022,7 @@ function walkDeclaration(
   node: Declaration,
   bindings: Record<string, BindingTypes>,
   userImportAliases: Record<string, string>,
-  hoistStatic: boolean
+  hoistStatic: boolean,
 ): boolean {
   let isAllLiteral = false
 
@@ -1023,7 +1031,7 @@ function walkDeclaration(
     isAllLiteral =
       isConst &&
       node.declarations.every(
-        decl => decl.id.type === 'Identifier' && isStaticNode(decl.init!)
+        decl => decl.id.type === 'Identifier' && isStaticNode(decl.init!),
       )
 
     // export const foo = ...
@@ -1033,7 +1041,7 @@ function walkDeclaration(
         isConst &&
         isCallOf(
           init,
-          c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS
+          c => c === DEFINE_PROPS || c === DEFINE_EMITS || c === WITH_DEFAULTS,
         )
       )
       if (id.type === 'Identifier') {
@@ -1068,7 +1076,7 @@ function walkDeclaration(
                 m === userImportAliases['shallowRef'] ||
                 m === userImportAliases['customRef'] ||
                 m === userImportAliases['toRef'] ||
-                m === DEFINE_MODEL
+                m === DEFINE_MODEL,
             )
           ) {
             bindingType = BindingTypes.SETUP_REF
@@ -1092,7 +1100,7 @@ function walkDeclaration(
     }
   } else if (node.type === 'TSEnumDeclaration') {
     isAllLiteral = node.members.every(
-      member => !member.initializer || isStaticNode(member.initializer)
+      member => !member.initializer || isStaticNode(member.initializer),
     )
     bindings[node.id!.name] = isAllLiteral
       ? BindingTypes.LITERAL_CONST
@@ -1113,7 +1121,7 @@ function walkObjectPattern(
   node: ObjectPattern,
   bindings: Record<string, BindingTypes>,
   isConst: boolean,
-  isDefineCall = false
+  isDefineCall = false,
 ) {
   for (const p of node.properties) {
     if (p.type === 'ObjectProperty') {
@@ -1141,7 +1149,7 @@ function walkArrayPattern(
   node: ArrayPattern,
   bindings: Record<string, BindingTypes>,
   isConst: boolean,
-  isDefineCall = false
+  isDefineCall = false,
 ) {
   for (const e of node.elements) {
     e && walkPattern(e, bindings, isConst, isDefineCall)
@@ -1152,7 +1160,7 @@ function walkPattern(
   node: Node,
   bindings: Record<string, BindingTypes>,
   isConst: boolean,
-  isDefineCall = false
+  isDefineCall = false,
 ) {
   if (node.type === 'Identifier') {
     const type = isDefineCall
@@ -1201,7 +1209,7 @@ function canNeverBeRef(node: Node, userReactiveImport?: string): boolean {
     case 'SequenceExpression':
       return canNeverBeRef(
         node.expressions[node.expressions.length - 1],
-        userReactiveImport
+        userReactiveImport,
       )
     default:
       if (isLiteralNode(node)) {
index 47f90e824d682275e9de6c397ed8ba8c10ed62aa..4390014e89e2980a55f1f3ab38edebaae59c3d6f 100644 (file)
@@ -1,19 +1,19 @@
 import postcss, {
-  ProcessOptions,
-  Result,
-  SourceMap,
-  Message,
-  LazyResult
+  type LazyResult,
+  type Message,
+  type ProcessOptions,
+  type Result,
+  type SourceMap,
 } from 'postcss'
 import trimPlugin from './style/pluginTrim'
 import scopedPlugin from './style/pluginScoped'
 import {
+  type PreprocessLang,
+  type StylePreprocessor,
+  type StylePreprocessorResults,
   processors,
-  StylePreprocessor,
-  StylePreprocessorResults,
-  PreprocessLang
 } from './style/preprocessors'
-import { RawSourceMap } from 'source-map-js'
+import type { RawSourceMap } from 'source-map-js'
 import { cssVarsPlugin } from './style/cssVars'
 import postcssModules from 'postcss-modules'
 
@@ -69,25 +69,25 @@ export interface SFCStyleCompileResults {
 }
 
 export function compileStyle(
-  options: SFCStyleCompileOptions
+  options: SFCStyleCompileOptions,
 ): SFCStyleCompileResults {
   return doCompileStyle({
     ...options,
-    isAsync: false
+    isAsync: false,
   }) as SFCStyleCompileResults
 }
 
 export function compileStyleAsync(
-  options: SFCAsyncStyleCompileOptions
+  options: SFCAsyncStyleCompileOptions,
 ): Promise<SFCStyleCompileResults> {
   return doCompileStyle({
     ...options,
-    isAsync: true
+    isAsync: true,
   }) as Promise<SFCStyleCompileResults>
 }
 
 export function doCompileStyle(
-  options: SFCAsyncStyleCompileOptions
+  options: SFCAsyncStyleCompileOptions,
 ): SFCStyleCompileResults | Promise<SFCStyleCompileResults> {
   const {
     filename,
@@ -99,7 +99,7 @@ export function doCompileStyle(
     modulesOptions = {},
     preprocessLang,
     postcssOptions,
-    postcssPlugins
+    postcssPlugins,
   } = options
   const preprocessor = preprocessLang && processors[preprocessLang]
   const preProcessedSource = preprocessor && preprocess(options, preprocessor)
@@ -123,12 +123,12 @@ export function doCompileStyle(
   if (modules) {
     if (__GLOBAL__ || __ESM_BROWSER__) {
       throw new Error(
-        '[@vue/compiler-sfc] `modules` option is not supported in the browser build.'
+        '[@vue/compiler-sfc] `modules` option is not supported in the browser build.',
       )
     }
     if (!options.isAsync) {
       throw new Error(
-        '[@vue/compiler-sfc] `modules` option can only be used with compileStyleAsync().'
+        '[@vue/compiler-sfc] `modules` option can only be used with compileStyleAsync().',
       )
     }
     plugins.push(
@@ -136,21 +136,21 @@ export function doCompileStyle(
         ...modulesOptions,
         getJSON: (_cssFileName: string, json: Record<string, string>) => {
           cssModules = json
-        }
-      })
+        },
+      }),
     )
   }
 
   const postCSSOptions: ProcessOptions = {
     ...postcssOptions,
     to: filename,
-    from: filename
+    from: filename,
   }
   if (map) {
     postCSSOptions.map = {
       inline: false,
       annotation: false,
-      prev: map
+      prev: map,
     }
   }
 
@@ -159,7 +159,7 @@ export function doCompileStyle(
   let outMap: SourceMap | undefined
   // stylus output include plain css. so need remove the repeat item
   const dependencies = new Set(
-    preProcessedSource ? preProcessedSource.dependencies : []
+    preProcessedSource ? preProcessedSource.dependencies : [],
   )
   // sass has filename self when provided filename option
   dependencies.delete(filename)
@@ -191,14 +191,14 @@ export function doCompileStyle(
           errors,
           modules: cssModules,
           rawResult: result,
-          dependencies: recordPlainCssDependencies(result.messages)
+          dependencies: recordPlainCssDependencies(result.messages),
         }))
         .catch(error => ({
           code: '',
           map: undefined,
           errors: [...errors, error],
           rawResult: undefined,
-          dependencies
+          dependencies,
         }))
     }
 
@@ -215,19 +215,19 @@ export function doCompileStyle(
     map: outMap && outMap.toJSON(),
     errors,
     rawResult: result,
-    dependencies
+    dependencies,
   }
 }
 
 function preprocess(
   options: SFCStyleCompileOptions,
-  preprocessor: StylePreprocessor
+  preprocessor: StylePreprocessor,
 ): StylePreprocessorResults {
   if ((__ESM_BROWSER__ || __GLOBAL__) && !options.preprocessCustomRequire) {
     throw new Error(
       `[@vue/compiler-sfc] Style preprocessing in the browser build must ` +
         `provide the \`preprocessCustomRequire\` option to return the in-browser ` +
-        `version of the preprocessor.`
+        `version of the preprocessor.`,
     )
   }
 
@@ -236,8 +236,8 @@ function preprocess(
     options.inMap || options.map,
     {
       filename: options.filename,
-      ...options.preprocessOptions
+      ...options.preprocessOptions,
     },
-    options.preprocessCustomRequire
+    options.preprocessCustomRequire,
   )
 }
index e5f38c5baca6f2ced31c31d4274f10bc29403038..019aa5b0d65bd60c064e3a55e4429be99ed69637 100644 (file)
@@ -1,29 +1,29 @@
 import {
-  CompilerOptions,
-  CodegenResult,
-  CompilerError,
-  NodeTransform,
-  ParserOptions,
-  RootNode,
+  type CodegenResult,
+  type CompilerError,
+  type CompilerOptions,
+  type ElementNode,
+  type NodeTransform,
   NodeTypes,
-  ElementNode,
-  createRoot
+  type ParserOptions,
+  type RootNode,
+  createRoot,
 } from '@vue/compiler-core'
 import {
+  type RawSourceMap,
   SourceMapConsumer,
   SourceMapGenerator,
-  RawSourceMap
 } from 'source-map-js'
 import {
-  transformAssetUrl,
-  AssetURLOptions,
+  type AssetURLOptions,
+  type AssetURLTagConfig,
   createAssetUrlTransformWithOptions,
-  AssetURLTagConfig,
-  normalizeOptions
+  normalizeOptions,
+  transformAssetUrl,
 } from './template/transformAssetUrl'
 import {
+  createSrcsetTransformWithOptions,
   transformSrcset,
-  createSrcsetTransformWithOptions
 } from './template/transformSrcset'
 import { generateCodeFrame, isObject } from '@vue/shared'
 import * as CompilerDOM from '@vue/compiler-dom'
@@ -79,13 +79,13 @@ interface PreProcessor {
   render(
     source: string,
     options: any,
-    cb: (err: Error | null, res: string) => void
+    cb: (err: Error | null, res: string) => void,
   ): void
 }
 
 function preprocess(
   { source, filename, preprocessOptions }: SFCTemplateCompileOptions,
-  preprocessor: PreProcessor
+  preprocessor: PreProcessor,
 ): string {
   // Consolidate exposes a callback based API, but the callback is in fact
   // called synchronously for most templating engines. In our case, we have to
@@ -100,7 +100,7 @@ function preprocess(
     (_err, _res) => {
       if (_err) err = _err
       res = _res
-    }
+    },
   )
 
   if (err) throw err
@@ -108,7 +108,7 @@ function preprocess(
 }
 
 export function compileTemplate(
-  options: SFCTemplateCompileOptions
+  options: SFCTemplateCompileOptions,
 ): SFCTemplateCompileResults {
   const { preprocessLang, preprocessCustomRequire } = options
 
@@ -120,7 +120,7 @@ export function compileTemplate(
     throw new Error(
       `[@vue/compiler-sfc] Template preprocessing in the browser build must ` +
         `provide the \`preprocessCustomRequire\` option to return the in-browser ` +
-        `version of the preprocessor in the shape of { render(): string }.`
+        `version of the preprocessor in the shape of { render(): string }.`,
     )
   }
 
@@ -136,14 +136,14 @@ export function compileTemplate(
       return doCompileTemplate({
         ...options,
         source: preprocess(options, preprocessor),
-        ast: undefined // invalidate AST if template goes through preprocessor
+        ast: undefined, // invalidate AST if template goes through preprocessor
       })
     } catch (e: any) {
       return {
         code: `export default function render() {}`,
         source: options.source,
         tips: [],
-        errors: [e]
+        errors: [e],
       }
     }
   } else if (preprocessLang) {
@@ -151,11 +151,11 @@ export function compileTemplate(
       code: `export default function render() {}`,
       source: options.source,
       tips: [
-        `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`
+        `Component ${options.filename} uses lang ${preprocessLang} for template. Please install the language preprocessor.`,
       ],
       errors: [
-        `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`
-      ]
+        `Component ${options.filename} uses lang ${preprocessLang} for template, however it is not installed.`,
+      ],
     }
   } else {
     return doCompileTemplate(options)
@@ -175,7 +175,7 @@ function doCompileTemplate({
   isProd = false,
   compiler,
   compilerOptions = {},
-  transformAssetUrls
+  transformAssetUrls,
 }: SFCTemplateCompileOptions): SFCTemplateCompileResults {
   const errors: CompilerError[] = []
   const warnings: CompilerError[] = []
@@ -185,7 +185,7 @@ function doCompileTemplate({
     const assetOptions = normalizeOptions(transformAssetUrls)
     nodeTransforms = [
       createAssetUrlTransformWithOptions(assetOptions),
-      createSrcsetTransformWithOptions(assetOptions)
+      createSrcsetTransformWithOptions(assetOptions),
     ]
   } else if (transformAssetUrls !== false) {
     nodeTransforms = [transformAssetUrl, transformSrcset]
@@ -194,7 +194,7 @@ function doCompileTemplate({
   if (ssr && !ssrCssVars) {
     warnOnce(
       `compileTemplate is called with \`ssr: true\` but no ` +
-        `corresponding \`cssVars\` option.\`.`
+        `corresponding \`cssVars\` option.\`.`,
     )
   }
   if (!id) {
@@ -220,10 +220,10 @@ function doCompileTemplate({
     // the AST location info to be relative to the entire SFC.
     const newAST = (ssr ? CompilerDOM : compiler).parse(inAST.source, {
       parseMode: 'sfc',
-      onError: e => errors.push(e)
+      onError: e => errors.push(e),
     })
     const template = newAST.children.find(
-      node => node.type === NodeTypes.ELEMENT && node.tag === 'template'
+      node => node.type === NodeTypes.ELEMENT && node.tag === 'template',
     ) as ElementNode
     inAST = createRoot(template.children, inAST.source)
   }
@@ -245,7 +245,7 @@ function doCompileTemplate({
     nodeTransforms: nodeTransforms.concat(compilerOptions.nodeTransforms || []),
     filename,
     onError: e => errors.push(e),
-    onWarn: w => warnings.push(w)
+    onWarn: w => warnings.push(w),
   })
 
   // inMap should be the map produced by ./parse.ts which is a simple line-only
@@ -266,7 +266,7 @@ function doCompileTemplate({
       msg += `\n${generateCodeFrame(
         inAST?.source || source,
         w.loc.start.offset,
-        w.loc.end.offset
+        w.loc.end.offset,
       )}`
     }
     return msg
@@ -290,7 +290,7 @@ function mapLines(oldMap: RawSourceMap, newMap: RawSourceMap): RawSourceMap {
 
     const origPosInOldMap = oldMapConsumer.originalPositionFor({
       line: m.originalLine,
-      column: m.originalColumn
+      column: m.originalColumn,
     })
 
     if (origPosInOldMap.source == null) {
@@ -300,16 +300,16 @@ function mapLines(oldMap: RawSourceMap, newMap: RawSourceMap): RawSourceMap {
     mergedMapGenerator.addMapping({
       generated: {
         line: m.generatedLine,
-        column: m.generatedColumn
+        column: m.generatedColumn,
       },
       original: {
         line: origPosInOldMap.line, // map line
         // use current column, since the oldMap produced by @vue/compiler-sfc
         // does not
-        column: m.originalColumn
+        column: m.originalColumn,
       },
       source: origPosInOldMap.source,
-      name: origPosInOldMap.name
+      name: origPosInOldMap.name,
     })
   })
 
@@ -331,7 +331,7 @@ function mapLines(oldMap: RawSourceMap, newMap: RawSourceMap): RawSourceMap {
 function patchErrors(
   errors: CompilerError[],
   source: string,
-  inMap: RawSourceMap
+  inMap: RawSourceMap,
 ) {
   const originalSource = inMap.sourcesContent![0]
   const offset = originalSource.indexOf(source)
index 98b01c4bec173298760772df220dd3e2fcf48ca1..9661b7f79633dff9762568696142cc199fb29b0f 100644 (file)
@@ -8,19 +8,19 @@ export { compileScript } from './compileScript'
 export { rewriteDefault, rewriteDefaultAST } from './rewriteDefault'
 export { resolveTypeElements, inferRuntimeType } from './script/resolveType'
 
-import { SFCParseResult, parseCache as _parseCache } from './parse'
+import { type SFCParseResult, parseCache as _parseCache } from './parse'
 // #9521 export parseCache as a simple map to avoid exposing LRU types
 export const parseCache = _parseCache as Map<string, SFCParseResult>
 
 // error messages
 import {
+  DOMErrorMessages,
   errorMessages as coreErrorMessages,
-  DOMErrorMessages
 } from '@vue/compiler-dom'
 
 export const errorMessages = {
   ...coreErrorMessages,
-  ...DOMErrorMessages
+  ...DOMErrorMessages,
 }
 
 // Utilities
@@ -36,7 +36,7 @@ export {
   walkIdentifiers,
   extractIdentifiers,
   isInDestructureAssignment,
-  isStaticProperty
+  isStaticProperty,
 } from '@vue/compiler-core'
 
 // Internals for type resolution
@@ -52,33 +52,33 @@ export type {
   SFCBlock,
   SFCTemplateBlock,
   SFCScriptBlock,
-  SFCStyleBlock
+  SFCStyleBlock,
 } from './parse'
 export type {
   TemplateCompiler,
   SFCTemplateCompileOptions,
-  SFCTemplateCompileResults
+  SFCTemplateCompileResults,
 } from './compileTemplate'
 export type {
   SFCStyleCompileOptions,
   SFCAsyncStyleCompileOptions,
-  SFCStyleCompileResults
+  SFCStyleCompileResults,
 } from './compileStyle'
 export type { SFCScriptCompileOptions } from './compileScript'
 export type { ScriptCompileContext } from './script/context'
 export type {
   TypeResolveContext,
   SimpleTypeResolveOptions,
-  SimpleTypeResolveContext
+  SimpleTypeResolveContext,
 } from './script/resolveType'
 export type {
   AssetURLOptions,
-  AssetURLTagConfig
+  AssetURLTagConfig,
 } from './template/transformAssetUrl'
 export type {
   CompilerOptions,
   CompilerError,
-  BindingMetadata
+  BindingMetadata,
 } from '@vue/compiler-core'
 
 /**
index a7d36fded43c0efcb1a22f5b21394ce93159d572..0c891e8215909e7975e508946f97fe1d21a7dd08 100644 (file)
@@ -1,18 +1,18 @@
 import {
+  type BindingMetadata,
+  type CompilerError,
+  type ElementNode,
   NodeTypes,
-  ElementNode,
-  SourceLocation,
-  CompilerError,
-  BindingMetadata,
-  RootNode,
-  createRoot
+  type RootNode,
+  type SourceLocation,
+  createRoot,
 } from '@vue/compiler-core'
 import * as CompilerDOM from '@vue/compiler-dom'
-import { RawSourceMap, SourceMapGenerator } from 'source-map-js'
-import { TemplateCompiler } from './compileTemplate'
+import { type RawSourceMap, SourceMapGenerator } from 'source-map-js'
+import type { TemplateCompiler } from './compileTemplate'
 import { parseCssVars } from './style/cssVars'
 import { createCache } from './cache'
-import { ImportBinding } from './compileScript'
+import type { ImportBinding } from './compileScript'
 import { isImportUsed } from './script/importUsageCheck'
 
 export const DEFAULT_FILENAME = 'anonymous.vue'
@@ -106,8 +106,8 @@ export function parse(
     pad = false,
     ignoreEmpty = true,
     compiler = CompilerDOM,
-    parseExpressions = true
-  }: SFCParseOptions = {}
+    parseExpressions = true,
+  }: SFCParseOptions = {},
 ): SFCParseResult {
   const sourceKey =
     source + sourceMap + filename + sourceRoot + pad + compiler.parse
@@ -126,7 +126,7 @@ export function parse(
     customBlocks: [],
     cssVars: [],
     slotted: false,
-    shouldForceReload: prevImports => hmrShouldReload(prevImports, descriptor)
+    shouldForceReload: prevImports => hmrShouldReload(prevImports, descriptor),
   }
 
   const errors: (CompilerError | SyntaxError)[] = []
@@ -135,7 +135,7 @@ export function parse(
     prefixIdentifiers: parseExpressions,
     onError: e => {
       errors.push(e)
-    }
+    },
   })
   ast.children.forEach(node => {
     if (node.type !== NodeTypes.ELEMENT) {
@@ -157,7 +157,7 @@ export function parse(
           const templateBlock = (descriptor.template = createBlock(
             node,
             source,
-            false
+            false,
           ) as SFCTemplateBlock)
 
           if (!templateBlock.attrs.src) {
@@ -170,10 +170,10 @@ export function parse(
               `<template functional> is no longer supported in Vue 3, since ` +
                 `functional components no longer have significant performance ` +
                 `difference from stateful ones. Just use a normal <template> ` +
-                `instead.`
+                `instead.`,
             ) as CompilerError
             err.loc = node.props.find(
-              p => p.type === NodeTypes.ATTRIBUTE && p.name === 'functional'
+              p => p.type === NodeTypes.ATTRIBUTE && p.name === 'functional',
             )!.loc
             errors.push(err)
           }
@@ -200,8 +200,8 @@ export function parse(
           errors.push(
             new SyntaxError(
               `<style vars> has been replaced by a new proposal: ` +
-                `https://github.com/vuejs/rfcs/pull/231`
-            )
+                `https://github.com/vuejs/rfcs/pull/231`,
+            ),
           )
         }
         descriptor.styles.push(styleBlock)
@@ -214,8 +214,8 @@ export function parse(
   if (!descriptor.template && !descriptor.script && !descriptor.scriptSetup) {
     errors.push(
       new SyntaxError(
-        `At least one <template> or <script> is required in a single file component.`
-      )
+        `At least one <template> or <script> is required in a single file component.`,
+      ),
     )
   }
   if (descriptor.scriptSetup) {
@@ -223,8 +223,8 @@ export function parse(
       errors.push(
         new SyntaxError(
           `<script setup> cannot use the "src" attribute because ` +
-            `its syntax will be ambiguous outside of the component.`
-        )
+            `its syntax will be ambiguous outside of the component.`,
+        ),
       )
       descriptor.scriptSetup = null
     }
@@ -232,8 +232,8 @@ export function parse(
       errors.push(
         new SyntaxError(
           `<script> cannot use the "src" attribute when <script setup> is ` +
-            `also present because they must be processed together.`
-        )
+            `also present because they must be processed together.`,
+        ),
       )
       descriptor.script = null
     }
@@ -246,7 +246,7 @@ export function parse(
     (descriptor.template.lang === 'pug' || descriptor.template.lang === 'jade')
   ) {
     ;[descriptor.template.content, templateColumnOffset] = dedent(
-      descriptor.template.content
+      descriptor.template.content,
     )
   }
 
@@ -259,7 +259,7 @@ export function parse(
           block.content,
           sourceRoot,
           !pad || block.type === 'template' ? block.loc.start.line - 1 : 0,
-          columnOffset
+          columnOffset,
         )
       }
     }
@@ -275,12 +275,12 @@ export function parse(
   // check if the SFC uses :slotted
   const slottedRE = /(?:::v-|:)slotted\(/
   descriptor.slotted = descriptor.styles.some(
-    s => s.scoped && slottedRE.test(s.content)
+    s => s.scoped && slottedRE.test(s.content),
   )
 
   const result = {
     descriptor,
-    errors
+    errors,
   }
   parseCache.set(sourceKey, result)
   return result
@@ -288,12 +288,12 @@ export function parse(
 
 function createDuplicateBlockError(
   node: ElementNode,
-  isScriptSetup = false
+  isScriptSetup = false,
 ): CompilerError {
   const err = new SyntaxError(
     `Single file component can contain only one <${node.tag}${
       isScriptSetup ? ` setup` : ``
-    }> element`
+    }> element`,
   ) as CompilerError
   err.loc = node.loc
   return err
@@ -302,7 +302,7 @@ function createDuplicateBlockError(
 function createBlock(
   node: ElementNode,
   source: string,
-  pad: SFCParseOptions['pad']
+  pad: SFCParseOptions['pad'],
 ): SFCBlock {
   const type = node.tag
   const loc = node.innerLoc!
@@ -311,7 +311,7 @@ function createBlock(
     type,
     content: source.slice(loc.start.offset, loc.end.offset),
     loc,
-    attrs
+    attrs,
   }
   if (pad) {
     block.content = padContent(source, block, pad) + block.content
@@ -348,11 +348,11 @@ function generateSourceMap(
   generated: string,
   sourceRoot: string,
   lineOffset: number,
-  columnOffset: number
+  columnOffset: number,
 ): RawSourceMap {
   const map = new SourceMapGenerator({
     file: filename.replace(/\\/g, '/'),
-    sourceRoot: sourceRoot.replace(/\\/g, '/')
+    sourceRoot: sourceRoot.replace(/\\/g, '/'),
   })
   map.setSourceContent(filename, source)
   map._sources.add(filename)
@@ -368,8 +368,8 @@ function generateSourceMap(
             generatedLine,
             generatedColumn: i,
             source: filename,
-            // @ts-ignore
-            name: null
+            // @ts-expect-error
+            name: null,
           })
         }
       }
@@ -381,7 +381,7 @@ function generateSourceMap(
 function padContent(
   content: string,
   block: SFCBlock,
-  pad: SFCParseOptions['pad']
+  pad: SFCParseOptions['pad'],
 ): string {
   content = content.slice(0, block.loc.start.offset)
   if (pad === 'space') {
@@ -423,7 +423,7 @@ function isEmpty(node: ElementNode) {
  */
 export function hmrShouldReload(
   prevImports: Record<string, ImportBinding>,
-  next: SFCDescriptor
+  next: SFCDescriptor,
 ): boolean {
   if (
     !next.scriptSetup ||
@@ -469,6 +469,6 @@ function dedent(s: string): [string, number] {
         return line.slice(minIndent)
       })
       .join('\n'),
-    minIndent
+    minIndent,
   ]
 }
index cb1826b4a8341996b979392d46af93e895c47f13..e6714c9906d423ccee05f6d3f23b92c57bb5498b 100644 (file)
@@ -7,11 +7,11 @@ import { resolveParserPlugins } from './script/context'
 export function rewriteDefault(
   input: string,
   as: string,
-  parserPlugins?: ParserPlugin[]
+  parserPlugins?: ParserPlugin[],
 ): string {
   const ast = parse(input, {
     sourceType: 'module',
-    plugins: resolveParserPlugins('js', parserPlugins)
+    plugins: resolveParserPlugins('js', parserPlugins),
   }).program.body
   const s = new MagicString(input)
 
@@ -27,7 +27,7 @@ export function rewriteDefault(
 export function rewriteDefaultAST(
   ast: Statement[],
   s: MagicString,
-  as: string
+  as: string,
 ): void {
   if (!hasDefaultExport(ast)) {
     s.append(`\nconst ${as} = {}`)
@@ -60,7 +60,7 @@ export function rewriteDefaultAST(
           if (node.source) {
             if (specifier.local.name === 'default') {
               s.prepend(
-                `import { default as __VUE_DEFAULT__ } from '${node.source.value}'\n`
+                `import { default as __VUE_DEFAULT__ } from '${node.source.value}'\n`,
               )
               const end = specifierEnd(s, specifier.local.end!, node.end!)
               s.remove(specifier.start!, end)
@@ -70,8 +70,8 @@ export function rewriteDefaultAST(
               s.prepend(
                 `import { ${s.slice(
                   specifier.local.start!,
-                  specifier.local.end!
-                )} as __VUE_DEFAULT__ } from '${node.source.value}'\n`
+                  specifier.local.end!,
+                )} as __VUE_DEFAULT__ } from '${node.source.value}'\n`,
               )
               const end = specifierEnd(s, specifier.exported.end!, node.end!)
               s.remove(specifier.start!, end)
@@ -96,7 +96,7 @@ export function hasDefaultExport(ast: Statement[]): boolean {
     } else if (
       stmt.type === 'ExportNamedDeclaration' &&
       stmt.specifiers.some(
-        spec => (spec.exported as Identifier).name === 'default'
+        spec => (spec.exported as Identifier).name === 'default',
       )
     ) {
       return true
index 5adbb1b433663a7cf5fc3432d6ee9089771c4dd1..ae544f640e013138dc538580a5bd3956938c1b9b 100644 (file)
@@ -1,10 +1,10 @@
-import {
+import type {
   ArrayExpression,
   Node,
   ObjectExpression,
-  Statement
+  Statement,
 } from '@babel/types'
-import { BindingMetadata, BindingTypes } from '@vue/compiler-dom'
+import { type BindingMetadata, BindingTypes } from '@vue/compiler-dom'
 import { resolveObjectKey } from './utils'
 
 /**
@@ -30,7 +30,7 @@ function analyzeBindingsFromOptions(node: ObjectExpression): BindingMetadata {
   // mark non-script-setup so we don't resolve components/directives from these
   Object.defineProperty(bindings, '__isScriptSetup', {
     enumerable: false,
-    value: false
+    value: false,
   })
   for (const property of node.properties) {
     if (
index 7643b28fd50e2b725d871b5dea86fed3e8ee4fd4..f74adee603b694d3b7124dcba49fd5574608e380 100644 (file)
@@ -1,13 +1,13 @@
-import { CallExpression, Node, ObjectPattern, Program } from '@babel/types'
-import { SFCDescriptor } from '../parse'
+import type { CallExpression, Node, ObjectPattern, Program } from '@babel/types'
+import type { SFCDescriptor } from '../parse'
 import { generateCodeFrame, isArray } from '@vue/shared'
-import { parse as babelParse, ParserPlugin } from '@babel/parser'
-import { ImportBinding, SFCScriptCompileOptions } from '../compileScript'
-import { PropsDestructureBindings } from './defineProps'
-import { ModelDecl } from './defineModel'
-import { BindingMetadata } from '../../../compiler-core/src'
+import { type ParserPlugin, parse as babelParse } from '@babel/parser'
+import type { ImportBinding, SFCScriptCompileOptions } from '../compileScript'
+import type { PropsDestructureBindings } from './defineProps'
+import type { ModelDecl } from './defineModel'
+import type { BindingMetadata } from '../../../compiler-core/src'
 import MagicString from 'magic-string'
-import { TypeScope } from './resolveType'
+import type { TypeScope } from './resolveType'
 
 export class ScriptCompileContext {
   isJS: boolean
@@ -79,7 +79,7 @@ export class ScriptCompileContext {
 
   constructor(
     public descriptor: SFCDescriptor,
-    public options: Partial<SFCScriptCompileOptions>
+    public options: Partial<SFCScriptCompileOptions>,
   ) {
     const { script, scriptSetup } = descriptor
     const scriptLang = script && script.lang
@@ -107,14 +107,14 @@ export class ScriptCompileContext {
     // resolve parser plugins
     const plugins: ParserPlugin[] = resolveParserPlugins(
       (scriptLang || scriptSetupLang)!,
-      options.babelParserPlugins
+      options.babelParserPlugins,
     )
 
     function parse(input: string, offset: number): Program {
       try {
         return babelParse(input, {
           plugins,
-          sourceType: 'module'
+          sourceType: 'module',
         }).program
       } catch (e: any) {
         e.message = `[vue/compiler-sfc] ${e.message}\n\n${
@@ -122,7 +122,7 @@ export class ScriptCompileContext {
         }\n${generateCodeFrame(
           descriptor.source,
           e.pos + offset,
-          e.pos + offset + 1
+          e.pos + offset + 1,
         )}`
         throw e
       }
@@ -152,8 +152,8 @@ export class ScriptCompileContext {
       }\n${generateCodeFrame(
         (scope || this.descriptor).source,
         node.start! + offset,
-        node.end! + offset
-      )}`
+        node.end! + offset,
+      )}`,
     )
   }
 }
@@ -161,7 +161,7 @@ export class ScriptCompileContext {
 export function resolveParserPlugins(
   lang: string,
   userPlugins?: ParserPlugin[],
-  dts = false
+  dts = false,
 ) {
   const plugins: ParserPlugin[] = []
   if (
@@ -170,7 +170,7 @@ export function resolveParserPlugins(
       p =>
         p === 'importAssertions' ||
         p === 'importAttributes' ||
-        (isArray(p) && p[0] === 'importAttributes')
+        (isArray(p) && p[0] === 'importAttributes'),
     )
   ) {
     plugins.push('importAttributes')
index 4e72eaf89fd5a4c39f28208318b21df45f4bba04..526a55dc8a1010cf6a9d1eebddce6203cc29d9ad 100644 (file)
@@ -1,17 +1,17 @@
-import {
+import type {
   ArrayPattern,
   Identifier,
   LVal,
   Node,
   ObjectPattern,
-  RestElement
+  RestElement,
 } from '@babel/types'
 import { isCallOf } from './utils'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 import {
-  TypeResolveContext,
+  type TypeResolveContext,
   resolveTypeElements,
-  resolveUnionType
+  resolveUnionType,
 } from './resolveType'
 
 export const DEFINE_EMITS = 'defineEmits'
@@ -19,7 +19,7 @@ export const DEFINE_EMITS = 'defineEmits'
 export function processDefineEmits(
   ctx: ScriptCompileContext,
   node: Node,
-  declId?: LVal
+  declId?: LVal,
 ): boolean {
   if (!isCallOf(node, DEFINE_EMITS)) {
     return false
@@ -34,7 +34,7 @@ export function processDefineEmits(
       ctx.error(
         `${DEFINE_EMITS}() cannot accept both type and non-type arguments ` +
           `at the same time. Use one or the other.`,
-        node
+        node,
       )
     }
     ctx.emitsTypeDecl = node.typeParameters.params[0]
@@ -63,7 +63,7 @@ export function genRuntimeEmits(ctx: ScriptCompileContext): string | undefined {
       .join(', ')}]`
     emitsDecl = emitsDecl
       ? `/*#__PURE__*/${ctx.helper(
-          'mergeModels'
+          'mergeModels',
         )}(${emitsDecl}, ${modelEmitsDecl})`
       : modelEmitsDecl
   }
@@ -91,7 +91,7 @@ export function extractRuntimeEmits(ctx: TypeResolveContext): Set<string> {
     if (hasProperty) {
       ctx.error(
         `defineEmits() type cannot mixed call signature and property syntax.`,
-        node
+        node,
       )
     }
     for (const call of calls) {
@@ -105,7 +105,7 @@ export function extractRuntimeEmits(ctx: TypeResolveContext): Set<string> {
 function extractEventNames(
   ctx: TypeResolveContext,
   eventName: ArrayPattern | Identifier | ObjectPattern | RestElement,
-  emits: Set<string>
+  emits: Set<string>,
 ) {
   if (
     eventName.type === 'Identifier' &&
index 636fdba8d082adb128734d49eb2fc84a6149075b..ba13e26c1e58a17d68392d38a19ed2bca8ea3a70 100644 (file)
@@ -1,12 +1,12 @@
-import { Node } from '@babel/types'
+import type { Node } from '@babel/types'
 import { isCallOf } from './utils'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 
 export const DEFINE_EXPOSE = 'defineExpose'
 
 export function processDefineExpose(
   ctx: ScriptCompileContext,
-  node: Node
+  node: Node,
 ): boolean {
   if (isCallOf(node, DEFINE_EXPOSE)) {
     if (ctx.hasDefineExposeCall) {
index 2d1eb523217559ccb61b3df89cc0868988ebd34e..183529d358544909359ac762969818d7666bcfb2 100644 (file)
@@ -1,11 +1,11 @@
-import { LVal, Node, ObjectProperty, TSType } from '@babel/types'
-import { ScriptCompileContext } from './context'
+import type { LVal, Node, ObjectProperty, TSType } from '@babel/types'
+import type { ScriptCompileContext } from './context'
 import { inferRuntimeType } from './resolveType'
 import {
   UNKNOWN_TYPE,
   concatStrings,
   isCallOf,
-  toRuntimeTypeString
+  toRuntimeTypeString,
 } from './utils'
 import { BindingTypes, unwrapTSNode } from '@vue/compiler-dom'
 
@@ -20,7 +20,7 @@ export interface ModelDecl {
 export function processDefineModel(
   ctx: ScriptCompileContext,
   node: Node,
-  declId?: LVal
+  declId?: LVal,
 ): boolean {
   if (!isCallOf(node, DEFINE_MODEL)) {
     return false
@@ -50,7 +50,8 @@ export function processDefineModel(
   ctx.modelDecls[modelName] = {
     type,
     options: optionsString,
-    identifier: declId && declId.type === 'Identifier' ? declId.name : undefined
+    identifier:
+      declId && declId.type === 'Identifier' ? declId.name : undefined,
   }
   // register binding type
   ctx.bindingMetadata[modelName] = BindingTypes.PROPS
@@ -62,7 +63,7 @@ export function processDefineModel(
         p =>
           p.type === 'ObjectProperty' &&
           ((p.key.type === 'Identifier' && p.key.name === 'local') ||
-            (p.key.type === 'StringLiteral' && p.key.value === 'local'))
+            (p.key.type === 'StringLiteral' && p.key.value === 'local')),
       ) as ObjectProperty
 
       if (local) {
@@ -85,7 +86,7 @@ export function processDefineModel(
     ctx.startOffset! + node.end!,
     `${ctx.helper('useModel')}(__props, ${JSON.stringify(modelName)}${
       runtimeOptions ? `, ${runtimeOptions}` : ``
-    })`
+    })`,
   )
 
   return true
@@ -120,7 +121,7 @@ export function genModelProps(ctx: ScriptCompileContext) {
 
     const codegenOptions = concatStrings([
       runtimeType && `type: ${runtimeType}`,
-      skipCheck && 'skipCheck: true'
+      skipCheck && 'skipCheck: true',
     ])
 
     let decl: string
index 4a3551d7551c2427af942878372b28a2365fc8d4..8e32e0fba82a8229257e7c3ffdbe1dc2ad5f2d20 100644 (file)
@@ -1,6 +1,6 @@
-import { Node } from '@babel/types'
+import type { Node } from '@babel/types'
 import { unwrapTSNode } from '@vue/compiler-dom'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 import { isCallOf } from './utils'
 import { DEFINE_PROPS } from './defineProps'
 import { DEFINE_EMITS } from './defineEmits'
@@ -11,7 +11,7 @@ export const DEFINE_OPTIONS = 'defineOptions'
 
 export function processDefineOptions(
   ctx: ScriptCompileContext,
-  node: Node
+  node: Node,
 ): boolean {
   if (!isCallOf(node, DEFINE_OPTIONS)) {
     return false
@@ -48,25 +48,25 @@ export function processDefineOptions(
   if (propsOption) {
     ctx.error(
       `${DEFINE_OPTIONS}() cannot be used to declare props. Use ${DEFINE_PROPS}() instead.`,
-      propsOption
+      propsOption,
     )
   }
   if (emitsOption) {
     ctx.error(
       `${DEFINE_OPTIONS}() cannot be used to declare emits. Use ${DEFINE_EMITS}() instead.`,
-      emitsOption
+      emitsOption,
     )
   }
   if (exposeOption) {
     ctx.error(
       `${DEFINE_OPTIONS}() cannot be used to declare expose. Use ${DEFINE_EXPOSE}() instead.`,
-      exposeOption
+      exposeOption,
     )
   }
   if (slotsOption) {
     ctx.error(
       `${DEFINE_OPTIONS}() cannot be used to declare slots. Use ${DEFINE_SLOTS}() instead.`,
-      slotsOption
+      slotsOption,
     )
   }
 
index cc7b86ba2cb4f0809d3b228a721f9880e0a40b9b..4c8a34aa616a6c79f01842ecf80587b557c0906c 100644 (file)
@@ -1,26 +1,26 @@
-import {
-  Node,
+import type {
+  Expression,
   LVal,
-  ObjectProperty,
-  ObjectMethod,
+  Node,
   ObjectExpression,
-  Expression
+  ObjectMethod,
+  ObjectProperty,
 } from '@babel/types'
 import { BindingTypes, isFunctionType, unwrapTSNode } from '@vue/compiler-dom'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 import {
-  TypeResolveContext,
+  type TypeResolveContext,
   inferRuntimeType,
-  resolveTypeElements
+  resolveTypeElements,
 } from './resolveType'
 import {
-  resolveObjectKey,
   UNKNOWN_TYPE,
   concatStrings,
-  isLiteralNode,
+  getEscapedPropName,
   isCallOf,
+  isLiteralNode,
+  resolveObjectKey,
   toRuntimeTypeString,
-  getEscapedPropName
 } from './utils'
 import { genModelProps } from './defineModel'
 import { getObjectOrArrayExpressionKeys } from './analyzeScriptBindings'
@@ -47,7 +47,7 @@ export type PropsDestructureBindings = Record<
 export function processDefineProps(
   ctx: ScriptCompileContext,
   node: Node,
-  declId?: LVal
+  declId?: LVal,
 ) {
   if (!isCallOf(node, DEFINE_PROPS)) {
     return processWithDefaults(ctx, node, declId)
@@ -74,7 +74,7 @@ export function processDefineProps(
       ctx.error(
         `${DEFINE_PROPS}() cannot accept both type and non-type arguments ` +
           `at the same time. Use one or the other.`,
-        node
+        node,
       )
     }
     ctx.propsTypeDecl = node.typeParameters.params[0]
@@ -94,7 +94,7 @@ export function processDefineProps(
 function processWithDefaults(
   ctx: ScriptCompileContext,
   node: Node,
-  declId?: LVal
+  declId?: LVal,
 ): boolean {
   if (!isCallOf(node, WITH_DEFAULTS)) {
     return false
@@ -102,7 +102,7 @@ function processWithDefaults(
   if (!processDefineProps(ctx, node.arguments[0], declId)) {
     ctx.error(
       `${WITH_DEFAULTS}' first argument must be a ${DEFINE_PROPS} call.`,
-      node.arguments[0] || node
+      node.arguments[0] || node,
     )
   }
 
@@ -110,14 +110,14 @@ function processWithDefaults(
     ctx.error(
       `${WITH_DEFAULTS} can only be used with type-based ` +
         `${DEFINE_PROPS} declaration.`,
-      node
+      node,
     )
   }
   if (ctx.propsDestructureDecl) {
     ctx.error(
       `${WITH_DEFAULTS}() is unnecessary when using destructure with ${DEFINE_PROPS}().\n` +
         `Prefer using destructure default values, e.g. const { foo = 1 } = defineProps(...).`,
-      node.callee
+      node.callee,
     )
   }
   ctx.propsRuntimeDefaults = node.arguments[1]
@@ -143,12 +143,12 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
           defaults.push(
             `${finalKey}: ${d.valueString}${
               d.needSkipFactory ? `, __skip_${finalKey}: true` : ``
-            }`
+            }`,
           )
       }
       if (defaults.length) {
         propsDecls = `/*#__PURE__*/${ctx.helper(
-          `mergeDefaults`
+          `mergeDefaults`,
         )}(${propsDecls}, {\n  ${defaults.join(',\n  ')}\n})`
       }
     }
@@ -160,7 +160,7 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
 
   if (propsDecls && modelsDecls) {
     return `/*#__PURE__*/${ctx.helper(
-      'mergeModels'
+      'mergeModels',
     )}(${propsDecls}, ${modelsDecls})`
   } else {
     return modelsDecls || propsDecls
@@ -168,7 +168,7 @@ export function genRuntimeProps(ctx: ScriptCompileContext): string | undefined {
 }
 
 export function extractRuntimeProps(
-  ctx: TypeResolveContext
+  ctx: TypeResolveContext,
 ): string | undefined {
   // this is only called if propsTypeDecl exists
   const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl!)
@@ -192,7 +192,7 @@ export function extractRuntimeProps(
 
   if (ctx.propsRuntimeDefaults && !hasStaticDefaults) {
     propsDecls = `/*#__PURE__*/${ctx.helper(
-      'mergeDefaults'
+      'mergeDefaults',
     )}(${propsDecls}, ${ctx.getString(ctx.propsRuntimeDefaults)})`
   }
 
@@ -201,7 +201,7 @@ export function extractRuntimeProps(
 
 function resolveRuntimePropsFromType(
   ctx: TypeResolveContext,
-  node: Node
+  node: Node,
 ): PropTypeData[] {
   const props: PropTypeData[] = []
   const elements = resolveTypeElements(ctx, node)
@@ -222,7 +222,7 @@ function resolveRuntimePropsFromType(
       key,
       required: !e.optional,
       type: type || [`null`],
-      skipCheck
+      skipCheck,
     })
   }
   return props
@@ -231,7 +231,7 @@ function resolveRuntimePropsFromType(
 function genRuntimePropFromType(
   ctx: TypeResolveContext,
   { key, required, type, skipCheck }: PropTypeData,
-  hasStaticDefaults: boolean
+  hasStaticDefaults: boolean,
 ): string {
   let defaultString: string | undefined
   const destructured = genDestructuredDefaultValue(ctx, key, type)
@@ -244,7 +244,7 @@ function genRuntimePropFromType(
       node => {
         if (node.type === 'SpreadElement') return false
         return resolveObjectKey(node.key, node.computed) === key
-      }
+      },
     ) as ObjectProperty | ObjectMethod
     if (prop) {
       if (prop.type === 'ObjectProperty') {
@@ -264,13 +264,13 @@ function genRuntimePropFromType(
       `type: ${toRuntimeTypeString(type)}`,
       `required: ${required}`,
       skipCheck && 'skipCheck: true',
-      defaultString
+      defaultString,
     ])} }`
   } else if (
     type.some(
       el =>
         el === 'Boolean' ||
-        ((!hasStaticDefaults || defaultString) && el === 'Function')
+        ((!hasStaticDefaults || defaultString) && el === 'Function'),
     )
   ) {
     // #4783 for boolean, should keep the type
@@ -278,14 +278,14 @@ function genRuntimePropFromType(
     // in production
     return `${finalKey}: { ${concatStrings([
       `type: ${toRuntimeTypeString(type)}`,
-      defaultString
+      defaultString,
     ])} }`
   } else {
     // #8989 for custom element, should keep the type
     if (ctx.isCE) {
       if (defaultString) {
         return `${finalKey}: ${`{ ${defaultString}, type: ${toRuntimeTypeString(
-          type
+          type,
         )} }`}`
       } else {
         return `${finalKey}: {type: ${toRuntimeTypeString(type)}}`
@@ -309,7 +309,7 @@ function hasStaticWithDefaults(ctx: TypeResolveContext) {
     ctx.propsRuntimeDefaults.properties.every(
       node =>
         node.type !== 'SpreadElement' &&
-        (!node.computed || node.key.type.endsWith('Literal'))
+        (!node.computed || node.key.type.endsWith('Literal')),
     )
   )
 }
@@ -317,7 +317,7 @@ function hasStaticWithDefaults(ctx: TypeResolveContext) {
 function genDestructuredDefaultValue(
   ctx: TypeResolveContext,
   key: string,
-  inferredType?: string[]
+  inferredType?: string[],
 ):
   | {
       valueString: string
@@ -335,7 +335,7 @@ function genDestructuredDefaultValue(
       if (valueType && !inferredType.includes(valueType)) {
         ctx.error(
           `Default value of prop "${key}" does not match declared type.`,
-          unwrapped
+          unwrapped,
         )
       }
     }
@@ -355,7 +355,7 @@ function genDestructuredDefaultValue(
 
     return {
       valueString: needFactoryWrap ? `() => (${value})` : value,
-      needSkipFactory
+      needSkipFactory,
     }
   }
 }
index c9c4fb5f7b7e7e44da115bc4f7e5f955e5ac949c..e4a59aca7d55d9c096497f5a08afbd6929e93f3b 100644 (file)
@@ -1,11 +1,11 @@
-import {
-  Node,
-  Identifier,
+import type {
   BlockStatement,
+  Expression,
+  Identifier,
+  Node,
+  ObjectPattern,
   Program,
   VariableDeclaration,
-  ObjectPattern,
-  Expression
 } from '@babel/types'
 import { walk } from 'estree-walker'
 import {
@@ -15,18 +15,18 @@ import {
   isInDestructureAssignment,
   isReferencedIdentifier,
   isStaticProperty,
+  unwrapTSNode,
   walkFunctionParams,
-  unwrapTSNode
 } from '@vue/compiler-dom'
 import { genPropsAccessExp } from '@vue/shared'
 import { isCallOf, resolveObjectKey } from './utils'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 import { DEFINE_PROPS } from './defineProps'
 import { warnOnce } from '../warn'
 
 export function processPropsDestructure(
   ctx: ScriptCompileContext,
-  declId: ObjectPattern
+  declId: ObjectPattern,
 ) {
   if (!ctx.options.propsDestructure) {
     return
@@ -36,7 +36,7 @@ export function processPropsDestructure(
     `This project is using reactive props destructure, which is an experimental ` +
       `feature. It may receive breaking changes or be removed in the future, so ` +
       `use at your own risk.\n` +
-      `To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`
+      `To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502.`,
   )
 
   ctx.propsDestructureDecl = declId
@@ -44,7 +44,7 @@ export function processPropsDestructure(
   const registerBinding = (
     key: string,
     local: string,
-    defaultValue?: Expression
+    defaultValue?: Expression,
   ) => {
     ctx.propsDestructuredBindings[key] = { local, default: defaultValue }
     if (local !== key) {
@@ -61,7 +61,7 @@ export function processPropsDestructure(
       if (!propKey) {
         ctx.error(
           `${DEFINE_PROPS}() destructure cannot use computed key.`,
-          prop.key
+          prop.key,
         )
       }
 
@@ -71,7 +71,7 @@ export function processPropsDestructure(
         if (left.type !== 'Identifier') {
           ctx.error(
             `${DEFINE_PROPS}() destructure does not support nested patterns.`,
-            left
+            left,
           )
         }
         registerBinding(propKey, left.name, right)
@@ -81,7 +81,7 @@ export function processPropsDestructure(
       } else {
         ctx.error(
           `${DEFINE_PROPS}() destructure does not support nested patterns.`,
-          prop.value
+          prop.value,
         )
       }
     } else {
@@ -102,7 +102,7 @@ type Scope = Record<string, boolean>
 
 export function transformDestructuredProps(
   ctx: ScriptCompileContext,
-  vueImportAliases: Record<string, string>
+  vueImportAliases: Record<string, string>,
 ) {
   if (!ctx.options.propsDestructure) {
     return
@@ -137,7 +137,7 @@ export function transformDestructuredProps(
     } else {
       ctx.error(
         'registerBinding called without active scope, something is wrong.',
-        id
+        id,
       )
     }
   }
@@ -209,7 +209,7 @@ export function transformDestructuredProps(
         // { prop } -> { prop: __props.prop }
         ctx.s.appendLeft(
           id.end! + ctx.startOffset!,
-          `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`
+          `: ${genPropsAccessExp(propsLocalToPublicMap[id.name])}`,
         )
       }
     } else {
@@ -217,7 +217,7 @@ export function transformDestructuredProps(
       ctx.s.overwrite(
         id.start! + ctx.startOffset!,
         id.end! + ctx.startOffset!,
-        genPropsAccessExp(propsLocalToPublicMap[id.name])
+        genPropsAccessExp(propsLocalToPublicMap[id.name]),
       )
     }
   }
@@ -229,7 +229,7 @@ export function transformDestructuredProps(
         ctx.error(
           `"${arg.name}" is a destructured prop and should not be passed directly to ${method}(). ` +
             `Pass a getter () => ${arg.name} instead.`,
-          arg
+          arg,
         )
       }
     }
@@ -302,6 +302,6 @@ export function transformDestructuredProps(
       ) {
         popScope()
       }
-    }
+    },
   })
 }
index cd7dc2e4897336b42812092b4a7ec9fda3e4c9bf..d8f66d757a6ea5c5d3503ffa0a33c2c652966324 100644 (file)
@@ -1,13 +1,13 @@
-import { LVal, Node } from '@babel/types'
+import type { LVal, Node } from '@babel/types'
 import { isCallOf } from './utils'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 
 export const DEFINE_SLOTS = 'defineSlots'
 
 export function processDefineSlots(
   ctx: ScriptCompileContext,
   node: Node,
-  declId?: LVal
+  declId?: LVal,
 ): boolean {
   if (!isCallOf(node, DEFINE_SLOTS)) {
     return false
@@ -25,7 +25,7 @@ export function processDefineSlots(
     ctx.s.overwrite(
       ctx.startOffset! + node.start!,
       ctx.startOffset! + node.end!,
-      `${ctx.helper('useSlots')}()`
+      `${ctx.helper('useSlots')}()`,
     )
   }
 
index f9fcca235d963fd1aa10d7c932641bfafed9d947..5ea11f9157f07a43459b1fad972fb639b7c855ca 100644 (file)
@@ -1,11 +1,11 @@
-import { SFCDescriptor } from '../parse'
+import type { SFCDescriptor } from '../parse'
 import {
+  type ExpressionNode,
   NodeTypes,
-  SimpleExpressionNode,
+  type SimpleExpressionNode,
+  type TemplateChildNode,
   parserOptions,
   walkIdentifiers,
-  TemplateChildNode,
-  ExpressionNode
 } from '@vue/compiler-dom'
 import { createCache } from '../cache'
 import { camelize, capitalize, isBuiltInDirective } from '@vue/shared'
index 023ba44b34f56e0b820571d117fc35527a11c901..3b2f21d486332b09b6551bd61a13859e28b821ab 100644 (file)
@@ -1,5 +1,5 @@
 import { analyzeScriptBindings } from './analyzeScriptBindings'
-import { ScriptCompileContext } from './context'
+import type { ScriptCompileContext } from './context'
 import MagicString from 'magic-string'
 import { rewriteDefaultAST } from '../rewriteDefault'
 import { genNormalScriptCssVarsCode } from '../style/cssVars'
@@ -8,7 +8,7 @@ export const normalScriptDefaultVar = `__default__`
 
 export function processNormalScript(
   ctx: ScriptCompileContext,
-  scopeId: string
+  scopeId: string,
 ) {
   const script = ctx.descriptor.script!
   if (script.lang && !ctx.isJS && !ctx.isTS) {
@@ -34,7 +34,7 @@ export function processNormalScript(
           bindings,
           scopeId,
           !!isProd,
-          defaultVar
+          defaultVar,
         )
       }
       if (!genDefaultAs) {
@@ -46,7 +46,7 @@ export function processNormalScript(
       content,
       map,
       bindings,
-      scriptAst: scriptAst.body
+      scriptAst: scriptAst.body,
     }
   } catch (e: any) {
     // silently fallback if parse fails since user may be using custom
index 3df3bdafb8d575f07c53390267a01843fac98f19..3f965e99735a187f93d79f790f1db3a1fc9c10f1 100644 (file)
@@ -1,4 +1,4 @@
-import {
+import type {
   Expression,
   Identifier,
   Node,
@@ -22,24 +22,24 @@ import {
   TSTypeLiteral,
   TSTypeQuery,
   TSTypeReference,
-  TemplateLiteral
+  TemplateLiteral,
 } from '@babel/types'
 import {
   UNKNOWN_TYPE,
   createGetCanonicalFileName,
   getId,
   getImportedName,
+  joinPaths,
   normalizePath,
-  joinPaths
 } from './utils'
-import { ScriptCompileContext, resolveParserPlugins } from './context'
-import { ImportBinding, SFCScriptCompileOptions } from '../compileScript'
+import { type ScriptCompileContext, resolveParserPlugins } from './context'
+import type { ImportBinding, SFCScriptCompileOptions } from '../compileScript'
 import { capitalize, hasOwn } from '@vue/shared'
 import { parse as babelParse } from '@babel/parser'
 import { parse } from '../parse'
 import { createCache } from '../cache'
 import type TS from 'typescript'
-import { extname, dirname, join } from 'path'
+import { dirname, extname, join } from 'path'
 import { minimatch as isMatch } from 'minimatch'
 import * as process from 'process'
 
@@ -113,7 +113,7 @@ export class TypeScope {
     public offset: number = 0,
     public imports: Record<string, Import> = Object.create(null),
     public types: Record<string, ScopeTypeNode> = Object.create(null),
-    public declares: Record<string, ScopeTypeNode> = Object.create(null)
+    public declares: Record<string, ScopeTypeNode> = Object.create(null),
   ) {}
   isGenericScope = false
   resolvedImportSources: Record<string, string> = Object.create(null)
@@ -144,7 +144,7 @@ export function resolveTypeElements(
   ctx: TypeResolveContext,
   node: Node & MaybeWithScope & { _resolvedElements?: ResolvedElements },
   scope?: TypeScope,
-  typeParameters?: Record<string, Node>
+  typeParameters?: Record<string, Node>,
 ): ResolvedElements {
   const canCache = !typeParameters
   if (canCache && node._resolvedElements) {
@@ -154,7 +154,7 @@ export function resolveTypeElements(
     ctx,
     node,
     node._ownerScope || scope || ctxToScope(ctx),
-    typeParameters
+    typeParameters,
   )
   return canCache ? (node._resolvedElements = resolved) : resolved
 }
@@ -163,7 +163,7 @@ function innerResolveTypeElements(
   ctx: TypeResolveContext,
   node: Node,
   scope: TypeScope,
-  typeParameters?: Record<string, Node>
+  typeParameters?: Record<string, Node>,
 ): ResolvedElements {
   switch (node.type) {
     case 'TSTypeLiteral':
@@ -176,7 +176,7 @@ function innerResolveTypeElements(
         ctx,
         node.typeAnnotation,
         scope,
-        typeParameters
+        typeParameters,
       )
     case 'TSFunctionType': {
       return { props: {}, calls: [node] }
@@ -185,7 +185,7 @@ function innerResolveTypeElements(
     case 'TSIntersectionType':
       return mergeElements(
         node.types.map(t => resolveTypeElements(ctx, t, scope, typeParameters)),
-        node.type
+        node.type,
       )
     case 'TSMappedType':
       return resolveMappedType(ctx, node, scope)
@@ -193,7 +193,7 @@ function innerResolveTypeElements(
       const types = resolveIndexType(ctx, node, scope)
       return mergeElements(
         types.map(t => resolveTypeElements(ctx, t, t._ownerScope)),
-        'TSUnionType'
+        'TSUnionType',
       )
     }
     case 'TSExpressionWithTypeArguments': // referenced by interface extends
@@ -210,9 +210,9 @@ function innerResolveTypeElements(
             ctx,
             node.typeParameters.params[0],
             scope,
-            typeParameters
+            typeParameters,
           ),
-          scope
+          scope,
         )
       }
       const resolved = resolveTypeReference(ctx, node, scope)
@@ -235,7 +235,7 @@ function innerResolveTypeElements(
           ctx,
           resolved,
           resolved._ownerScope,
-          typeParams
+          typeParams,
         )
       } else {
         if (typeof typeName === 'string') {
@@ -244,11 +244,11 @@ function innerResolveTypeElements(
               ctx,
               typeParameters[typeName],
               scope,
-              typeParameters
+              typeParameters,
             )
           }
           if (
-            // @ts-ignore
+            // @ts-expect-error
             SupportedBuiltinsSet.has(typeName)
           ) {
             return resolveBuiltin(
@@ -256,14 +256,14 @@ function innerResolveTypeElements(
               node,
               typeName as any,
               scope,
-              typeParameters
+              typeParameters,
             )
           } else if (typeName === 'ReturnType' && node.typeParameters) {
             // limited support, only reference types
             const ret = resolveReturnType(
               ctx,
               node.typeParameters.params[0],
-              scope
+              scope,
             )
             if (ret) {
               return resolveTypeElements(ctx, ret, scope)
@@ -273,7 +273,7 @@ function innerResolveTypeElements(
         return ctx.error(
           `Unresolvable type reference or unsupported built-in utility type`,
           node,
-          scope
+          scope,
         )
       }
     }
@@ -286,14 +286,14 @@ function innerResolveTypeElements(
       ) {
         return resolveExtractPropTypes(
           resolveTypeElements(ctx, node.typeParameters.params[0], scope),
-          scope
+          scope,
         )
       }
       const sourceScope = importSourceToScope(
         ctx,
         node.argument,
         scope,
-        node.argument.value
+        node.argument.value,
       )
       const resolved = resolveTypeReference(ctx, node, sourceScope)
       if (resolved) {
@@ -317,7 +317,7 @@ function typeElementsToMap(
   ctx: TypeResolveContext,
   elements: TSTypeElement[],
   scope = ctxToScope(ctx),
-  typeParameters?: Record<string, Node>
+  typeParameters?: Record<string, Node>,
 ): ResolvedElements {
   const res: ResolvedElements = { props: {} }
   for (const e of elements) {
@@ -340,7 +340,7 @@ function typeElementsToMap(
         ctx.error(
           `Unsupported computed key in type referenced by a macro`,
           e.key,
-          scope
+          scope,
         )
       }
     } else if (e.type === 'TSCallSignatureDeclaration') {
@@ -352,7 +352,7 @@ function typeElementsToMap(
 
 function mergeElements(
   maps: ResolvedElements[],
-  type: 'TSUnionType' | 'TSIntersectionType'
+  type: 'TSUnionType' | 'TSIntersectionType',
 ): ResolvedElements {
   if (maps.length === 1) return maps[0]
   const res: ResolvedElements = { props: {} }
@@ -366,11 +366,11 @@ function mergeElements(
           baseProps[key].key,
           {
             type,
-            // @ts-ignore
-            types: [baseProps[key], props[key]]
+            // @ts-expect-error
+            types: [baseProps[key], props[key]],
           },
           baseProps[key]._ownerScope,
-          baseProps[key].optional || props[key].optional
+          baseProps[key].optional || props[key].optional,
         )
       }
     }
@@ -385,7 +385,7 @@ function createProperty(
   key: Expression,
   typeAnnotation: TSType,
   scope: TypeScope,
-  optional: boolean
+  optional: boolean,
 ): TSPropertySignature & WithScope {
   return {
     type: 'TSPropertySignature',
@@ -394,9 +394,9 @@ function createProperty(
     optional,
     typeAnnotation: {
       type: 'TSTypeAnnotation',
-      typeAnnotation
+      typeAnnotation,
     },
-    _ownerScope: scope
+    _ownerScope: scope,
   }
 }
 
@@ -404,13 +404,13 @@ function resolveInterfaceMembers(
   ctx: TypeResolveContext,
   node: TSInterfaceDeclaration & MaybeWithScope,
   scope: TypeScope,
-  typeParameters?: Record<string, Node>
+  typeParameters?: Record<string, Node>,
 ): ResolvedElements {
   const base = typeElementsToMap(
     ctx,
     node.body.body,
     node._ownerScope,
-    typeParameters
+    typeParameters,
   )
   if (node.extends) {
     for (const ext of node.extends) {
@@ -438,7 +438,7 @@ function resolveInterfaceMembers(
             `interface Props extends /* @vue-ignore */ Base {}\n\n` +
             `Note: both in 3.2 or with the ignore, the properties in the base ` +
             `type are treated as fallthrough attrs at runtime.`,
-          ext
+          ext,
         )
       }
     }
@@ -449,7 +449,7 @@ function resolveInterfaceMembers(
 function resolveMappedType(
   ctx: TypeResolveContext,
   node: TSMappedType,
-  scope: TypeScope
+  scope: TypeScope,
 ): ResolvedElements {
   const res: ResolvedElements = { props: {} }
   const keys = resolveStringType(ctx, node.typeParameter.constraint!, scope)
@@ -457,11 +457,11 @@ function resolveMappedType(
     res.props[key] = createProperty(
       {
         type: 'Identifier',
-        name: key
+        name: key,
       },
       node.typeAnnotation!,
       scope,
-      !!node.optional
+      !!node.optional,
     )
   }
   return res
@@ -470,7 +470,7 @@ function resolveMappedType(
 function resolveIndexType(
   ctx: TypeResolveContext,
   node: TSIndexedAccessType,
-  scope: TypeScope
+  scope: TypeScope,
 ): (TSType & MaybeWithScope)[] {
   if (node.indexType.type === 'TSNumberKeyword') {
     return resolveArrayElementType(ctx, node.objectType, scope)
@@ -501,7 +501,7 @@ function resolveIndexType(
 function resolveArrayElementType(
   ctx: TypeResolveContext,
   node: Node,
-  scope: TypeScope
+  scope: TypeScope,
 ): TSType[] {
   // type[]
   if (node.type === 'TSArrayType') {
@@ -510,7 +510,7 @@ function resolveArrayElementType(
   // tuple
   if (node.type === 'TSTupleType') {
     return node.elementTypes.map(t =>
-      t.type === 'TSNamedTupleMember' ? t.elementType : t
+      t.type === 'TSNamedTupleMember' ? t.elementType : t,
     )
   }
   if (node.type === 'TSTypeReference') {
@@ -527,14 +527,14 @@ function resolveArrayElementType(
   return ctx.error(
     'Failed to resolve element type from target type',
     node,
-    scope
+    scope,
   )
 }
 
 function resolveStringType(
   ctx: TypeResolveContext,
   node: Node,
-  scope: TypeScope
+  scope: TypeScope,
 ): string[] {
   switch (node.type) {
     case 'StringLiteral':
@@ -573,7 +573,7 @@ function resolveStringType(
             ctx.error(
               'Unsupported type when resolving index type',
               node.typeName,
-              scope
+              scope,
             )
         }
       }
@@ -585,7 +585,7 @@ function resolveStringType(
 function resolveTemplateKeys(
   ctx: TypeResolveContext,
   node: TemplateLiteral,
-  scope: TypeScope
+  scope: TypeScope,
 ): string[] {
   if (!node.expressions.length) {
     return [node.quasis[0].value.raw]
@@ -601,9 +601,9 @@ function resolveTemplateKeys(
     {
       ...node,
       expressions: node.expressions.slice(1),
-      quasis: q ? node.quasis.slice(1) : node.quasis
+      quasis: q ? node.quasis.slice(1) : node.quasis,
     },
-    scope
+    scope,
   )
 
   for (const r of resolved) {
@@ -620,7 +620,7 @@ const SupportedBuiltinsSet = new Set([
   'Required',
   'Readonly',
   'Pick',
-  'Omit'
+  'Omit',
 ] as const)
 
 type GetSetType<T> = T extends Set<infer V> ? V : never
@@ -630,13 +630,13 @@ function resolveBuiltin(
   node: TSTypeReference | TSExpressionWithTypeArguments,
   name: GetSetType<typeof SupportedBuiltinsSet>,
   scope: TypeScope,
-  typeParameters?: Record<string, Node>
+  typeParameters?: Record<string, Node>,
 ): ResolvedElements {
   const t = resolveTypeElements(
     ctx,
     node.typeParameters!.params[0],
     scope,
-    typeParameters
+    typeParameters,
   )
   switch (name) {
     case 'Partial': {
@@ -659,7 +659,7 @@ function resolveBuiltin(
       const picked = resolveStringType(
         ctx,
         node.typeParameters!.params[1],
-        scope
+        scope,
       )
       const res: ResolvedElements = { props: {}, calls: t.calls }
       for (const key of picked) {
@@ -671,7 +671,7 @@ function resolveBuiltin(
       const omitted = resolveStringType(
         ctx,
         node.typeParameters!.params[1],
-        scope
+        scope,
       )
       const res: ResolvedElements = { props: {}, calls: t.calls }
       for (const key in t.props) {
@@ -696,7 +696,7 @@ function resolveTypeReference(
   },
   scope?: TypeScope,
   name?: string,
-  onlyExported = false
+  onlyExported = false,
 ): ScopeTypeNode | undefined {
   const canCache = !scope?.isGenericScope
   if (canCache && node._resolvedReference) {
@@ -707,7 +707,7 @@ function resolveTypeReference(
     scope || ctxToScope(ctx),
     name || getReferenceName(node),
     node,
-    onlyExported
+    onlyExported,
   )
   return canCache ? (node._resolvedReference = resolved) : resolved
 }
@@ -717,7 +717,7 @@ function innerResolveTypeReference(
   scope: TypeScope,
   name: string | string[],
   node: ReferenceTypes,
-  onlyExported: boolean
+  onlyExported: boolean,
 ): ScopeTypeNode | undefined {
   if (typeof name === 'string') {
     if (scope.imports[name]) {
@@ -761,7 +761,7 @@ function innerResolveTypeReference(
           childScope,
           name.length > 2 ? name.slice(1) : name[name.length - 1],
           node,
-          !ns.declare
+          !ns.declare,
         )
       }
     }
@@ -801,7 +801,7 @@ function resolveGlobalScope(ctx: TypeResolveContext): TypeScope[] | undefined {
       throw new Error('[vue/compiler-sfc] globalTypeFiles requires fs access.')
     }
     return ctx.options.globalTypeFiles.map(file =>
-      fileToScope(ctx, normalizePath(file), true)
+      fileToScope(ctx, normalizePath(file), true),
     )
   }
 }
@@ -823,11 +823,11 @@ export function registerTS(_loadTS: () => typeof TS) {
       ) {
         throw new Error(
           'Failed to load TypeScript, which is required for resolving imported types. ' +
-            'Please make sure "typescript" is installed as a project dependency.'
+            'Please make sure "typescript" is installed as a project dependency.',
         )
       } else {
         throw new Error(
-          'Failed to load TypeScript for resolving imported types.'
+          'Failed to load TypeScript for resolving imported types.',
         )
       }
     }
@@ -859,7 +859,7 @@ function resolveFS(ctx: TypeResolveContext): FS | undefined {
         file = file.replace(/\.ts$/, '')
       }
       return fs.readFile(file)
-    }
+    },
   })
 }
 
@@ -867,7 +867,7 @@ function resolveTypeFromImport(
   ctx: TypeResolveContext,
   node: ReferenceTypes,
   name: string,
-  scope: TypeScope
+  scope: TypeScope,
 ): ScopeTypeNode | undefined {
   const { source, imported } = scope.imports[name]
   const sourceScope = importSourceToScope(ctx, node, scope, source)
@@ -878,7 +878,7 @@ function importSourceToScope(
   ctx: TypeResolveContext,
   node: Node,
   scope: TypeScope,
-  source: string
+  source: string,
 ): TypeScope {
   let fs: FS | undefined
   try {
@@ -891,7 +891,7 @@ function importSourceToScope(
       `No fs option provided to \`compileScript\` in non-Node environment. ` +
         `File system access is required for resolving imported types.`,
       node,
-      scope
+      scope,
     )
   }
 
@@ -912,7 +912,7 @@ function importSourceToScope(
         return ctx.error(
           `Type import from non-relative sources is not supported in the browser build.`,
           node,
-          scope
+          scope,
         )
       }
       if (!ts) {
@@ -923,7 +923,7 @@ function importSourceToScope(
               `typescript is required as a peer dep for vue in order ` +
               `to support resolving types from module imports.`,
             node,
-            scope
+            scope,
           )
         }
       }
@@ -941,7 +941,7 @@ function importSourceToScope(
     return ctx.error(
       `Failed to resolve import source ${JSON.stringify(source)}.`,
       node,
-      scope
+      scope,
     )
   }
 }
@@ -973,7 +973,7 @@ function resolveWithTS(
   containingFile: string,
   source: string,
   ts: typeof TS,
-  fs: FS
+  fs: FS,
 ): string | undefined {
   if (!__NODE_JS__) return
 
@@ -1000,7 +1000,7 @@ function resolveWithTS(
       for (const c of configs) {
         const base = normalizePath(
           (c.config.options.pathsBasePath as string) ||
-            dirname(c.config.options.configFilePath as string)
+            dirname(c.config.options.configFilePath as string),
         )
         const included: string[] = c.config.raw?.include
         const excluded: string[] = c.config.raw?.exclude
@@ -1028,7 +1028,7 @@ function resolveWithTS(
       (matchedConfig.cache = ts.createModuleResolutionCache(
         process.cwd(),
         createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames),
-        tsCompilerOptions
+        tsCompilerOptions,
       ))
   } else {
     tsCompilerOptions = {}
@@ -1040,7 +1040,7 @@ function resolveWithTS(
     containingFile,
     tsCompilerOptions,
     fs,
-    tsResolveCache
+    tsResolveCache,
   )
 
   if (res.resolvedModule) {
@@ -1055,7 +1055,7 @@ function resolveWithTS(
 function loadTSConfig(
   configPath: string,
   ts: typeof TS,
-  fs: FS
+  fs: FS,
 ): TS.ParsedCommandLine[] {
   // The only case where `fs` is NOT `ts.sys` is during tests.
   // parse config host requires an extra `readDirectory` method
@@ -1064,7 +1064,7 @@ function loadTSConfig(
     ? {
         ...fs,
         useCaseSensitiveFileNames: true,
-        readDirectory: () => []
+        readDirectory: () => [],
       }
     : ts.sys
   const config = ts.parseJsonConfigFileContent(
@@ -1072,7 +1072,7 @@ function loadTSConfig(
     parseConfigHost,
     dirname(configPath),
     undefined,
-    configPath
+    configPath,
   )
   const res = [config]
   if (config.projectReferences) {
@@ -1100,7 +1100,7 @@ export function invalidateTypeCache(filename: string) {
 export function fileToScope(
   ctx: TypeResolveContext,
   filename: string,
-  asGlobal = false
+  asGlobal = false,
 ): TypeScope {
   const cached = fileToScopeCache.get(filename)
   if (cached) {
@@ -1119,7 +1119,7 @@ export function fileToScope(
 function parseFile(
   filename: string,
   content: string,
-  parserPlugins?: SFCScriptCompileOptions['babelParserPlugins']
+  parserPlugins?: SFCScriptCompileOptions['babelParserPlugins'],
 ): Statement[] {
   const ext = extname(filename)
   if (ext === '.ts' || ext === '.tsx') {
@@ -1127,13 +1127,13 @@ function parseFile(
       plugins: resolveParserPlugins(
         ext.slice(1),
         parserPlugins,
-        filename.endsWith('.d.ts')
+        filename.endsWith('.d.ts'),
       ),
-      sourceType: 'module'
+      sourceType: 'module',
     }).program.body
   } else if (ext === '.vue') {
     const {
-      descriptor: { script, scriptSetup }
+      descriptor: { script, scriptSetup },
     } = parse(content)
     if (!script && !scriptSetup) {
       return []
@@ -1158,7 +1158,7 @@ function parseFile(
     const lang = script?.lang || scriptSetup?.lang
     return babelParse(scriptContent, {
       plugins: resolveParserPlugins(lang!, parserPlugins),
-      sourceType: 'module'
+      sourceType: 'module',
     }).program.body
   }
   return []
@@ -1180,7 +1180,7 @@ function ctxToScope(ctx: TypeResolveContext): TypeScope {
     ctx.filename,
     ctx.source,
     'startOffset' in ctx ? ctx.startOffset! : 0,
-    'userImports' in ctx ? Object.create(ctx.userImports) : recordImports(body)
+    'userImports' in ctx ? Object.create(ctx.userImports) : recordImports(body),
   )
 
   recordTypes(ctx, body, scope)
@@ -1191,7 +1191,7 @@ function ctxToScope(ctx: TypeResolveContext): TypeScope {
 function moduleDeclToScope(
   ctx: TypeResolveContext,
   node: TSModuleDeclaration & { _resolvedChildScope?: TypeScope },
-  parentScope: TypeScope
+  parentScope: TypeScope,
 ): TypeScope {
   if (node._resolvedChildScope) {
     return node._resolvedChildScope
@@ -1218,7 +1218,7 @@ function createChildScope(parentScope: TypeScope) {
     parentScope.offset,
     Object.create(parentScope.imports),
     Object.create(parentScope.types),
-    Object.create(parentScope.declares)
+    Object.create(parentScope.declares),
   )
 }
 
@@ -1228,7 +1228,7 @@ function recordTypes(
   ctx: TypeResolveContext,
   body: Statement[],
   scope: TypeScope,
-  asGlobal = false
+  asGlobal = false,
 ) {
   const { types, declares, exportedTypes, exportedDeclares, imports } = scope
   const isAmbient = asGlobal
@@ -1264,15 +1264,15 @@ function recordTypes(
                 // re-export, register an import + export as a type reference
                 imports[exported] = {
                   source: stmt.source.value,
-                  imported: local
+                  imported: local,
                 }
                 exportedTypes[exported] = {
                   type: 'TSTypeReference',
                   typeName: {
                     type: 'Identifier',
-                    name: local
+                    name: local,
                   },
-                  _ownerScope: scope
+                  _ownerScope: scope,
                 }
               } else if (types[local]) {
                 // exporting local defined type
@@ -1286,7 +1286,7 @@ function recordTypes(
           ctx,
           stmt.source,
           scope,
-          stmt.source.value
+          stmt.source.value,
         )
         Object.assign(scope.exportedTypes, sourceScope.exportedTypes)
       } else if (stmt.type === 'ExportDefaultDeclaration' && stmt.declaration) {
@@ -1296,7 +1296,7 @@ function recordTypes(
             stmt.declaration,
             exportedTypes,
             exportedDeclares,
-            'default'
+            'default',
           )
         } else if (types[stmt.declaration.name]) {
           exportedTypes['default'] = types[stmt.declaration.name]
@@ -1318,7 +1318,7 @@ function recordType(
   node: Node,
   types: Record<string, Node>,
   declares: Record<string, Node>,
-  overwriteId?: string
+  overwriteId?: string,
 ) {
   switch (node.type) {
     case 'TSInterfaceDeclaration':
@@ -1393,7 +1393,7 @@ function mergeNamespaces(to: TSModuleDeclaration, from: TSModuleDeclaration) {
         type: 'ExportNamedDeclaration',
         declaration: toBody,
         exportKind: 'type',
-        specifiers: []
+        specifiers: [],
       })
     }
   } else if (fromBody.type === 'TSModuleDeclaration') {
@@ -1402,7 +1402,7 @@ function mergeNamespaces(to: TSModuleDeclaration, from: TSModuleDeclaration) {
       type: 'ExportNamedDeclaration',
       declaration: fromBody,
       exportKind: 'type',
-      specifiers: []
+      specifiers: [],
     })
   } else {
     // both block
@@ -1412,7 +1412,7 @@ function mergeNamespaces(to: TSModuleDeclaration, from: TSModuleDeclaration) {
 
 function attachNamespace(
   to: Node & { _ns?: TSModuleDeclaration },
-  ns: TSModuleDeclaration
+  ns: TSModuleDeclaration,
 ) {
   if (!to._ns) {
     to._ns = ns
@@ -1436,7 +1436,7 @@ function recordImport(node: Node, imports: TypeScope['imports']) {
   for (const s of node.specifiers) {
     imports[s.local.name] = {
       imported: getImportedName(s),
-      source: node.source.value
+      source: node.source.value,
     }
   }
 }
@@ -1444,7 +1444,7 @@ function recordImport(node: Node, imports: TypeScope['imports']) {
 export function inferRuntimeType(
   ctx: TypeResolveContext,
   node: Node & MaybeWithScope,
-  scope = node._ownerScope || ctxToScope(ctx)
+  scope = node._ownerScope || ctxToScope(ctx),
 ): string[] {
   try {
     switch (node.type) {
@@ -1481,7 +1481,7 @@ export function inferRuntimeType(
           return inferRuntimeType(
             ctx,
             node.typeAnnotation.typeAnnotation,
-            scope
+            scope,
           )
         }
         break
@@ -1551,7 +1551,7 @@ export function inferRuntimeType(
                 return inferRuntimeType(
                   ctx,
                   node.typeParameters.params[0],
-                  scope
+                  scope,
                 ).filter(t => t !== 'null')
               }
               break
@@ -1560,7 +1560,7 @@ export function inferRuntimeType(
                 return inferRuntimeType(
                   ctx,
                   node.typeParameters.params[1],
-                  scope
+                  scope,
                 )
               }
               break
@@ -1570,7 +1570,7 @@ export function inferRuntimeType(
                 return inferRuntimeType(
                   ctx,
                   node.typeParameters.params[0],
-                  scope
+                  scope,
                 )
               }
               break
@@ -1587,7 +1587,7 @@ export function inferRuntimeType(
         return flattenTypes(ctx, node.types, scope)
       case 'TSIntersectionType': {
         return flattenTypes(ctx, node.types, scope).filter(
-          t => t !== UNKNOWN_TYPE
+          t => t !== UNKNOWN_TYPE,
         )
       }
 
@@ -1610,7 +1610,7 @@ export function inferRuntimeType(
           ctx,
           node.argument,
           scope,
-          node.argument.value
+          node.argument.value,
         )
         const resolved = resolveTypeReference(ctx, node, sourceScope)
         if (resolved) {
@@ -1640,7 +1640,7 @@ export function inferRuntimeType(
 function flattenTypes(
   ctx: TypeResolveContext,
   types: TSType[],
-  scope: TypeScope
+  scope: TypeScope,
 ): string[] {
   if (types.length === 1) {
     return inferRuntimeType(ctx, types[0], scope)
@@ -1648,9 +1648,9 @@ function flattenTypes(
   return [
     ...new Set(
       ([] as string[]).concat(
-        ...types.map(t => inferRuntimeType(ctx, t, scope))
-      )
-    )
+        ...types.map(t => inferRuntimeType(ctx, t, scope)),
+      ),
+    ),
   ]
 }
 
@@ -1677,7 +1677,7 @@ function inferEnumType(node: TSEnumDeclaration): string[] {
  */
 function resolveExtractPropTypes(
   { props }: ResolvedElements,
-  scope: TypeScope
+  scope: TypeScope,
 ): ResolvedElements {
   const res: ResolvedElements = { props: {} }
   for (const key in props) {
@@ -1685,7 +1685,7 @@ function resolveExtractPropTypes(
     res.props[key] = reverseInferType(
       raw.key,
       raw.typeAnnotation!.typeAnnotation,
-      scope
+      scope,
     )
   }
   return res
@@ -1696,7 +1696,7 @@ function reverseInferType(
   node: TSType,
   scope: TypeScope,
   optional = true,
-  checkObjectSyntax = true
+  checkObjectSyntax = true,
 ): TSPropertySignature & WithScope {
   if (checkObjectSyntax && node.type === 'TSTypeLiteral') {
     // check { type: xxx }
@@ -1720,7 +1720,7 @@ function reverseInferType(
         key,
         ctorToType(node.typeName.name),
         scope,
-        optional
+        optional,
       )
     } else if (node.typeName.name === 'PropType' && node.typeParameters) {
       // PropType<{}>
@@ -1758,7 +1758,7 @@ function ctorToType(ctorType: string): TSType {
     case 'Promise':
       return {
         type: 'TSTypeReference',
-        typeName: { type: 'Identifier', name: ctor }
+        typeName: { type: 'Identifier', name: ctor },
       }
   }
   // fallback to null
@@ -1771,7 +1771,7 @@ function findStaticPropertyType(node: TSTypeLiteral, key: string) {
       m.type === 'TSPropertySignature' &&
       !m.computed &&
       getId(m.key) === key &&
-      m.typeAnnotation
+      m.typeAnnotation,
   )
   return prop && prop.typeAnnotation!.typeAnnotation
 }
@@ -1779,7 +1779,7 @@ function findStaticPropertyType(node: TSTypeLiteral, key: string) {
 function resolveReturnType(
   ctx: TypeResolveContext,
   arg: Node,
-  scope: TypeScope
+  scope: TypeScope,
 ) {
   let resolved: Node | undefined = arg
   if (
@@ -1801,7 +1801,7 @@ function resolveReturnType(
 export function resolveUnionType(
   ctx: TypeResolveContext,
   node: Node & MaybeWithScope & { _resolvedElements?: ResolvedElements },
-  scope?: TypeScope
+  scope?: TypeScope,
 ): Node[] {
   if (node.type === 'TSTypeReference') {
     const resolved = resolveTypeReference(ctx, node, scope)
index 26534ee9576a91fb18bbec610a4c9689c6ff5b92..09955ac54e4c8cfcf9d24f19cef59458dffa0649 100644 (file)
@@ -1,5 +1,5 @@
-import { AwaitExpression } from '@babel/types'
-import { ScriptCompileContext } from './context'
+import type { AwaitExpression } from '@babel/types'
+import type { ScriptCompileContext } from './context'
 
 /**
  * Support context-persistence between top-level await expressions:
@@ -38,7 +38,7 @@ export function processAwait(
   ctx: ScriptCompileContext,
   node: AwaitExpression,
   needSemi: boolean,
-  isStatement: boolean
+  isStatement: boolean,
 ) {
   const argumentStart =
     node.argument.extra && node.argument.extra.parenthesized
@@ -48,7 +48,7 @@ export function processAwait(
   const startOffset = ctx.startOffset!
   const argumentStr = ctx.descriptor.source.slice(
     argumentStart + startOffset,
-    node.argument.end! + startOffset
+    node.argument.end! + startOffset,
   )
 
   const containsNestedAwait = /\bawait\b/.test(argumentStr)
@@ -57,13 +57,13 @@ export function processAwait(
     node.start! + startOffset,
     argumentStart + startOffset,
     `${needSemi ? `;` : ``}(\n  ([__temp,__restore] = ${ctx.helper(
-      `withAsyncContext`
-    )}(${containsNestedAwait ? `async ` : ``}() => `
+      `withAsyncContext`,
+    )}(${containsNestedAwait ? `async ` : ``}() => `,
   )
   ctx.s.appendLeft(
     node.end! + startOffset,
     `)),\n  ${isStatement ? `` : `__temp = `}await __temp,\n  __restore()${
       isStatement ? `` : `,\n  __temp`
-    }\n)`
+    }\n)`,
   )
 }
index a1124ce81b1ad8a33e14c0f5317164996f9c6ffb..38e6bf9375056a3888575b77e6a47cab74bf4fa1 100644 (file)
@@ -1,4 +1,4 @@
-import {
+import type {
   CallExpression,
   Expression,
   Identifier,
@@ -6,7 +6,7 @@ import {
   ImportNamespaceSpecifier,
   ImportSpecifier,
   Node,
-  StringLiteral
+  StringLiteral,
 } from '@babel/types'
 import path from 'path'
 
@@ -33,7 +33,7 @@ export function isLiteralNode(node: Node) {
 
 export function isCallOf(
   node: Node | null | undefined,
-  test: string | ((id: string) => boolean) | null | undefined
+  test: string | ((id: string) => boolean) | null | undefined,
 ): node is CallExpression {
   return !!(
     node &&
@@ -51,7 +51,10 @@ export function toRuntimeTypeString(types: string[]) {
 }
 
 export function getImportedName(
-  specifier: ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
+  specifier:
+    | ImportSpecifier
+    | ImportDefaultSpecifier
+    | ImportNamespaceSpecifier,
 ) {
   if (specifier.type === 'ImportSpecifier')
     return specifier.imported.type === 'Identifier'
@@ -114,6 +117,6 @@ export const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g
 
 export function getEscapedCssVarName(key: string, doubleEscape: boolean) {
   return key.replace(cssVarNameEscapeSymbolsRE, s =>
-    doubleEscape ? `\\\\${s}` : `\\${s}`
+    doubleEscape ? `\\\\${s}` : `\\${s}`,
   )
 }
index 1ea64bbc387e079aef6b0877946dd71cd544fab7..47bb7c083bb2579fa29a4c090d279fee8daf55c2 100644 (file)
@@ -1,15 +1,15 @@
 import {
-  processExpression,
-  createTransformContext,
-  createSimpleExpression,
-  createRoot,
+  type BindingMetadata,
   NodeTypes,
-  SimpleExpressionNode,
-  BindingMetadata
+  type SimpleExpressionNode,
+  createRoot,
+  createSimpleExpression,
+  createTransformContext,
+  processExpression,
 } from '@vue/compiler-dom'
-import { SFCDescriptor } from '../parse'
+import type { SFCDescriptor } from '../parse'
 import { getEscapedCssVarName } from '../script/utils'
-import { PluginCreator } from 'postcss'
+import type { PluginCreator } from 'postcss'
 import hash from 'hash-sum'
 
 export const CSS_VARS_HELPER = `useCssVars`
@@ -18,12 +18,12 @@ export function genCssVarsFromList(
   vars: string[],
   id: string,
   isProd: boolean,
-  isSSR = false
+  isSSR = false,
 ): string {
   return `{\n  ${vars
     .map(
       key =>
-        `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`
+        `"${isSSR ? `--` : ``}${genVarName(id, key, isProd, isSSR)}": (${key})`,
     )
     .join(',\n  ')}\n}`
 }
@@ -32,7 +32,7 @@ function genVarName(
   id: string,
   raw: string,
   isProd: boolean,
-  isSSR = false
+  isSSR = false,
 ): string {
   if (isProd) {
     return hash(id + raw)
@@ -81,7 +81,7 @@ export function parseCssVars(sfc: SFCDescriptor): string[] {
 enum LexerState {
   inParens,
   inSingleQuoteString,
-  inDoubleQuoteString
+  inDoubleQuoteString,
 }
 
 function lexBinding(content: string, start: number): number | null {
@@ -152,7 +152,7 @@ export const cssVarsPlugin: PluginCreator<CssVarsPluginOptions> = opts => {
         }
         decl.value = transformed + value.slice(lastIndex)
       }
-    }
+    },
   }
 }
 cssVarsPlugin.postcss = true
@@ -161,14 +161,14 @@ export function genCssVarsCode(
   vars: string[],
   bindings: BindingMetadata,
   id: string,
-  isProd: boolean
+  isProd: boolean,
 ) {
   const varsExp = genCssVarsFromList(vars, id, isProd)
   const exp = createSimpleExpression(varsExp, false)
   const context = createTransformContext(createRoot([]), {
     prefixIdentifiers: true,
     inline: true,
-    bindingMetadata: bindings.__isScriptSetup === false ? undefined : bindings
+    bindingMetadata: bindings.__isScriptSetup === false ? undefined : bindings,
   })
   const transformed = processExpression(exp, context)
   const transformedString =
@@ -192,7 +192,7 @@ export function genNormalScriptCssVarsCode(
   bindings: BindingMetadata,
   id: string,
   isProd: boolean,
-  defaultVar: string
+  defaultVar: string,
 ): string {
   return (
     `\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\n` +
@@ -200,7 +200,7 @@ export function genNormalScriptCssVarsCode(
       cssVars,
       bindings,
       id,
-      isProd
+      isProd,
     )}}\n` +
     `const __setup__ = ${defaultVar}.setup\n` +
     `${defaultVar}.setup = __setup__\n` +
index f71c304f50224207146bf2b85ff9461aa0f8255f..c5e018961305515ae9bd3f97fcf805cee326e149 100644 (file)
@@ -1,4 +1,4 @@
-import { PluginCreator, Rule, AtRule } from 'postcss'
+import type { AtRule, PluginCreator, Rule } from 'postcss'
 import selectorParser from 'postcss-selector-parser'
 import { warn } from '../warn'
 
@@ -55,7 +55,7 @@ const scopedPlugin: PluginCreator<string> = (id = '') => {
           }
         })
       }
-    }
+    },
   }
 }
 
@@ -82,7 +82,7 @@ function rewriteSelector(
   id: string,
   selector: selectorParser.Selector,
   selectorRoot: selectorParser.Root,
-  slotted = false
+  slotted = false,
 ) {
   let node: selectorParser.Node | null = null
   let shouldInject = true
@@ -97,7 +97,7 @@ function rewriteSelector(
       n.spaces.before = n.spaces.after = ''
       warn(
         `the >>> and /deep/ combinators have been deprecated. ` +
-          `Use :deep() instead.`
+          `Use :deep() instead.`,
       )
       return false
     }
@@ -121,8 +121,8 @@ function rewriteSelector(
             selector.insertAfter(
               n,
               selectorParser.combinator({
-                value: ' '
-              })
+                value: ' ',
+              }),
             )
           }
           selector.removeChild(n)
@@ -131,7 +131,7 @@ function rewriteSelector(
           // .foo ::v-deep .bar -> .foo[xxxxxxx] .bar
           warn(
             `${value} usage as a combinator has been deprecated. ` +
-              `Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`
+              `Use :deep(<inner-selector>) instead of ${value} <inner-selector>.`,
           )
 
           const prev = selector.at(selector.index(n) - 1)
@@ -182,7 +182,7 @@ function rewriteSelector(
     const { type, value } = node as selectorParser.Node
     if (type === 'pseudo' && (value === ':is' || value === ':where')) {
       ;(node as selectorParser.Pseudo).nodes.forEach(value =>
-        rewriteSelector(id, value, selectorRoot, slotted)
+        rewriteSelector(id, value, selectorRoot, slotted),
       )
       shouldInject = false
     }
@@ -207,8 +207,8 @@ function rewriteSelector(
         attribute: idToAdd,
         value: idToAdd,
         raws: {},
-        quoteMark: `"`
-      })
+        quoteMark: `"`,
+      }),
     )
   }
 }
index 67c4a3f0f3556d9d4b32642adfba72f64cfc142a..ab5283438a6041b7dcf9f201d77229502cca401a 100644 (file)
@@ -1,4 +1,4 @@
-import { PluginCreator } from 'postcss'
+import type { PluginCreator } from 'postcss'
 
 const trimPlugin: PluginCreator<{}> = () => {
   return {
@@ -10,7 +10,7 @@ const trimPlugin: PluginCreator<{}> = () => {
           if ('after' in raws && raws.after) raws.after = '\n'
         }
       })
-    }
+    },
   }
 }
 
index e4630745667d05b4f97b1d1462083cac77bbf69a..b09c3ec98c252cb27ed8e1894f12fc1c0f8a00b3 100644 (file)
@@ -1,6 +1,6 @@
 import merge from 'merge-source-map'
-import { RawSourceMap } from 'source-map-js'
-import { SFCStyleCompileOptions } from '../compileStyle'
+import type { RawSourceMap } from 'source-map-js'
+import type { SFCStyleCompileOptions } from '../compileStyle'
 import { isFunction } from '@vue/shared'
 
 export type StylePreprocessor = (
@@ -11,7 +11,7 @@ export type StylePreprocessor = (
     additionalData?: string | ((source: string, filename: string) => string)
     filename: string
   },
-  customRequire: SFCStyleCompileOptions['preprocessCustomRequire']
+  customRequire: SFCStyleCompileOptions['preprocessCustomRequire'],
 ) => StylePreprocessorResults
 
 export interface StylePreprocessorResults {
@@ -29,7 +29,7 @@ const scss: StylePreprocessor = (source, map, options, load = require) => {
     data: getSource(source, options.filename, options.additionalData),
     file: options.filename,
     outFile: options.filename,
-    sourceMap: !!map
+    sourceMap: !!map,
   }
 
   try {
@@ -42,10 +42,10 @@ const scss: StylePreprocessor = (source, map, options, load = require) => {
           map,
           result.map.toJSON
             ? result.map.toJSON()
-            : JSON.parse(result.map.toString())
+            : JSON.parse(result.map.toString()),
         ),
         errors: [],
-        dependencies
+        dependencies,
       }
     }
 
@@ -61,9 +61,9 @@ const sass: StylePreprocessor = (source, map, options, load) =>
     map,
     {
       ...options,
-      indentedSyntax: true
+      indentedSyntax: true,
     },
-    load
+    load,
   )
 
 // .less
@@ -78,7 +78,7 @@ const less: StylePreprocessor = (source, map, options, load = require) => {
     (err: Error | null, output: any) => {
       error = err
       result = output
-    }
+    },
   )
 
   if (error) return { code: '', errors: [error], dependencies: [] }
@@ -88,14 +88,14 @@ const less: StylePreprocessor = (source, map, options, load = require) => {
       code: result.css.toString(),
       map: merge(map, result.map),
       errors: [],
-      dependencies: dependencies
+      dependencies: dependencies,
     }
   }
 
   return {
     code: result.css.toString(),
     errors: [],
-    dependencies: dependencies
+    dependencies: dependencies,
   }
 }
 
@@ -113,7 +113,7 @@ const styl: StylePreprocessor = (source, map, options, load = require) => {
         code: result,
         map: merge(map, ref.sourcemap),
         errors: [],
-        dependencies
+        dependencies,
       }
     }
 
@@ -126,7 +126,7 @@ const styl: StylePreprocessor = (source, map, options, load = require) => {
 function getSource(
   source: string,
   filename: string,
-  additionalData?: string | ((source: string, filename: string) => string)
+  additionalData?: string | ((source: string, filename: string) => string),
 ) {
   if (!additionalData) return source
   if (isFunction(additionalData)) {
@@ -142,5 +142,5 @@ export const processors: Record<PreprocessLang, StylePreprocessor> = {
   sass,
   scss,
   styl,
-  stylus: styl
+  stylus: styl,
 }
index 0966945a5ee55cedf8fe1f07757277f1e62cc99b..c1414d1ecbdb3dc992943044d1d92fdfeee5eaab 100644 (file)
@@ -1,4 +1,4 @@
-import { UrlWithStringQuery, parse as uriParse } from 'url'
+import { type UrlWithStringQuery, parse as uriParse } from 'url'
 import { isString } from '@vue/shared'
 
 export function isRelativeUrl(url: string): boolean {
index 4267d4ea3529719a4023e11e683aaf039ac6f482..6291e21bbba29c9a0bc30b85b5d9b767a91a24bf 100644 (file)
@@ -1,19 +1,19 @@
 import path from 'path'
 import {
   ConstantTypes,
-  createSimpleExpression,
-  ExpressionNode,
-  NodeTransform,
+  type ExpressionNode,
+  type NodeTransform,
   NodeTypes,
-  SimpleExpressionNode,
-  SourceLocation,
-  TransformContext
+  type SimpleExpressionNode,
+  type SourceLocation,
+  type TransformContext,
+  createSimpleExpression,
 } from '@vue/compiler-core'
 import {
+  isDataUrl,
+  isExternalUrl,
   isRelativeUrl,
   parseUrl,
-  isExternalUrl,
-  isDataUrl
 } from './templateUtils'
 import { isArray } from '@vue/shared'
 
@@ -42,28 +42,28 @@ export const defaultAssetUrlOptions: Required<AssetURLOptions> = {
     source: ['src'],
     img: ['src'],
     image: ['xlink:href', 'href'],
-    use: ['xlink:href', 'href']
-  }
+    use: ['xlink:href', 'href'],
+  },
 }
 
 export const normalizeOptions = (
-  options: AssetURLOptions | AssetURLTagConfig
+  options: AssetURLOptions | AssetURLTagConfig,
 ): Required<AssetURLOptions> => {
   if (Object.keys(options).some(key => isArray((options as any)[key]))) {
     // legacy option format which directly passes in tags config
     return {
       ...defaultAssetUrlOptions,
-      tags: options as any
+      tags: options as any,
     }
   }
   return {
     ...defaultAssetUrlOptions,
-    ...options
+    ...options,
   }
 }
 
 export const createAssetUrlTransformWithOptions = (
-  options: Required<AssetURLOptions>
+  options: Required<AssetURLOptions>,
 ): NodeTransform => {
   return (node, context) =>
     (transformAssetUrl as Function)(node, context, options)
@@ -85,7 +85,7 @@ export const createAssetUrlTransformWithOptions = (
 export const transformAssetUrl: NodeTransform = (
   node,
   context,
-  options: AssetURLOptions = defaultAssetUrlOptions
+  options: AssetURLOptions = defaultAssetUrlOptions,
 ) => {
   if (node.type === NodeTypes.ELEMENT) {
     if (!node.props.length) {
@@ -141,7 +141,7 @@ export const transformAssetUrl: NodeTransform = (
         arg: createSimpleExpression(attr.name, true, attr.loc),
         exp,
         modifiers: [],
-        loc: attr.loc
+        loc: attr.loc,
       }
     })
   }
@@ -151,7 +151,7 @@ function getImportsExpressionExp(
   path: string | null,
   hash: string | null,
   loc: SourceLocation,
-  context: TransformContext
+  context: TransformContext,
 ): ExpressionNode {
   if (path) {
     let name: string
@@ -166,14 +166,14 @@ function getImportsExpressionExp(
         name,
         false,
         loc,
-        ConstantTypes.CAN_STRINGIFY
+        ConstantTypes.CAN_STRINGIFY,
       )
 
       // We need to ensure the path is not encoded (to %2F),
       // so we decode it back in case it is encoded
       context.imports.push({
         exp,
-        path: decodeURIComponent(path)
+        path: decodeURIComponent(path),
       })
     }
 
@@ -186,7 +186,7 @@ function getImportsExpressionExp(
       hashExp,
       false,
       loc,
-      ConstantTypes.CAN_STRINGIFY
+      ConstantTypes.CAN_STRINGIFY,
     )
 
     if (!context.hoistStatic) {
@@ -206,7 +206,7 @@ function getImportsExpressionExp(
         `_hoisted_${existingHoistIndex + 1}`,
         false,
         loc,
-        ConstantTypes.CAN_STRINGIFY
+        ConstantTypes.CAN_STRINGIFY,
       )
     }
     return context.hoist(finalExp)
index 18b9d0b0b3bfe51ac67640ab755fe301e7c3bedf..8f00f86e3c3ac79d4becba78c1c8c7729219ff46 100644 (file)
@@ -1,20 +1,23 @@
 import path from 'path'
 import {
   ConstantTypes,
+  type ExpressionNode,
+  type NodeTransform,
+  NodeTypes,
+  type SimpleExpressionNode,
   createCompoundExpression,
   createSimpleExpression,
-  ExpressionNode,
-  NodeTransform,
-  NodeTypes,
-  SimpleExpressionNode
 } from '@vue/compiler-core'
 import {
+  isDataUrl,
+  isExternalUrl,
   isRelativeUrl,
   parseUrl,
-  isExternalUrl,
-  isDataUrl
 } from './templateUtils'
-import { AssetURLOptions, defaultAssetUrlOptions } from './transformAssetUrl'
+import {
+  type AssetURLOptions,
+  defaultAssetUrlOptions,
+} from './transformAssetUrl'
 
 const srcsetTags = ['img', 'source']
 
@@ -27,7 +30,7 @@ interface ImageCandidate {
 const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g
 
 export const createSrcsetTransformWithOptions = (
-  options: Required<AssetURLOptions>
+  options: Required<AssetURLOptions>,
 ): NodeTransform => {
   return (node, context) =>
     (transformSrcset as Function)(node, context, options)
@@ -36,7 +39,7 @@ export const createSrcsetTransformWithOptions = (
 export const transformSrcset: NodeTransform = (
   node,
   context,
-  options: Required<AssetURLOptions> = defaultAssetUrlOptions
+  options: Required<AssetURLOptions> = defaultAssetUrlOptions,
 ) => {
   if (node.type === NodeTypes.ELEMENT) {
     if (srcsetTags.includes(node.tag) && node.props.length) {
@@ -109,21 +112,21 @@ export const transformSrcset: NodeTransform = (
               let exp: SimpleExpressionNode
               if (path) {
                 const existingImportsIndex = context.imports.findIndex(
-                  i => i.path === path
+                  i => i.path === path,
                 )
                 if (existingImportsIndex > -1) {
                   exp = createSimpleExpression(
                     `_imports_${existingImportsIndex}`,
                     false,
                     attr.loc,
-                    ConstantTypes.CAN_STRINGIFY
+                    ConstantTypes.CAN_STRINGIFY,
                   )
                 } else {
                   exp = createSimpleExpression(
                     `_imports_${context.imports.length}`,
                     false,
                     attr.loc,
-                    ConstantTypes.CAN_STRINGIFY
+                    ConstantTypes.CAN_STRINGIFY,
                   )
                   context.imports.push({ exp, path })
                 }
@@ -134,7 +137,7 @@ export const transformSrcset: NodeTransform = (
                 `"${url}"`,
                 false,
                 attr.loc,
-                ConstantTypes.CAN_STRINGIFY
+                ConstantTypes.CAN_STRINGIFY,
               )
               compoundExpression.children.push(exp)
             }
@@ -160,7 +163,7 @@ export const transformSrcset: NodeTransform = (
             arg: createSimpleExpression('srcset', true, attr.loc),
             exp,
             modifiers: [],
-            loc: attr.loc
+            loc: attr.loc,
           }
         }
       })
index 13cfa4da7272dc02ed9d65d4d7579afec9aebf77..29bed4dc509660be395a5b7cd1ed6acd13857bc7 100644 (file)
@@ -11,6 +11,6 @@ export function warnOnce(msg: string) {
 
 export function warn(msg: string) {
   console.warn(
-    `\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`
+    `\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`,
   )
 }
index f25214f52f5db5eef2c127fde1490eb770bff065..2fde4560ec43e4e81dfc0848e4ac5aa4c4d14ccb 100644 (file)
@@ -114,7 +114,7 @@ describe('ssr: components', () => {
         compile(`<foo>
         <template v-slot>foo</template>
         <template v-slot:named>bar</template>
-      </foo>`).code
+      </foo>`).code,
       ).toMatchInlineSnapshot(`
         "const { resolveComponent: _resolveComponent, withCtx: _withCtx, createTextVNode: _createTextVNode } = require("vue")
         const { ssrRenderComponent: _ssrRenderComponent } = require("vue/server-renderer")
@@ -151,7 +151,7 @@ describe('ssr: components', () => {
       expect(
         compile(`<foo>
         <template v-slot:named v-if="ok">foo</template>
-      </foo>`).code
+      </foo>`).code,
       ).toMatchInlineSnapshot(`
         "const { resolveComponent: _resolveComponent, withCtx: _withCtx, createTextVNode: _createTextVNode, createSlots: _createSlots } = require("vue")
         const { ssrRenderComponent: _ssrRenderComponent } = require("vue/server-renderer")
@@ -228,7 +228,7 @@ describe('ssr: components', () => {
             <span v-for="i in list"></span>
           </div>
         </template>
-      </foo>`).code
+      </foo>`).code,
       ).toMatchInlineSnapshot(`
         "const { resolveComponent: _resolveComponent, withCtx: _withCtx, renderList: _renderList, Fragment: _Fragment, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode } = require("vue")
         const { ssrRenderComponent: _ssrRenderComponent, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
@@ -347,7 +347,7 @@ describe('ssr: components', () => {
       test('should push marker string if is slot root', () => {
         expect(
           compile(`<foo><transition><div v-if="false"/></transition></foo>`)
-            .code
+            .code,
         ).toMatchInlineSnapshot(`
           "const { resolveComponent: _resolveComponent, withCtx: _withCtx, openBlock: _openBlock, createBlock: _createBlock, createCommentVNode: _createCommentVNode, Transition: _Transition, createVNode: _createVNode } = require("vue")
           const { ssrRenderComponent: _ssrRenderComponent } = require("vue/server-renderer")
index 6e51826d9c9d4a94ba552f2f730c4012c1339f75..8f0e28f4e146b19f0381973f7cd1bc3a334fcb99 100644 (file)
@@ -4,16 +4,16 @@ import { compile } from '../src'
 describe('ssr: element', () => {
   test('basic elements', () => {
     expect(getCompiledString(`<div></div>`)).toMatchInlineSnapshot(
-      `"\`<div></div>\`"`
+      `"\`<div></div>\`"`,
     )
     expect(getCompiledString(`<div/>`)).toMatchInlineSnapshot(
-      `"\`<div></div>\`"`
+      `"\`<div></div>\`"`,
     )
   })
 
   test('nested elements', () => {
     expect(
-      getCompiledString(`<div><span></span><span></span></div>`)
+      getCompiledString(`<div><span></span><span></span></div>`),
     ).toMatchInlineSnapshot(`"\`<div><span></span><span></span></div>\`"`)
   })
 
@@ -49,7 +49,7 @@ describe('ssr: element', () => {
 
     test('<textarea> with static value', () => {
       expect(
-        getCompiledString(`<textarea value="fo&gt;o"/>`)
+        getCompiledString(`<textarea value="fo&gt;o"/>`),
       ).toMatchInlineSnapshot(`"\`<textarea>fo&gt;o</textarea>\`"`)
     })
 
@@ -73,7 +73,7 @@ describe('ssr: element', () => {
 
     test('multiple _ssrInterpolate at parent and child import dependency once', () => {
       expect(
-        compile(`<div>{{ hello }}<textarea v-bind="a"></textarea></div>`).code
+        compile(`<div>{{ hello }}<textarea v-bind="a"></textarea></div>`).code,
       ).toMatchInlineSnapshot(`
         "const { ssrRenderAttrs: _ssrRenderAttrs, ssrInterpolate: _ssrInterpolate } = require("vue/server-renderer")
 
@@ -96,8 +96,8 @@ describe('ssr: element', () => {
     test('should pass tag to custom elements w/ dynamic v-bind', () => {
       expect(
         compile(`<my-foo v-bind="obj"></my-foo>`, {
-          isCustomElement: () => true
-        }).code
+          isCustomElement: () => true,
+        }).code,
       ).toMatchInlineSnapshot(`
         "const { mergeProps: _mergeProps } = require("vue")
         const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
@@ -112,19 +112,19 @@ describe('ssr: element', () => {
   describe('attrs', () => {
     test('static attrs', () => {
       expect(
-        getCompiledString(`<div id="foo" class="bar"></div>`)
+        getCompiledString(`<div id="foo" class="bar"></div>`),
       ).toMatchInlineSnapshot(`"\`<div id="foo" class="bar"></div>\`"`)
     })
 
     test('ignore static key/ref', () => {
       expect(
-        getCompiledString(`<div key="1" ref="el"></div>`)
+        getCompiledString(`<div key="1" ref="el"></div>`),
       ).toMatchInlineSnapshot(`"\`<div></div>\`"`)
     })
 
     test('ignore v-bind key/ref', () => {
       expect(
-        getCompiledString(`<div :key="1" :ref="el"></div>`)
+        getCompiledString(`<div :key="1" :ref="el"></div>`),
       ).toMatchInlineSnapshot(`"\`<div></div>\`"`)
     })
 
@@ -263,8 +263,8 @@ describe('ssr: element', () => {
       // should merge style and :style
       expect(
         getCompiledString(
-          `<div style="color:red;" :style="b" v-bind="obj"></div>`
-        )
+          `<div style="color:red;" :style="b" v-bind="obj"></div>`,
+        ),
       ).toMatchInlineSnapshot(`
         "\`<div\${
             _ssrRenderAttrs(_mergeProps({
@@ -276,10 +276,10 @@ describe('ssr: element', () => {
 
     test('should ignore v-on', () => {
       expect(
-        getCompiledString(`<div id="foo" @click="bar"/>`)
+        getCompiledString(`<div id="foo" @click="bar"/>`),
       ).toMatchInlineSnapshot(`"\`<div id="foo"></div>\`"`)
       expect(
-        getCompiledString(`<div id="foo" v-on="bar"/>`)
+        getCompiledString(`<div id="foo" v-on="bar"/>`),
       ).toMatchInlineSnapshot(`"\`<div id="foo"></div>\`"`)
       expect(getCompiledString(`<div v-bind="foo" v-on="bar"/>`))
         .toMatchInlineSnapshot(`
@@ -329,7 +329,7 @@ describe('ssr: element', () => {
 
     test('custom dir with object v-bind + normal bindings', () => {
       expect(
-        getCompiledString(`<div v-bind="x" class="foo" v-xxx title="bar" />`)
+        getCompiledString(`<div v-bind="x" class="foo" v-xxx title="bar" />`),
       ).toMatchInlineSnapshot(`
         "\`<div\${
             _ssrRenderAttrs(_mergeProps(_ctx.x, {
index 2ed04a16fe5e020872ba18fbda581ff8a5341385..9e70dac0bdca3cc1f535def98297eddd0a1692e2 100644 (file)
@@ -5,8 +5,8 @@ describe('ssr: inject <style vars>', () => {
   test('basic', () => {
     expect(
       compile(`<div/>`, {
-        ssrCssVars: `{ color }`
-      }).code
+        ssrCssVars: `{ color }`,
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { mergeProps: _mergeProps } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
@@ -21,8 +21,8 @@ describe('ssr: inject <style vars>', () => {
   test('fragment', () => {
     expect(
       compile(`<div/><div/>`, {
-        ssrCssVars: `{ color }`
-      }).code
+        ssrCssVars: `{ color }`,
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -40,8 +40,8 @@ describe('ssr: inject <style vars>', () => {
   test('passing on to components', () => {
     expect(
       compile(`<div/><foo/>`, {
-        ssrCssVars: `{ color }`
-      }).code
+        ssrCssVars: `{ color }`,
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { resolveComponent: _resolveComponent } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs, ssrRenderComponent: _ssrRenderComponent } = require("vue/server-renderer")
@@ -60,8 +60,8 @@ describe('ssr: inject <style vars>', () => {
   test('v-if branches', () => {
     expect(
       compile(`<div v-if="ok"/><template v-else><div/><div/></template>`, {
-        ssrCssVars: `{ color }`
-      }).code
+        ssrCssVars: `{ color }`,
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { mergeProps: _mergeProps } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
@@ -91,9 +91,9 @@ describe('ssr: inject <style vars>', () => {
           </template>
         </Suspense>`,
         {
-          ssrCssVars: `{ color }`
-        }
-      ).code
+          ssrCssVars: `{ color }`,
+        },
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { withCtx: _withCtx } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs, ssrRenderSuspense: _ssrRenderSuspense } = require("vue/server-renderer")
@@ -117,7 +117,7 @@ describe('ssr: inject <style vars>', () => {
     const result = compile(`<div/>`, {
       inline: true,
       bindingMetadata: { dynamic: BindingTypes.SETUP_MAYBE_REF },
-      ssrCssVars: '{ "--hash": (dynamic) }'
+      ssrCssVars: '{ "--hash": (dynamic) }',
     })
 
     expect(result.code).toMatchInlineSnapshot(`
index ac02c88422081022d886e81d148d31a352b14ad7..bb262fad0fd5f3b32fc19b2c0a877e87d3d62d57 100644 (file)
@@ -27,7 +27,7 @@ describe('ssr compile: teleport', () => {
       `)
 
     expect(
-      compile(`<teleport :to="target" :disabled="foo"><div/></teleport>`).code
+      compile(`<teleport :to="target" :disabled="foo"><div/></teleport>`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderTeleport: _ssrRenderTeleport } = require("vue/server-renderer")
 
index 7841e571e8214bbb6a88a71ec620ad72d9cddc60..c3bfd7d8f6e80543498d0c55c175cd19ed84d05d 100644 (file)
@@ -7,8 +7,8 @@ describe('ssr: scopeId', () => {
     expect(
       compile(`<div><span>hello</span></div>`, {
         scopeId,
-        mode: 'module'
-      }).code
+        mode: 'module',
+      }).code,
     ).toMatchInlineSnapshot(`
       "import { ssrRenderAttrs as _ssrRenderAttrs } from "vue/server-renderer"
 
@@ -23,8 +23,8 @@ describe('ssr: scopeId', () => {
     expect(
       compile(`<foo>foo</foo>`, {
         scopeId,
-        mode: 'module'
-      }).code
+        mode: 'module',
+      }).code,
     ).toMatchInlineSnapshot(`
       "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createTextVNode as _createTextVNode } from "vue"
       import { ssrRenderComponent as _ssrRenderComponent } from "vue/server-renderer"
@@ -52,8 +52,8 @@ describe('ssr: scopeId', () => {
     expect(
       compile(`<foo><span>hello</span></foo>`, {
         scopeId,
-        mode: 'module'
-      }).code
+        mode: 'module',
+      }).code,
     ).toMatchInlineSnapshot(`
       "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode } from "vue"
       import { ssrRenderComponent as _ssrRenderComponent } from "vue/server-renderer"
@@ -81,8 +81,8 @@ describe('ssr: scopeId', () => {
     expect(
       compile(`<foo><span>hello</span><bar><span/></bar></foo>`, {
         scopeId,
-        mode: 'module'
-      }).code
+        mode: 'module',
+      }).code,
     ).toMatchInlineSnapshot(`
       "import { resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode } from "vue"
       import { ssrRenderComponent as _ssrRenderComponent } from "vue/server-renderer"
@@ -132,9 +132,9 @@ describe('ssr: scopeId', () => {
         `<transition-group tag="div" class="red"><span>hello</span></transition-group>`,
         {
           scopeId,
-          mode: 'module'
-        }
-      ).code
+          mode: 'module',
+        },
+      ).code,
     ).toMatchInlineSnapshot(`
       "import { mergeProps as _mergeProps } from "vue"
       import { ssrRenderAttrs as _ssrRenderAttrs } from "vue/server-renderer"
@@ -150,9 +150,9 @@ describe('ssr: scopeId', () => {
         `<transition-group :tag="someTag" class="red"><span>hello</span></transition-group>`,
         {
           scopeId,
-          mode: 'module'
-        }
-      ).code
+          mode: 'module',
+        },
+      ).code,
     ).toMatchInlineSnapshot(`
       "import { mergeProps as _mergeProps } from "vue"
       import { ssrRenderAttrs as _ssrRenderAttrs } from "vue/server-renderer"
index a3ed5b88167549d7748cd4e38521f2bd1f0e6e82..977cc8027d033919fae6a30da43c1934f85062f2 100644 (file)
@@ -1,5 +1,5 @@
 import { compile } from '../src'
-import { ssrHelpers, SSR_RENDER_SLOT_INNER } from '../src/runtimeHelpers'
+import { SSR_RENDER_SLOT_INNER, ssrHelpers } from '../src/runtimeHelpers'
 
 describe('ssr: <slot>', () => {
   test('basic', () => {
@@ -62,8 +62,8 @@ describe('ssr: <slot>', () => {
   test('with scopeId', async () => {
     expect(
       compile(`<slot/>`, {
-        scopeId: 'hello'
-      }).code
+        scopeId: 'hello',
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderSlot: _ssrRenderSlot } = require("vue/server-renderer")
 
@@ -77,8 +77,8 @@ describe('ssr: <slot>', () => {
     expect(
       compile(`<slot/>`, {
         scopeId: 'hello',
-        slotted: false
-      }).code
+        slotted: false,
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderSlot: _ssrRenderSlot } = require("vue/server-renderer")
 
@@ -91,8 +91,8 @@ describe('ssr: <slot>', () => {
   test('with forwarded scopeId', async () => {
     expect(
       compile(`<Comp><slot/></Comp>`, {
-        scopeId: 'hello'
-      }).code
+        scopeId: 'hello',
+      }).code,
     ).toMatchInlineSnapshot(`
       "const { resolveComponent: _resolveComponent, withCtx: _withCtx, renderSlot: _renderSlot } = require("vue")
       const { ssrRenderSlot: _ssrRenderSlot, ssrRenderComponent: _ssrRenderComponent } = require("vue/server-renderer")
index 2e425362b56d602972871ba447b8e3834498feb5..dd8853c8daf062a29952508f0b16c707cc02d949 100644 (file)
@@ -28,7 +28,7 @@ describe('ssr compile: suspense', () => {
       <template #fallback>
         loading...
       </template>
-    </suspense>`).code
+    </suspense>`).code,
     ).toMatchInlineSnapshot(`
       "const { resolveComponent: _resolveComponent, withCtx: _withCtx } = require("vue")
       const { ssrRenderComponent: _ssrRenderComponent, ssrRenderSuspense: _ssrRenderSuspense } = require("vue/server-renderer")
index 54f9827a34e2d7486cec9107e8f57b4fcf0c2572..1aa391e6a5fafe03a0321aed8c241a3ff55a169d 100644 (file)
@@ -8,7 +8,7 @@ describe('ssr: text', () => {
 
   test('static text with template string special chars', () => {
     expect(getCompiledString(`\`\${foo}\``)).toMatchInlineSnapshot(
-      `"\`\\\`\\\${foo}\\\`\`"`
+      `"\`\\\`\\\${foo}\\\`\`"`,
     )
   })
 
@@ -17,27 +17,27 @@ describe('ssr: text', () => {
     // snapshot -> inline snapshot goes through two escapes
     // so that makes a total of 3 * 2 * 2 = 12 back slashes
     expect(getCompiledString(`\\$foo`)).toMatchInlineSnapshot(
-      `"\`\\\\\\$foo\`"`
+      `"\`\\\\\\$foo\`"`,
     )
   })
 
   test('comments', () => {
     expect(getCompiledString(`<!--bar-->`)).toMatchInlineSnapshot(
-      `"\`<!--bar-->\`"`
+      `"\`<!--bar-->\`"`,
     )
   })
 
   test('static text escape', () => {
     expect(getCompiledString(`&lt;foo&gt;`)).toMatchInlineSnapshot(
-      `"\`&lt;foo&gt;\`"`
+      `"\`&lt;foo&gt;\`"`,
     )
   })
 
   test('nested elements with static text', () => {
     expect(
-      getCompiledString(`<div><span>hello</span><span>bye</span></div>`)
+      getCompiledString(`<div><span>hello</span><span>bye</span></div>`),
     ).toMatchInlineSnapshot(
-      `"\`<div><span>hello</span><span>bye</span></div>\`"`
+      `"\`<div><span>hello</span><span>bye</span></div>\`"`,
     )
   })
 
@@ -54,7 +54,7 @@ describe('ssr: text', () => {
   test('nested elements with interpolation', () => {
     expect(
       compile(`<div><span>{{ foo }} bar</span><span>baz {{ qux }}</span></div>`)
-        .code
+        .code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttrs: _ssrRenderAttrs, ssrInterpolate: _ssrInterpolate } = require("vue/server-renderer")
 
index 3c53da4349f106cbb071347f05af4d57c6e75ffd..d2a576fd02a1e7f5814b58131a5a298736d0dfd3 100644 (file)
@@ -6,7 +6,7 @@ describe('transition-group', () => {
   test('basic', () => {
     expect(
       compile(`<transition-group><div v-for="i in list"/></transition-group>`)
-        .code
+        .code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -23,8 +23,8 @@ describe('transition-group', () => {
   test('with static tag', () => {
     expect(
       compile(
-        `<transition-group tag="ul"><div v-for="i in list"/></transition-group>`
-      ).code
+        `<transition-group tag="ul"><div v-for="i in list"/></transition-group>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttrs: _ssrRenderAttrs, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -41,8 +41,8 @@ describe('transition-group', () => {
   test('with dynamic tag', () => {
     expect(
       compile(
-        `<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`
-      ).code
+        `<transition-group :tag="someTag"><div v-for="i in list"/></transition-group>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttrs: _ssrRenderAttrs, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -67,8 +67,8 @@ describe('transition-group', () => {
               <div v-for="i in 10"/>
               <div v-for="i in 10"/>
               <template v-if="ok"><div>ok</div></template>
-            </transition-group>`
-      ).code
+            </transition-group>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -94,8 +94,8 @@ describe('transition-group', () => {
     expect(
       compile(
         `<transition-group tag="ul" class="red" id="ok">
-        </transition-group>`
-      ).code
+        </transition-group>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { mergeProps: _mergeProps } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
index 69c4d95e56abed6706d0d0e9451564c91f3bb5a5..0d957265120986165b35cf80b9247fa1b3f23ac1 100644 (file)
@@ -35,8 +35,8 @@ describe('ssr: v-for', () => {
       compile(
         `<div v-for="row, i in list">` +
           `<div v-for="j in row">{{ i }},{{ j }}</div>` +
-          `</div>`
-      ).code
+          `</div>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -76,7 +76,7 @@ describe('ssr: v-for', () => {
   test('template v-for (single element)', () => {
     expect(
       compile(`<template v-for="i in list"><span>{{ i }}</span></template>`)
-        .code
+        .code,
     ).toMatchInlineSnapshot(`
       "const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -93,8 +93,8 @@ describe('ssr: v-for', () => {
   test('template v-for (multi element)', () => {
     expect(
       compile(
-        `<template v-for="i in list"><span>{{ i }}</span><span>{{ i + 1 }}</span></template>`
-      ).code
+        `<template v-for="i in list"><span>{{ i }}</span><span>{{ i + 1 }}</span></template>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrInterpolate: _ssrInterpolate, ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -114,7 +114,7 @@ describe('ssr: v-for', () => {
 
   test('render loop args should not be prefixed', () => {
     const { code } = compile(
-      `<div v-for="{ foo }, index in list">{{ foo + bar + index }}</div>`
+      `<div v-for="{ foo }, index in list">{{ foo + bar + index }}</div>`,
     )
     expect(code).toMatch(`_ctx.bar`)
     expect(code).not.toMatch(`_ctx.foo`)
index e0e3a4fc468c344c3fb35e77e924afaed6774fa8..b544adadcf3a77293cbf91b35b48f3305707ea0d 100644 (file)
@@ -111,7 +111,8 @@ describe('ssr: v-if', () => {
 
   test('<template v-if> (multiple element)', () => {
     expect(
-      compile(`<template v-if="foo"><div>hi</div><div>ho</div></template>`).code
+      compile(`<template v-if="foo"><div>hi</div><div>ho</div></template>`)
+        .code,
     ).toMatchInlineSnapshot(`
       "
       return function ssrRender(_ctx, _push, _parent, _attrs) {
@@ -126,7 +127,7 @@ describe('ssr: v-if', () => {
 
   test('<template v-if> (with v-for inside)', () => {
     expect(
-      compile(`<template v-if="foo"><div v-for="i in list"/></template>`).code
+      compile(`<template v-if="foo"><div v-for="i in list"/></template>`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderList: _ssrRenderList } = require("vue/server-renderer")
 
@@ -147,8 +148,8 @@ describe('ssr: v-if', () => {
   test('<template v-if> + normal v-else', () => {
     expect(
       compile(
-        `<template v-if="foo"><div>hi</div><div>ho</div></template><div v-else/>`
-      ).code
+        `<template v-if="foo"><div>hi</div><div>ho</div></template><div v-else/>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
index b1a2ff8936dd287d08e194f4a4a730abf659b489..f2c04f0a5e8b71287ccc458b12cd89b41e5c61cc 100644 (file)
@@ -36,8 +36,8 @@ describe('ssr: v-model', () => {
   test('<select v-model>', () => {
     expect(
       compileWithWrapper(
-        `<select v-model="model"><option value="1"></option></select>`
-      ).code
+        `<select v-model="model"><option value="1"></option></select>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrLooseContain: _ssrLooseContain, ssrLooseEqual: _ssrLooseEqual, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -54,8 +54,8 @@ describe('ssr: v-model', () => {
 
     expect(
       compileWithWrapper(
-        `<select multiple v-model="model"><option value="1" selected></option><option value="2"></option></select>`
-      ).code
+        `<select multiple v-model="model"><option value="1" selected></option><option value="2"></option></select>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrLooseContain: _ssrLooseContain, ssrLooseEqual: _ssrLooseEqual, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -72,7 +72,7 @@ describe('ssr: v-model', () => {
 
     expect(
       compileWithWrapper(`<select multiple v-model="model"><slot/></select>`)
-        .code
+        .code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderSlot: _ssrRenderSlot, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -89,7 +89,7 @@ describe('ssr: v-model', () => {
           <optgroup label="foo">
             <option value="bar">bar</option>
           </optgroup>
-        </select>`).code
+        </select>`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrLooseContain: _ssrLooseContain, ssrLooseEqual: _ssrLooseEqual, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -110,7 +110,7 @@ describe('ssr: v-model', () => {
           <optgroup label="foo">
             <slot/>
           </optgroup>
-        </select>`).code
+        </select>`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderSlot: _ssrRenderSlot, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -124,7 +124,7 @@ describe('ssr: v-model', () => {
 
   test('<input type="radio">', () => {
     expect(
-      compileWithWrapper(`<input type="radio" value="foo" v-model="bar">`).code
+      compileWithWrapper(`<input type="radio" value="foo" v-model="bar">`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrLooseEqual: _ssrLooseEqual, ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -156,7 +156,7 @@ describe('ssr: v-model', () => {
 
     expect(
       compileWithWrapper(`<input type="checkbox" value="foo" v-model="bar">`)
-        .code
+        .code,
     ).toMatchInlineSnapshot(`
       "const { ssrLooseContain: _ssrLooseContain, ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -173,8 +173,8 @@ describe('ssr: v-model', () => {
 
     expect(
       compileWithWrapper(
-        `<input type="checkbox" :true-value="foo" :false-value="bar" v-model="baz">`
-      ).code
+        `<input type="checkbox" :true-value="foo" :false-value="bar" v-model="baz">`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrLooseEqual: _ssrLooseEqual, ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -189,8 +189,8 @@ describe('ssr: v-model', () => {
 
     expect(
       compileWithWrapper(
-        `<input type="checkbox" true-value="foo" false-value="bar" v-model="baz">`
-      ).code
+        `<input type="checkbox" true-value="foo" false-value="bar" v-model="baz">`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrLooseEqual: _ssrLooseEqual, ssrIncludeBooleanAttr: _ssrIncludeBooleanAttr, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -236,7 +236,7 @@ describe('ssr: v-model', () => {
       `)
 
     expect(
-      compileWithWrapper(`<input :type="x" v-model="foo" value="bar">`).code
+      compileWithWrapper(`<input :type="x" v-model="foo" value="bar">`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttr: _ssrRenderAttr, ssrRenderDynamicModel: _ssrRenderDynamicModel, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -252,7 +252,7 @@ describe('ssr: v-model', () => {
     `)
 
     expect(
-      compileWithWrapper(`<input :type="x" v-model="foo" :value="bar">`).code
+      compileWithWrapper(`<input :type="x" v-model="foo" :value="bar">`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderAttr: _ssrRenderAttr, ssrRenderDynamicModel: _ssrRenderDynamicModel, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -289,7 +289,7 @@ describe('ssr: v-model', () => {
 
     expect(
       compileWithWrapper(`<input id="x" v-bind="obj" v-model="foo" class="y">`)
-        .code
+        .code,
     ).toMatchInlineSnapshot(`
       "const { mergeProps: _mergeProps } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs, ssrGetDynamicModelProps: _ssrGetDynamicModelProps } = require("vue/server-renderer")
index 9f7d55850abf70cdc927bbf4ace61f9281741702..d0f3ec93036add68c9acd7181c1944407d3a5e75 100644 (file)
@@ -53,7 +53,7 @@ describe('ssr: v-show', () => {
 
   test('with dynamic style', () => {
     expect(
-      compileWithWrapper(`<div :style="{ color: 'red' }" v-show="foo"/>`).code
+      compileWithWrapper(`<div :style="{ color: 'red' }" v-show="foo"/>`).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderStyle: _ssrRenderStyle, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -73,8 +73,8 @@ describe('ssr: v-show', () => {
   test('with static + dynamic style', () => {
     expect(
       compileWithWrapper(
-        `<div style="color:red" :style="{ fontSize: 14 }" v-show="foo"/>`
-      ).code
+        `<div style="color:red" :style="{ fontSize: 14 }" v-show="foo"/>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { ssrRenderStyle: _ssrRenderStyle, ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
 
@@ -95,8 +95,8 @@ describe('ssr: v-show', () => {
   test('with v-bind', () => {
     expect(
       compileWithWrapper(
-        `<div v-bind="baz" style="color:red" :style="{ fontSize: 14 }" v-show="foo"/>`
-      ).code
+        `<div v-bind="baz" style="color:red" :style="{ fontSize: 14 }" v-show="foo"/>`,
+      ).code,
     ).toMatchInlineSnapshot(`
       "const { mergeProps: _mergeProps } = require("vue")
       const { ssrRenderAttrs: _ssrRenderAttrs } = require("vue/server-renderer")
index 08dec4debecb538770ff2ed36e00187bd50b0572..c656517cdb87d0b28874ccf9f0c29a5c0555dfeb 100644 (file)
@@ -6,7 +6,7 @@ export function getCompiledString(src: string): string {
   // but also means this util can only be used for non-root cases.
   const { code } = compile(`<div>${src}</div>`)
   const match = code.match(
-    /_push\(\`<div\${\s*_ssrRenderAttrs\(_attrs\)\s*}>([^]*)<\/div>\`\)/
+    /_push\(\`<div\${\s*_ssrRenderAttrs\(_attrs\)\s*}>([^]*)<\/div>\`\)/,
   )
 
   if (!match) {
index c75a87e2a005f41969784376f5b9b43244009468..e4fd505d282939141e1e39a2a34b250c57363086 100644 (file)
@@ -1,8 +1,8 @@
 import {
-  SourceLocation,
-  CompilerError,
+  type CompilerError,
+  DOMErrorCodes,
+  type SourceLocation,
   createCompilerError,
-  DOMErrorCodes
 } from '@vue/compiler-dom'
 
 export interface SSRCompilerError extends CompilerError {
@@ -11,7 +11,7 @@ export interface SSRCompilerError extends CompilerError {
 
 export function createSSRCompilerError(
   code: SSRErrorCodes,
-  loc?: SourceLocation
+  loc?: SourceLocation,
 ) {
   return createCompilerError(code, loc, SSRErrorMessages) as SSRCompilerError
 }
@@ -19,7 +19,7 @@ export function createSSRCompilerError(
 export enum SSRErrorCodes {
   X_SSR_UNSAFE_ATTR_NAME = 65 /* DOMErrorCodes.__EXTEND_POINT__ */,
   X_SSR_NO_TELEPORT_TARGET,
-  X_SSR_INVALID_AST_NODE
+  X_SSR_INVALID_AST_NODE,
 }
 
 if (__TEST__) {
@@ -30,7 +30,7 @@ if (__TEST__) {
     throw new Error(
       `SSRErrorCodes need to be updated to ${
         DOMErrorCodes.__EXTEND_POINT__ + 1
-      } to match extension point from core DOMErrorCodes.`
+      } to match extension point from core DOMErrorCodes.`,
     )
   }
 }
@@ -38,5 +38,5 @@ if (__TEST__) {
 export const SSRErrorMessages: { [code: number]: string } = {
   [SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME]: `Unsafe attribute name for SSR.`,
   [SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET]: `Missing the 'to' prop on teleport element.`,
-  [SSRErrorCodes.X_SSR_INVALID_AST_NODE]: `Invalid AST node during SSR transform.`
+  [SSRErrorCodes.X_SSR_INVALID_AST_NODE]: `Invalid AST node during SSR transform.`,
 }
index cae8cf711a8a40bbfd420736f0503b223687934f..f8a686555e8b32e6b941cda69f348af0c0a7dfd6 100644 (file)
@@ -1,24 +1,24 @@
 import {
-  CodegenResult,
+  type CodegenResult,
+  type CompilerOptions,
+  type RootNode,
   baseParse,
-  parserOptions,
-  transform,
   generate,
-  CompilerOptions,
-  transformExpression,
-  trackVForSlotScopes,
-  trackSlotScopes,
   noopDirectiveTransform,
+  parserOptions,
+  trackSlotScopes,
+  trackVForSlotScopes,
+  transform,
   transformBind,
-  transformStyle,
+  transformExpression,
   transformOn,
-  RootNode
+  transformStyle,
 } from '@vue/compiler-dom'
 import { ssrCodegenTransform } from './ssrCodegenTransform'
 import { ssrTransformElement } from './transforms/ssrTransformElement'
 import {
+  rawOptionsMap,
   ssrTransformComponent,
-  rawOptionsMap
 } from './transforms/ssrTransformComponent'
 import { ssrTransformSlotOutlet } from './transforms/ssrTransformSlotOutlet'
 import { ssrTransformIf } from './transforms/ssrVIf'
@@ -30,7 +30,7 @@ import { ssrInjectCssVars } from './transforms/ssrInjectCssVars'
 
 export function compile(
   source: string | RootNode,
-  options: CompilerOptions = {}
+  options: CompilerOptions = {},
 ): CodegenResult {
   options = {
     ...options,
@@ -42,7 +42,7 @@ export function compile(
     prefixIdentifiers: true,
     // disable optimizations that are unnecessary for ssr
     cacheHandlers: false,
-    hoistStatic: false
+    hoistStatic: false,
   }
 
   const ast = typeof source === 'string' ? baseParse(source, options) : source
@@ -66,7 +66,7 @@ export function compile(
       ssrTransformComponent,
       trackSlotScopes,
       transformStyle,
-      ...(options.nodeTransforms || []) // user transforms
+      ...(options.nodeTransforms || []), // user transforms
     ],
     directiveTransforms: {
       // reusing core v-bind
@@ -80,8 +80,8 @@ export function compile(
       cloak: noopDirectiveTransform,
       once: noopDirectiveTransform,
       memo: noopDirectiveTransform,
-      ...(options.directiveTransforms || {}) // user transforms
-    }
+      ...(options.directiveTransforms || {}), // user transforms
+    },
   })
 
   // traverse the template AST and convert into SSR codegen AST
index 220af4854f67deb4c7d22d1e230eb4f83c0cbf16..1420ef64fbeaeb56c8f8462a7559aee19ea23858 100644 (file)
@@ -39,7 +39,7 @@ export const ssrHelpers = {
   [SSR_GET_DYNAMIC_MODEL_PROPS]: `ssrGetDynamicModelProps`,
   [SSR_RENDER_TELEPORT]: `ssrRenderTeleport`,
   [SSR_RENDER_SUSPENSE]: `ssrRenderSuspense`,
-  [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`
+  [SSR_GET_DIRECTIVE_PROPS]: `ssrGetDirectiveProps`,
 }
 
 // Note: these are helpers imported from @vue/server-renderer
index 954863b539352232e1342a734c65fa094c117993..1755be3a3b07b2146b8e80233cc8434e2c0c1cdf 100644 (file)
@@ -1,31 +1,31 @@
 import {
-  RootNode,
-  BlockStatement,
-  TemplateLiteral,
-  createCallExpression,
-  createTemplateLiteral,
-  NodeTypes,
-  TemplateChildNode,
+  type BlockStatement,
+  type CallExpression,
+  type CompilerOptions,
   ElementTypes,
+  type IfStatement,
+  NodeTypes,
+  type RootNode,
+  type TemplateChildNode,
+  type TemplateLiteral,
   createBlockStatement,
-  CompilerOptions,
-  IfStatement,
-  CallExpression,
-  isText,
-  processExpression,
-  createSimpleExpression,
+  createCallExpression,
   createCompoundExpression,
+  createRoot,
+  createSimpleExpression,
+  createTemplateLiteral,
   createTransformContext,
-  createRoot
+  isText,
+  processExpression,
 } from '@vue/compiler-dom'
-import { isString, escapeHtml } from '@vue/shared'
+import { escapeHtml, isString } from '@vue/shared'
 import { SSR_INTERPOLATE, ssrHelpers } from './runtimeHelpers'
 import { ssrProcessIf } from './transforms/ssrVIf'
 import { ssrProcessFor } from './transforms/ssrVFor'
 import { ssrProcessSlotOutlet } from './transforms/ssrTransformSlotOutlet'
 import { ssrProcessComponent } from './transforms/ssrTransformComponent'
 import { ssrProcessElement } from './transforms/ssrTransformElement'
-import { createSSRCompilerError, SSRErrorCodes } from './errors'
+import { SSRErrorCodes, createSSRCompilerError } from './errors'
 
 // Because SSR codegen output is completely different from client-side output
 // (e.g. multiple elements can be concatenated into a single template literal
@@ -43,10 +43,10 @@ export function ssrCodegenTransform(ast: RootNode, options: CompilerOptions) {
     const cssContext = createTransformContext(createRoot([]), options)
     const varsExp = processExpression(
       createSimpleExpression(options.ssrCssVars, false),
-      cssContext
+      cssContext,
     )
     context.body.push(
-      createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`])
+      createCompoundExpression([`const _cssVars = { style: `, varsExp, `}`]),
     )
     Array.from(cssContext.helpers.keys()).forEach(helper => {
       ast.helpers.add(helper)
@@ -63,8 +63,8 @@ export function ssrCodegenTransform(ast: RootNode, options: CompilerOptions) {
   ast.ssrHelpers = Array.from(
     new Set([
       ...Array.from(ast.helpers).filter(h => h in ssrHelpers),
-      ...context.helpers
-    ])
+      ...context.helpers,
+    ]),
   )
 
   ast.helpers = new Set(Array.from(ast.helpers).filter(h => !(h in ssrHelpers)))
@@ -76,7 +76,7 @@ function createSSRTransformContext(
   root: RootNode,
   options: CompilerOptions,
   helpers: Set<symbol> = new Set(),
-  withSlotScopeId = false
+  withSlotScopeId = false,
 ) {
   const body: BlockStatement['body'] = []
   let currentString: TemplateLiteral | null = null
@@ -115,20 +115,20 @@ function createSSRTransformContext(
       // close current string
       currentString = null
       body.push(statement)
-    }
+    },
   }
 }
 
 function createChildContext(
   parent: SSRTransformContext,
-  withSlotScopeId = parent.withSlotScopeId
+  withSlotScopeId = parent.withSlotScopeId,
 ): SSRTransformContext {
   // ensure child inherits parent helpers
   return createSSRTransformContext(
     parent.root,
     parent.options,
     parent.helpers,
-    withSlotScopeId
+    withSlotScopeId,
   )
 }
 
@@ -140,7 +140,7 @@ export function processChildren(
   parent: Container,
   context: SSRTransformContext,
   asFragment = false,
-  disableNestedFragments = false
+  disableNestedFragments = false,
 ) {
   if (asFragment) {
     context.pushStringPart(`<!--[-->`)
@@ -167,8 +167,8 @@ export function processChildren(
             context.onError(
               createSSRCompilerError(
                 SSRErrorCodes.X_SSR_INVALID_AST_NODE,
-                (child as any).loc
-              )
+                (child as any).loc,
+              ),
             )
             // make sure we exhaust all possible types
             const exhaustiveCheck: never = child
@@ -185,7 +185,9 @@ export function processChildren(
         break
       case NodeTypes.INTERPOLATION:
         context.pushStringPart(
-          createCallExpression(context.helper(SSR_INTERPOLATE), [child.content])
+          createCallExpression(context.helper(SSR_INTERPOLATE), [
+            child.content,
+          ]),
         )
         break
       case NodeTypes.IF:
@@ -206,8 +208,8 @@ export function processChildren(
         context.onError(
           createSSRCompilerError(
             SSRErrorCodes.X_SSR_INVALID_AST_NODE,
-            (child as any).loc
-          )
+            (child as any).loc,
+          ),
         )
         // make sure we exhaust all possible types
         const exhaustiveCheck: never = child
@@ -223,7 +225,7 @@ export function processChildrenAsStatement(
   parent: Container,
   parentContext: SSRTransformContext,
   asFragment = false,
-  withSlotScopeId = parentContext.withSlotScopeId
+  withSlotScopeId = parentContext.withSlotScopeId,
 ): BlockStatement {
   const childContext = createChildContext(parentContext, withSlotScopeId)
   processChildren(parent, childContext, asFragment)
index f11e62f6f43b5507940dd3539270851ce413f2ae..7a69414ce4024709ad1c6c0e446defbcebe71025 100644 (file)
@@ -1,12 +1,12 @@
 import {
-  NodeTransform,
-  NodeTypes,
   ElementTypes,
-  locStub,
+  type NodeTransform,
+  NodeTypes,
+  type RootNode,
+  type TemplateChildNode,
   createSimpleExpression,
-  RootNode,
-  TemplateChildNode,
-  findDir
+  findDir,
+  locStub,
 } from '@vue/compiler-dom'
 
 export const ssrInjectCssVars: NodeTransform = (node, context) => {
@@ -61,7 +61,7 @@ function injectCssVars(node: RootNode | TemplateChildNode) {
         arg: undefined,
         exp: createSimpleExpression(`_cssVars`, false),
         modifiers: [],
-        loc: locStub
+        loc: locStub,
       })
     }
   }
index a54a7366f012f49964832bdd3607caadb2c164e6..b1aac0d74c2fd8b044fc30c6f4b4694f97d61c4b 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  NodeTransform,
-  NodeTypes,
   ElementTypes,
-  locStub,
+  type NodeTransform,
+  NodeTypes,
+  type ParentNode,
+  type RootNode,
+  type TemplateChildNode,
   createSimpleExpression,
-  RootNode,
-  TemplateChildNode,
-  ParentNode,
-  findDir
+  findDir,
+  locStub,
 } from '@vue/compiler-dom'
 
 const filterChild = (node: ParentNode) =>
@@ -85,7 +85,7 @@ function injectFallthroughAttrs(node: RootNode | TemplateChildNode) {
       arg: undefined,
       exp: createSimpleExpression(`_attrs`, false),
       modifiers: [],
-      loc: locStub
+      loc: locStub,
     })
   }
 }
index 4d3599a57a654a012e9ade880d2e899e6bef4c92..c179cd50cf7c7bef12543a3a1c648d06dbad0246 100644 (file)
@@ -1,65 +1,65 @@
 import {
-  NodeTransform,
-  NodeTypes,
+  CREATE_VNODE,
+  type CallExpression,
+  type CompilerOptions,
+  type ComponentNode,
+  DOMDirectiveTransforms,
+  DOMNodeTransforms,
+  type DirectiveNode,
   ElementTypes,
-  createCallExpression,
-  resolveComponentType,
+  type ExpressionNode,
+  type FunctionExpression,
+  type JSChildNode,
+  Namespaces,
+  type NodeTransform,
+  NodeTypes,
+  RESOLVE_DYNAMIC_COMPONENT,
+  type ReturnStatement,
+  type RootNode,
+  SUSPENSE,
+  type SlotFnBuilder,
+  TELEPORT,
+  TRANSITION,
+  TRANSITION_GROUP,
+  type TemplateChildNode,
+  type TemplateNode,
+  type TransformContext,
+  type TransformOptions,
   buildProps,
-  ComponentNode,
-  SlotFnBuilder,
-  createFunctionExpression,
   buildSlots,
-  FunctionExpression,
-  TemplateChildNode,
+  createCallExpression,
+  createFunctionExpression,
   createIfStatement,
-  createSimpleExpression,
-  getBaseTransformPreset,
-  DOMNodeTransforms,
-  DOMDirectiveTransforms,
   createReturnStatement,
-  ReturnStatement,
-  Namespaces,
-  locStub,
-  RootNode,
-  TransformContext,
-  CompilerOptions,
-  TransformOptions,
   createRoot,
+  createSimpleExpression,
   createTransformContext,
-  traverseNode,
-  ExpressionNode,
-  TemplateNode,
-  SUSPENSE,
-  TELEPORT,
-  TRANSITION_GROUP,
-  CREATE_VNODE,
-  CallExpression,
-  JSChildNode,
-  RESOLVE_DYNAMIC_COMPONENT,
-  TRANSITION,
+  getBaseTransformPreset,
+  locStub,
+  resolveComponentType,
   stringifyExpression,
-  DirectiveNode
+  traverseNode,
 } from '@vue/compiler-dom'
 import { SSR_RENDER_COMPONENT, SSR_RENDER_VNODE } from '../runtimeHelpers'
 import {
-  SSRTransformContext,
+  type SSRTransformContext,
   processChildren,
-  processChildrenAsStatement
+  processChildrenAsStatement,
 } from '../ssrCodegenTransform'
 import { ssrProcessTeleport } from './ssrTransformTeleport'
 import {
   ssrProcessSuspense,
-  ssrTransformSuspense
+  ssrTransformSuspense,
 } from './ssrTransformSuspense'
 import {
   ssrProcessTransitionGroup,
-  ssrTransformTransitionGroup
+  ssrTransformTransitionGroup,
 } from './ssrTransformTransitionGroup'
-import { isSymbol, isObject, isArray, extend } from '@vue/shared'
+import { extend, isArray, isObject, isSymbol } from '@vue/shared'
 import { buildSSRProps } from './ssrTransformElement'
 import {
   ssrProcessTransition,
-  ssrTransformTransition
+  ssrTransformTransition,
 } from './ssrTransformTransition'
 
 // We need to construct the slot functions in the 1st pass to ensure proper
@@ -128,7 +128,7 @@ export const ssrTransformComponent: NodeTransform = (node, context) => {
     if (clonedNode.children.length) {
       buildSlots(clonedNode, context, (props, vFor, children) => {
         vnodeBranches.push(
-          createVNodeSlotBranch(props, vFor, children, context)
+          createVNodeSlotBranch(props, vFor, children, context),
         )
         return createFunctionExpression(undefined)
       })
@@ -143,7 +143,7 @@ export const ssrTransformComponent: NodeTransform = (node, context) => {
         context,
         undefined,
         true,
-        isDynamicComponent
+        isDynamicComponent,
       )
       if (props || directives.length) {
         propsExp = buildSSRProps(props, directives, context)
@@ -160,14 +160,14 @@ export const ssrTransformComponent: NodeTransform = (node, context) => {
         undefined, // no return, assign body later
         true, // newline
         true, // isSlot
-        loc
+        loc,
       )
       wipEntries.push({
         type: WIP_SLOT,
         fn,
         children,
         // also collect the corresponding vnode branch built earlier
-        vnodeBranch: vnodeBranches[wipEntries.length]
+        vnodeBranch: vnodeBranches[wipEntries.length],
       })
       return fn
     }
@@ -187,15 +187,15 @@ export const ssrTransformComponent: NodeTransform = (node, context) => {
           createCallExpression(context.helper(CREATE_VNODE), [
             component,
             propsExp,
-            slots
+            slots,
           ]),
-          `_parent`
-        ]
+          `_parent`,
+        ],
       )
     } else {
       node.ssrCodegenNode = createCallExpression(
         context.helper(SSR_RENDER_COMPONENT),
-        [component, propsExp, slots, `_parent`]
+        [component, propsExp, slots, `_parent`],
       )
     }
   }
@@ -204,7 +204,7 @@ export const ssrTransformComponent: NodeTransform = (node, context) => {
 export function ssrProcessComponent(
   node: ComponentNode,
   context: SSRTransformContext,
-  parent: { children: TemplateChildNode[] }
+  parent: { children: TemplateChildNode[] },
 ) {
   const component = componentTypeMap.get(node)!
   if (!node.ssrCodegenNode) {
@@ -244,9 +244,9 @@ export function ssrProcessComponent(
           wipEntries[i],
           context,
           false,
-          true /* withSlotScopeId */
+          true /* withSlotScopeId */,
         ),
-        vnodeBranch
+        vnodeBranch,
       )
     }
 
@@ -258,7 +258,7 @@ export function ssrProcessComponent(
     if (typeof component === 'string') {
       // static component
       context.pushStatement(
-        createCallExpression(`_push`, [node.ssrCodegenNode])
+        createCallExpression(`_push`, [node.ssrCodegenNode]),
       )
     } else {
       // dynamic component (`resolveDynamicComponent` call)
@@ -275,14 +275,14 @@ const [baseNodeTransforms, baseDirectiveTransforms] =
 const vnodeNodeTransforms = [...baseNodeTransforms, ...DOMNodeTransforms]
 const vnodeDirectiveTransforms = {
   ...baseDirectiveTransforms,
-  ...DOMDirectiveTransforms
+  ...DOMDirectiveTransforms,
 }
 
 function createVNodeSlotBranch(
   slotProps: ExpressionNode | undefined,
   vFor: DirectiveNode | undefined,
   children: TemplateChildNode[],
-  parentContext: TransformContext
+  parentContext: TransformContext,
 ): ReturnStatement {
   // apply a sub-transform using vnode-based transforms.
   const rawOptions = rawOptionsMap.get(parentContext.root)!
@@ -292,12 +292,12 @@ function createVNodeSlotBranch(
     // overwrite with vnode-based transforms
     nodeTransforms: [
       ...vnodeNodeTransforms,
-      ...(rawOptions.nodeTransforms || [])
+      ...(rawOptions.nodeTransforms || []),
     ],
     directiveTransforms: {
       ...vnodeDirectiveTransforms,
-      ...(rawOptions.directiveTransforms || {})
-    }
+      ...(rawOptions.directiveTransforms || {}),
+    },
   }
 
   // wrap the children with a wrapper template for proper children treatment.
@@ -311,7 +311,7 @@ function createVNodeSlotBranch(
       exp: slotProps,
       arg: undefined,
       modifiers: [],
-      loc: locStub
+      loc: locStub,
     })
   }
   if (vFor) {
@@ -325,7 +325,7 @@ function createVNodeSlotBranch(
     props: wrapperProps,
     children,
     loc: locStub,
-    codegenNode: undefined
+    codegenNode: undefined,
   }
   subTransform(wrapperNode, subOptions, parentContext)
   return createReturnStatement(children)
@@ -334,7 +334,7 @@ function createVNodeSlotBranch(
 function subTransform(
   node: TemplateChildNode,
   options: TransformOptions,
-  parentContext: TransformContext
+  parentContext: TransformContext,
 ) {
   const childRoot = createRoot([node])
   const childContext = createTransformContext(childRoot, options)
index 19259f36f2dcaca1fd83e5880be26d39e2a68f5c..050528f5870b604b810991bd47d68662b11e97a5 100644 (file)
@@ -1,57 +1,60 @@
 import {
-  NodeTransform,
-  NodeTypes,
+  type ArrayExpression,
+  type AttributeNode,
+  type CallExpression,
+  type DirectiveNode,
   ElementTypes,
-  TemplateLiteral,
-  createTemplateLiteral,
-  createInterpolation,
-  createCallExpression,
-  createConditionalExpression,
-  createSimpleExpression,
-  buildProps,
-  DirectiveNode,
-  PlainElementNode,
-  createCompilerError,
   ErrorCodes,
-  CallExpression,
+  type ExpressionNode,
+  type InterpolationNode,
+  type JSChildNode,
+  MERGE_PROPS,
+  type NodeTransform,
+  NodeTypes,
+  type PlainElementNode,
+  type PropsExpression,
+  type TemplateLiteral,
+  type TextNode,
+  type TransformContext,
+  buildDirectiveArgs,
+  buildProps,
   createArrayExpression,
-  ExpressionNode,
-  JSChildNode,
-  ArrayExpression,
   createAssignmentExpression,
-  TextNode,
+  createCallExpression,
+  createCompilerError,
+  createConditionalExpression,
+  createInterpolation,
+  createSequenceExpression,
+  createSimpleExpression,
+  createTemplateLiteral,
   hasDynamicKeyVBind,
-  MERGE_PROPS,
   isStaticArgOf,
-  createSequenceExpression,
-  InterpolationNode,
   isStaticExp,
-  AttributeNode,
-  buildDirectiveArgs,
-  TransformContext,
-  PropsExpression
 } from '@vue/compiler-dom'
 import {
+  NO,
   escapeHtml,
   isBooleanAttr,
   isBuiltInDirective,
   isSSRSafeAttrName,
-  NO,
-  propsToAttrMap
+  propsToAttrMap,
 } from '@vue/shared'
-import { createSSRCompilerError, SSRErrorCodes } from '../errors'
+import { SSRErrorCodes, createSSRCompilerError } from '../errors'
 import {
+  SSR_GET_DIRECTIVE_PROPS,
+  SSR_GET_DYNAMIC_MODEL_PROPS,
+  SSR_INCLUDE_BOOLEAN_ATTR,
+  SSR_INTERPOLATE,
   SSR_RENDER_ATTR,
+  SSR_RENDER_ATTRS,
   SSR_RENDER_CLASS,
-  SSR_RENDER_STYLE,
   SSR_RENDER_DYNAMIC_ATTR,
-  SSR_RENDER_ATTRS,
-  SSR_INTERPOLATE,
-  SSR_GET_DYNAMIC_MODEL_PROPS,
-  SSR_INCLUDE_BOOLEAN_ATTR,
-  SSR_GET_DIRECTIVE_PROPS
+  SSR_RENDER_STYLE,
 } from '../runtimeHelpers'
-import { SSRTransformContext, processChildren } from '../ssrCodegenTransform'
+import {
+  type SSRTransformContext,
+  processChildren,
+} from '../ssrCodegenTransform'
 
 // for directives with children overwrite (e.g. v-html & v-text), we need to
 // store the raw children so that they can be added in the 2nd pass.
@@ -81,7 +84,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
     // so when they are present we need to bail out to full `renderAttrs`
     const hasDynamicVBind = hasDynamicKeyVBind(node)
     const hasCustomDir = node.props.some(
-      p => p.type === NodeTypes.DIRECTIVE && !isBuiltInDirective(p.name)
+      p => p.type === NodeTypes.DIRECTIVE && !isBuiltInDirective(p.name),
     )
     const needMergeProps = hasDynamicVBind || hasCustomDir
     if (needMergeProps) {
@@ -91,13 +94,13 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
         node.props,
         false /* isComponent */,
         false /* isDynamicComponent */,
-        true /* ssr */
+        true /* ssr */,
       )
       if (props || directives.length) {
         const mergedProps = buildSSRProps(props, directives, context)
         const propsExp = createCallExpression(
           context.helper(SSR_RENDER_ATTRS),
-          [mergedProps]
+          [mergedProps],
         )
 
         if (node.tag === 'textarea') {
@@ -116,8 +119,8 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
             propsExp.arguments = [
               createAssignmentExpression(
                 createSimpleExpression(tempId, false),
-                mergedProps
-              )
+                mergedProps,
+              ),
             ]
             rawChildrenMap.set(
               node,
@@ -127,11 +130,11 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
                   createSimpleExpression(`${tempId}.value`, false),
                   createSimpleExpression(
                     existingText ? existingText.content : ``,
-                    true
+                    true,
                   ),
-                  false
-                )
-              ])
+                  false,
+                ),
+              ]),
             )
           }
         } else if (node.tag === 'input') {
@@ -152,11 +155,11 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
                     context.helper(SSR_GET_DYNAMIC_MODEL_PROPS),
                     [
                       tempExp, // existing props
-                      vModel.exp! // model
-                    ]
-                  )
-                ])
-              ])
+                      vModel.exp!, // model
+                    ],
+                  ),
+                ]),
+              ]),
             ]
           }
         }
@@ -190,7 +193,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
           node.children = [createInterpolation(prop.exp, prop.loc)]
         } else if (prop.name === 'slot') {
           context.onError(
-            createCompilerError(ErrorCodes.X_V_SLOT_MISPLACED, prop.loc)
+            createCompilerError(ErrorCodes.X_V_SLOT_MISPLACED, prop.loc),
           )
         } else if (isTextareaWithValue(node, prop) && prop.exp) {
           if (!needMergeProps) {
@@ -203,7 +206,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
             const { props, ssrTagParts } = directiveTransform(
               prop,
               node,
-              context
+              context,
             )
             if (ssrTagParts) {
               openTag.push(...ssrTagParts)
@@ -221,9 +224,9 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
                     ` class="`,
                     (dynamicClassBinding = createCallExpression(
                       context.helper(SSR_RENDER_CLASS),
-                      [value]
+                      [value],
                     )),
-                    `"`
+                    `"`,
                   )
                 } else if (attrName === 'style') {
                   if (dynamicStyleBinding) {
@@ -234,9 +237,9 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
                       ` style="`,
                       (dynamicStyleBinding = createCallExpression(
                         context.helper(SSR_RENDER_STYLE),
-                        [value]
+                        [value],
                       )),
-                      `"`
+                      `"`,
                     )
                   }
                 } else {
@@ -249,26 +252,26 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
                       createConditionalExpression(
                         createCallExpression(
                           context.helper(SSR_INCLUDE_BOOLEAN_ATTR),
-                          [value]
+                          [value],
                         ),
                         createSimpleExpression(' ' + attrName, true),
                         createSimpleExpression('', true),
-                        false /* no newline */
-                      )
+                        false /* no newline */,
+                      ),
                     )
                   } else if (isSSRSafeAttrName(attrName)) {
                     openTag.push(
                       createCallExpression(context.helper(SSR_RENDER_ATTR), [
                         key,
-                        value
-                      ])
+                        value,
+                      ]),
                     )
                   } else {
                     context.onError(
                       createSSRCompilerError(
                         SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME,
-                        key.loc
-                      )
+                        key.loc,
+                      ),
                     )
                   }
                 }
@@ -283,8 +286,8 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
                 openTag.push(
                   createCallExpression(
                     context.helper(SSR_RENDER_DYNAMIC_ATTR),
-                    args
-                  )
+                    args,
+                  ),
                 )
               }
             }
@@ -305,7 +308,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
           }
           openTag.push(
             ` ${prop.name}` +
-              (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``)
+              (prop.value ? `="${escapeHtml(prop.value.content)}"` : ``),
           )
         }
       }
@@ -328,7 +331,7 @@ export const ssrTransformElement: NodeTransform = (node, context) => {
 export function buildSSRProps(
   props: PropsExpression | undefined,
   directives: DirectiveNode[],
-  context: TransformContext
+  context: TransformContext,
 ): JSChildNode {
   let mergePropsArgs: JSChildNode[] = []
   if (props) {
@@ -344,8 +347,8 @@ export function buildSSRProps(
       mergePropsArgs.push(
         createCallExpression(context.helper(SSR_GET_DIRECTIVE_PROPS), [
           `_ctx`,
-          ...buildDirectiveArgs(dir, context).elements
-        ] as JSChildNode[])
+          ...buildDirectiveArgs(dir, context).elements,
+        ] as JSChildNode[]),
       )
     }
   }
@@ -370,7 +373,7 @@ function isTrueFalseValue(prop: DirectiveNode | AttributeNode) {
 
 function isTextareaWithValue(
   node: PlainElementNode,
-  prop: DirectiveNode
+  prop: DirectiveNode,
 ): boolean {
   return !!(
     node.tag === 'textarea' &&
@@ -390,7 +393,7 @@ function mergeCall(call: CallExpression, arg: string | JSChildNode) {
 
 function removeStaticBinding(
   tag: TemplateLiteral['elements'],
-  binding: string
+  binding: string,
 ) {
   const regExp = new RegExp(`^ ${binding}=".+"$`)
 
@@ -403,13 +406,13 @@ function removeStaticBinding(
 
 function findVModel(node: PlainElementNode): DirectiveNode | undefined {
   return node.props.find(
-    p => p.type === NodeTypes.DIRECTIVE && p.name === 'model' && p.exp
+    p => p.type === NodeTypes.DIRECTIVE && p.name === 'model' && p.exp,
   ) as DirectiveNode | undefined
 }
 
 export function ssrProcessElement(
   node: PlainElementNode,
-  context: SSRTransformContext
+  context: SSRTransformContext,
 ) {
   const isVoidTag = context.options.isVoidTag || NO
   const elementsToAdd = node.ssrCodegenNode!.elements
index c4bbb6ff620d89744e0d93ddbae0c4a8390d72ba..b75b4d033661677b5e97fcac3fcf0984c03df4b5 100644 (file)
@@ -1,19 +1,19 @@
 import {
-  NodeTransform,
-  isSlotOutlet,
-  processSlotOutlet,
+  ElementTypes,
+  type NodeTransform,
+  NodeTypes,
+  type SlotOutletNode,
+  TRANSITION,
   createCallExpression,
-  SlotOutletNode,
   createFunctionExpression,
-  NodeTypes,
-  ElementTypes,
+  isSlotOutlet,
+  processSlotOutlet,
   resolveComponentType,
-  TRANSITION
 } from '@vue/compiler-dom'
 import { SSR_RENDER_SLOT, SSR_RENDER_SLOT_INNER } from '../runtimeHelpers'
 import {
-  SSRTransformContext,
-  processChildrenAsStatement
+  type SSRTransformContext,
+  processChildrenAsStatement,
 } from '../ssrCodegenTransform'
 
 export const ssrTransformSlotOutlet: NodeTransform = (node, context) => {
@@ -27,7 +27,7 @@ export const ssrTransformSlotOutlet: NodeTransform = (node, context) => {
       // fallback content placeholder. will be replaced in the process phase
       `null`,
       `_push`,
-      `_parent`
+      `_parent`,
     ]
 
     // inject slot scope id if current template uses :slotted
@@ -62,7 +62,7 @@ export const ssrTransformSlotOutlet: NodeTransform = (node, context) => {
 
 export function ssrProcessSlotOutlet(
   node: SlotOutletNode,
-  context: SSRTransformContext
+  context: SSRTransformContext,
 ) {
   const renderCall = node.ssrCodegenNode!
 
index e7efbe1fb73e05dab1834794c4973ba83d79cdd8..47a35aac179c93b126785d196b35c1df47469cb6 100644 (file)
@@ -1,16 +1,16 @@
 import {
-  ComponentNode,
-  TransformContext,
+  type ComponentNode,
+  type FunctionExpression,
+  type SlotsExpression,
+  type TemplateChildNode,
+  type TransformContext,
   buildSlots,
-  createFunctionExpression,
-  FunctionExpression,
-  TemplateChildNode,
   createCallExpression,
-  SlotsExpression
+  createFunctionExpression,
 } from '@vue/compiler-dom'
 import {
-  SSRTransformContext,
-  processChildrenAsStatement
+  type SSRTransformContext,
+  processChildrenAsStatement,
 } from '../ssrCodegenTransform'
 import { SSR_RENDER_SUSPENSE } from '../runtimeHelpers'
 
@@ -27,13 +27,13 @@ interface WIPEntry {
 // phase 1
 export function ssrTransformSuspense(
   node: ComponentNode,
-  context: TransformContext
+  context: TransformContext,
 ) {
   return () => {
     if (node.children.length) {
       const wipEntry: WIPEntry = {
         slotsExp: null!, // to be immediately set
-        wipSlots: []
+        wipSlots: [],
       }
       wipMap.set(node, wipEntry)
       wipEntry.slotsExp = buildSlots(
@@ -45,14 +45,14 @@ export function ssrTransformSuspense(
             undefined, // no return, assign body later
             true, // newline
             false, // suspense slots are not treated as normal slots
-            loc
+            loc,
           )
           wipEntry.wipSlots.push({
             fn,
-            children
+            children,
           })
           return fn
-        }
+        },
       ).slots
     }
   }
@@ -61,7 +61,7 @@ export function ssrTransformSuspense(
 // phase 2
 export function ssrProcessSuspense(
   node: ComponentNode,
-  context: SSRTransformContext
+  context: SSRTransformContext,
 ) {
   // complete wip slots with ssr code
   const wipEntry = wipMap.get(node)
@@ -77,7 +77,7 @@ export function ssrProcessSuspense(
   context.pushStatement(
     createCallExpression(context.helper(SSR_RENDER_SUSPENSE), [
       `_push`,
-      slotsExp
-    ])
+      slotsExp,
+    ]),
   )
 }
index f470ca711d4eaae248ea808adf79be7e3e3d5d67..96f84241a9246f97b1ef5b403cb577b80151d609 100644 (file)
@@ -1,28 +1,28 @@
 import {
-  ComponentNode,
-  findProp,
+  type ComponentNode,
+  type ExpressionNode,
   NodeTypes,
-  createSimpleExpression,
-  createFunctionExpression,
   createCallExpression,
-  ExpressionNode
+  createFunctionExpression,
+  createSimpleExpression,
+  findProp,
 } from '@vue/compiler-dom'
 import {
-  SSRTransformContext,
-  processChildrenAsStatement
+  type SSRTransformContext,
+  processChildrenAsStatement,
 } from '../ssrCodegenTransform'
-import { createSSRCompilerError, SSRErrorCodes } from '../errors'
+import { SSRErrorCodes, createSSRCompilerError } from '../errors'
 import { SSR_RENDER_TELEPORT } from '../runtimeHelpers'
 
 // Note: this is a 2nd-pass codegen transform.
 export function ssrProcessTeleport(
   node: ComponentNode,
-  context: SSRTransformContext
+  context: SSRTransformContext,
 ) {
   const targetProp = findProp(node, 'to')
   if (!targetProp) {
     context.onError(
-      createSSRCompilerError(SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET, node.loc)
+      createSSRCompilerError(SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET, node.loc),
     )
     return
   }
@@ -38,8 +38,8 @@ export function ssrProcessTeleport(
     context.onError(
       createSSRCompilerError(
         SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET,
-        targetProp.loc
-      )
+        targetProp.loc,
+      ),
     )
     return
   }
@@ -56,7 +56,7 @@ export function ssrProcessTeleport(
     undefined, // Body is added later
     true, // newline
     false, // isSlot
-    node.loc
+    node.loc,
   )
   contentRenderFn.body = processChildrenAsStatement(node, context)
   context.pushStatement(
@@ -65,7 +65,7 @@ export function ssrProcessTeleport(
       contentRenderFn,
       target,
       disabled,
-      `_parent`
-    ])
+      `_parent`,
+    ]),
   )
 }
index d09a806f7b0fe739991b17768f89bd70a38b7437..400028d18206c87680899459a8dd7736771c78f0 100644 (file)
@@ -1,16 +1,19 @@
 import {
-  ComponentNode,
-  findProp,
+  type ComponentNode,
   NodeTypes,
-  TransformContext
+  type TransformContext,
+  findProp,
 } from '@vue/compiler-dom'
-import { processChildren, SSRTransformContext } from '../ssrCodegenTransform'
+import {
+  type SSRTransformContext,
+  processChildren,
+} from '../ssrCodegenTransform'
 
 const wipMap = new WeakMap<ComponentNode, Boolean>()
 
 export function ssrTransformTransition(
   node: ComponentNode,
-  context: TransformContext
+  context: TransformContext,
 ) {
   return () => {
     const appear = findProp(node, 'appear', false, true)
@@ -20,7 +23,7 @@ export function ssrTransformTransition(
 
 export function ssrProcessTransition(
   node: ComponentNode,
-  context: SSRTransformContext
+  context: SSRTransformContext,
 ) {
   // #5351: filter out comment children inside transition
   node.children = node.children.filter(c => c.type !== NodeTypes.COMMENT)
index b0f96e4dd6c781b3e3b71da21df6fec0f5625f7a..2d434010e2ade5da8c7e02ef80e1eb4debee3f2c 100644 (file)
@@ -1,16 +1,19 @@
 import {
-  AttributeNode,
+  type AttributeNode,
+  type ComponentNode,
+  type DirectiveNode,
+  type JSChildNode,
+  NodeTypes,
+  type TransformContext,
   buildProps,
-  ComponentNode,
   createCallExpression,
-  DirectiveNode,
   findProp,
-  JSChildNode,
-  NodeTypes,
-  TransformContext
 } from '@vue/compiler-dom'
 import { SSR_RENDER_ATTRS } from '../runtimeHelpers'
-import { processChildren, SSRTransformContext } from '../ssrCodegenTransform'
+import {
+  type SSRTransformContext,
+  processChildren,
+} from '../ssrCodegenTransform'
 import { buildSSRProps } from './ssrTransformElement'
 
 const wipMap = new WeakMap<ComponentNode, WIPEntry>()
@@ -24,7 +27,7 @@ interface WIPEntry {
 // phase 1: build props
 export function ssrTransformTransitionGroup(
   node: ComponentNode,
-  context: TransformContext
+  context: TransformContext,
 ) {
   return () => {
     const tag = findProp(node, 'tag')
@@ -36,18 +39,18 @@ export function ssrTransformTransitionGroup(
         otherProps,
         true /* isComponent */,
         false /* isDynamicComponent */,
-        true /* ssr (skip event listeners) */
+        true /* ssr (skip event listeners) */,
       )
       let propsExp = null
       if (props || directives.length) {
         propsExp = createCallExpression(context.helper(SSR_RENDER_ATTRS), [
-          buildSSRProps(props, directives, context)
+          buildSSRProps(props, directives, context),
         ])
       }
       wipMap.set(node, {
         tag,
         propsExp,
-        scopeId: context.scopeId || null
+        scopeId: context.scopeId || null,
       })
     }
   }
@@ -56,7 +59,7 @@ export function ssrTransformTransitionGroup(
 // phase 2: process children
 export function ssrProcessTransitionGroup(
   node: ComponentNode,
-  context: SSRTransformContext
+  context: SSRTransformContext,
 ) {
   const entry = wipMap.get(node)
   if (entry) {
@@ -83,7 +86,7 @@ export function ssrProcessTransitionGroup(
          * be patched using the same key map) so we need to account for that here
          * by disabling nested fragment wrappers from being generated.
          */
-        true
+        true,
       )
       context.pushStringPart(`</`)
       context.pushStringPart(tag.exp!)
index 0515993d4753778d9f29d526353d75028d6cbbb2..d1899708821c4f107105c384a35349890832ef5d 100644 (file)
@@ -1,22 +1,22 @@
 import {
-  createStructuralDirectiveTransform,
-  ForNode,
-  processFor,
+  type ForNode,
+  NodeTypes,
   createCallExpression,
-  createFunctionExpression,
   createForLoopParams,
-  NodeTypes
+  createFunctionExpression,
+  createStructuralDirectiveTransform,
+  processFor,
 } from '@vue/compiler-dom'
 import {
-  SSRTransformContext,
-  processChildrenAsStatement
+  type SSRTransformContext,
+  processChildrenAsStatement,
 } from '../ssrCodegenTransform'
 import { SSR_RENDER_LIST } from '../runtimeHelpers'
 
 // Plugin for the first transform pass, which simply constructs the AST node
 export const ssrTransformFor = createStructuralDirectiveTransform(
   'for',
-  processFor
+  processFor,
 )
 
 // This is called during the 2nd transform pass to construct the SSR-specific
@@ -24,18 +24,18 @@ export const ssrTransformFor = createStructuralDirectiveTransform(
 export function ssrProcessFor(
   node: ForNode,
   context: SSRTransformContext,
-  disableNestedFragments = false
+  disableNestedFragments = false,
 ) {
   const needFragmentWrapper =
     !disableNestedFragments &&
     (node.children.length !== 1 || node.children[0].type !== NodeTypes.ELEMENT)
   const renderLoop = createFunctionExpression(
-    createForLoopParams(node.parseResult)
+    createForLoopParams(node.parseResult),
   )
   renderLoop.body = processChildrenAsStatement(
     node,
     context,
-    needFragmentWrapper
+    needFragmentWrapper,
   )
   // v-for always renders a fragment unless explicitly disabled
   if (!disableNestedFragments) {
@@ -44,8 +44,8 @@ export function ssrProcessFor(
   context.pushStatement(
     createCallExpression(context.helper(SSR_RENDER_LIST), [
       node.source,
-      renderLoop
-    ])
+      renderLoop,
+    ]),
   )
   if (!disableNestedFragments) {
     context.pushStringPart(`<!--]-->`)
index 9de1d0e9a2d24087a582b5624bc554ba9f15635b..32a5a7c00f14270c3bbdffeed71cf13ae7ed651b 100644 (file)
@@ -1,23 +1,23 @@
 import {
-  createStructuralDirectiveTransform,
-  processIf,
-  IfNode,
-  createIfStatement,
+  type BlockStatement,
+  type IfBranchNode,
+  type IfNode,
+  NodeTypes,
   createBlockStatement,
   createCallExpression,
-  IfBranchNode,
-  BlockStatement,
-  NodeTypes
+  createIfStatement,
+  createStructuralDirectiveTransform,
+  processIf,
 } from '@vue/compiler-dom'
 import {
-  SSRTransformContext,
-  processChildrenAsStatement
+  type SSRTransformContext,
+  processChildrenAsStatement,
 } from '../ssrCodegenTransform'
 
 // Plugin for the first transform pass, which simply constructs the AST node
 export const ssrTransformIf = createStructuralDirectiveTransform(
   /^(if|else|else-if)$/,
-  processIf
+  processIf,
 )
 
 // This is called during the 2nd transform pass to construct the SSR-specific
@@ -25,12 +25,12 @@ export const ssrTransformIf = createStructuralDirectiveTransform(
 export function ssrProcessIf(
   node: IfNode,
   context: SSRTransformContext,
-  disableNestedFragments = false
+  disableNestedFragments = false,
 ) {
   const [rootBranch] = node.branches
   const ifStatement = createIfStatement(
     rootBranch.condition!,
-    processIfBranch(rootBranch, context, disableNestedFragments)
+    processIfBranch(rootBranch, context, disableNestedFragments),
   )
   context.pushStatement(ifStatement)
 
@@ -40,13 +40,13 @@ export function ssrProcessIf(
     const branchBlockStatement = processIfBranch(
       branch,
       context,
-      disableNestedFragments
+      disableNestedFragments,
     )
     if (branch.condition) {
       // else-if
       currentIf = currentIf.alternate = createIfStatement(
         branch.condition,
-        branchBlockStatement
+        branchBlockStatement,
       )
     } else {
       // else
@@ -56,7 +56,7 @@ export function ssrProcessIf(
 
   if (!currentIf.alternate) {
     currentIf.alternate = createBlockStatement([
-      createCallExpression(`_push`, ['`<!---->`'])
+      createCallExpression(`_push`, ['`<!---->`']),
     ])
   }
 }
@@ -64,7 +64,7 @@ export function ssrProcessIf(
 function processIfBranch(
   branch: IfBranchNode,
   context: SSRTransformContext,
-  disableNestedFragments = false
+  disableNestedFragments = false,
 ): BlockStatement {
   const { children } = branch
   const needFragmentWrapper =
index 0c4bd17787533adb843923bc3db085ade6c67767..9a645397e1a0aa1028e89d69cfb9139c22337aad 100644 (file)
@@ -1,27 +1,27 @@
 import {
-  DirectiveTransform,
+  DOMErrorCodes,
+  type DirectiveTransform,
   ElementTypes,
-  transformModel,
-  findProp,
+  type ExpressionNode,
   NodeTypes,
-  createDOMCompilerError,
-  DOMErrorCodes,
-  createObjectProperty,
-  createSimpleExpression,
+  type PlainElementNode,
   createCallExpression,
-  PlainElementNode,
-  ExpressionNode,
   createConditionalExpression,
+  createDOMCompilerError,
   createInterpolation,
-  hasDynamicKeyVBind
+  createObjectProperty,
+  createSimpleExpression,
+  findProp,
+  hasDynamicKeyVBind,
+  transformModel,
 } from '@vue/compiler-dom'
 import {
-  SSR_LOOSE_EQUAL,
+  SSR_INCLUDE_BOOLEAN_ATTR,
   SSR_LOOSE_CONTAIN,
+  SSR_LOOSE_EQUAL,
   SSR_RENDER_DYNAMIC_MODEL,
-  SSR_INCLUDE_BOOLEAN_ATTR
 } from '../runtimeHelpers'
-import { DirectiveTransformResult } from 'packages/compiler-core/src/transform'
+import type { DirectiveTransformResult } from 'packages/compiler-core/src/transform'
 
 export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
   const model = dir.exp!
@@ -32,8 +32,8 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
       context.onError(
         createDOMCompilerError(
           DOMErrorCodes.X_V_MODEL_UNNECESSARY_VALUE,
-          value.loc
-        )
+          value.loc,
+        ),
       )
     }
   }
@@ -49,23 +49,23 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
                 createCallExpression(`Array.isArray`, [model]),
                 createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
                   model,
-                  value
+                  value,
                 ]),
                 createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
                   model,
-                  value
-                ])
-              )
+                  value,
+                ]),
+              ),
             ]),
             createSimpleExpression(' selected', true),
             createSimpleExpression('', true),
-            false /* no newline */
-          )
+            false /* no newline */,
+          ),
         )
       }
     } else if (plainNode.tag === 'optgroup') {
       plainNode.children.forEach(option =>
-        processOption(option as PlainElementNode)
+        processOption(option as PlainElementNode),
       )
     }
   }
@@ -74,7 +74,7 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
     const res: DirectiveTransformResult = { props: [] }
     const defaultProps = [
       // default value binding for text type inputs
-      createObjectProperty(`value`, model)
+      createObjectProperty(`value`, model),
     ]
     if (node.tag === 'input') {
       const type = findProp(node, 'type')
@@ -86,8 +86,8 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
             createCallExpression(context.helper(SSR_RENDER_DYNAMIC_MODEL), [
               type.exp!,
               model,
-              value
-            ])
+              value,
+            ]),
           ]
         } else if (type.value) {
           // static type
@@ -98,9 +98,9 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
                   `checked`,
                   createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
                     model,
-                    value
-                  ])
-                )
+                    value,
+                  ]),
+                ),
               ]
               break
             case 'checkbox':
@@ -115,9 +115,9 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
                     `checked`,
                     createCallExpression(context.helper(SSR_LOOSE_EQUAL), [
                       model,
-                      trueValue
-                    ])
-                  )
+                      trueValue,
+                    ]),
+                  ),
                 ]
               } else {
                 res.props = [
@@ -127,11 +127,11 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
                       createCallExpression(`Array.isArray`, [model]),
                       createCallExpression(context.helper(SSR_LOOSE_CONTAIN), [
                         model,
-                        value
+                        value,
                       ]),
-                      model
-                    )
-                  )
+                      model,
+                    ),
+                  ),
                 ]
               }
               break
@@ -139,8 +139,8 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
               context.onError(
                 createDOMCompilerError(
                   DOMErrorCodes.X_V_MODEL_ON_FILE_INPUT_ELEMENT,
-                  dir.loc
-                )
+                  dir.loc,
+                ),
               )
               break
             default:
@@ -171,8 +171,8 @@ export const ssrTransformModel: DirectiveTransform = (dir, node, context) => {
       context.onError(
         createDOMCompilerError(
           DOMErrorCodes.X_V_MODEL_ON_INVALID_ELEMENT,
-          dir.loc
-        )
+          dir.loc,
+        ),
       )
     }
 
index ecd1c0d60b60c8a9edf088002134a1434458be56..3e3be4342008f3d98ebf18a9bb70c34a7b023925 100644 (file)
@@ -1,17 +1,17 @@
 import {
-  DirectiveTransform,
   DOMErrorCodes,
-  createObjectProperty,
-  createSimpleExpression,
+  type DirectiveTransform,
   createConditionalExpression,
+  createDOMCompilerError,
   createObjectExpression,
-  createDOMCompilerError
+  createObjectProperty,
+  createSimpleExpression,
 } from '@vue/compiler-dom'
 
 export const ssrTransformShow: DirectiveTransform = (dir, node, context) => {
   if (!dir.exp) {
     context.onError(
-      createDOMCompilerError(DOMErrorCodes.X_V_SHOW_NO_EXPRESSION)
+      createDOMCompilerError(DOMErrorCodes.X_V_SHOW_NO_EXPRESSION),
     )
   }
   return {
@@ -24,12 +24,12 @@ export const ssrTransformShow: DirectiveTransform = (dir, node, context) => {
           createObjectExpression([
             createObjectProperty(
               `display`,
-              createSimpleExpression(`none`, true)
-            )
+              createSimpleExpression(`none`, true),
+            ),
           ]),
-          false /* no newline */
-        )
-      )
-    ]
+          false /* no newline */,
+        ),
+      ),
+    ],
   }
 }
index 2d9d40332546e1bff963e0dfb4945b000239af5b..1cdf6de721407aabe3882c51df1723c4b9f99f65 100644 (file)
@@ -2,7 +2,7 @@ import { defineComponent } from 'vue'
 
 const _CustomPropsNotErased = defineComponent({
   props: {},
-  setup() {}
+  setup() {},
 })
 
 // #8376
index 0d7707a7c193545bf6724f30250989833a86cc94..1ac5f64d19a3796cd57e3e6517fc1dee04a323aa 100644 (file)
@@ -10,5 +10,5 @@ app.directive<HTMLElement, string>('custom', {
 
     // @ts-expect-error not any
     expectType<number>(binding.value)
-  }
+  },
 })
index ebfc986a757942266bc2173602f5deae1df3b909..065f695686560840d1b3e7c473625fe795ba6fd5 100644 (file)
@@ -1,10 +1,10 @@
-import { createApp, App, Plugin, defineComponent } from 'vue'
+import { type App, type Plugin, createApp, defineComponent } from 'vue'
 
 const app = createApp({})
 
 // Plugin without types accept anything
 const PluginWithoutType: Plugin = {
-  install(app: App) {}
+  install(app: App) {},
 }
 
 app.use(PluginWithoutType)
@@ -22,12 +22,12 @@ const PluginWithObjectOptions = {
     options.option1
     options.option2
     options.option3
-  }
+  },
 }
 
 for (const Plugin of [
   PluginWithObjectOptions,
-  PluginWithObjectOptions.install
+  PluginWithObjectOptions.install,
 ]) {
   // @ts-expect-error: no params
   app.use(Plugin)
@@ -42,7 +42,7 @@ for (const Plugin of [
 }
 
 const PluginNoOptions = {
-  install(app: App) {}
+  install(app: App) {},
 }
 
 for (const Plugin of [PluginNoOptions, PluginNoOptions.install]) {
@@ -55,7 +55,7 @@ for (const Plugin of [PluginNoOptions, PluginNoOptions.install]) {
 }
 
 const PluginMultipleArgs = {
-  install: (app: App, a: string, b: number) => {}
+  install: (app: App, a: string, b: number) => {},
 }
 
 for (const Plugin of [PluginMultipleArgs, PluginMultipleArgs.install]) {
@@ -67,12 +67,12 @@ for (const Plugin of [PluginMultipleArgs, PluginMultipleArgs.install]) {
 const PluginOptionalOptions = {
   install(
     app: App,
-    options: PluginOptions = { option2: 2, option3: true, option1: 'foo' }
+    options: PluginOptions = { option2: 2, option3: true, option1: 'foo' },
   ) {
     options.option1
     options.option2
     options.option3
-  }
+  },
 }
 
 for (const Plugin of [PluginOptionalOptions, PluginOptionalOptions.install]) {
@@ -102,6 +102,6 @@ app.component(
   defineComponent({
     ...aliases[key],
     name: key,
-    aliasName: aliases[key].name
-  })
+    aliasName: aliases[key].name,
+  }),
 )
index 8ac3e333f991b4bfd2019753a991ea1fa67a0332..ebff2955cfb62b13862f0857ca140d3425e85b27 100644 (file)
@@ -1,5 +1,5 @@
 import { CustomPropsNotErased } from '@vue/dts-built-test'
-import { expectType, describe } from './utils'
+import { describe, expectType } from './utils'
 
 declare module 'vue' {
   interface ComponentCustomProps {
index c6282373983ca64deb712150af55e78f942968aa..2729a3cc4b0c842059639725930b30efb6a7d5b0 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  createBlock,
-  VNode,
-  Teleport,
-  Text,
-  Static,
   Comment,
   Fragment,
+  Static,
   Suspense,
-  defineComponent
+  Teleport,
+  Text,
+  type VNode,
+  createBlock,
+  defineComponent,
 } from 'vue'
 import { expectType } from './utils'
 
index 98b3f42097b518cf70d7f0f3001344be1855726b..d08eca12a6ca5987a67a04ab8ead58d73672a395 100644 (file)
@@ -1,25 +1,25 @@
 import {
-  Component,
+  type Component,
+  type ComponentPublicInstance,
+  type EmitsOptions,
+  type FunctionalComponent,
+  type PropType,
+  type Ref,
+  type SetupContext,
+  type ShallowUnwrapRef,
   defineComponent,
-  PropType,
   ref,
-  Ref,
-  ShallowUnwrapRef,
-  FunctionalComponent,
-  ComponentPublicInstance,
   toRefs,
-  SetupContext,
-  EmitsOptions
 } from 'vue'
-import { describe, expectAssignable, expectType, IsAny } from './utils'
+import { type IsAny, describe, expectAssignable, expectType } from './utils'
 
 declare function extractComponentOptions<
   Props,
   RawBindings,
   Emits extends EmitsOptions | Record<string, any[]>,
-  Slots extends Record<string, any>
+  Slots extends Record<string, any>,
 >(
-  obj: Component<Props, RawBindings, any, any, any, Emits, Slots>
+  obj: Component<Props, RawBindings, any, any, any, Emits, Slots>,
 ): {
   props: Props
   emits: Emits
@@ -79,24 +79,24 @@ describe('object props', () => {
         // required should make property non-void
         b: {
           type: String,
-          required: true
+          required: true,
         },
         e: Function,
         // default value should infer type and make it non-void
         bb: {
-          default: 'hello'
+          default: 'hello',
         },
         bbb: {
           // Note: default function value requires arrow syntax + explicit
           // annotation
-          default: (props: any) => (props.bb as string) || 'foo'
+          default: (props: any) => (props.bb as string) || 'foo',
         },
         // explicit type casting
         cc: Array as PropType<string[]>,
         // required + type casting
         dd: {
           type: Object as PropType<{ n: 1 }>,
-          required: true
+          required: true,
         },
         // return type
         ee: Function as PropType<() => string>,
@@ -107,39 +107,39 @@ describe('object props', () => {
         // required + constructor type casting
         ddd: {
           type: Array as () => string[],
-          required: true
+          required: true,
         },
         // required + object return
         eee: {
           type: Function as PropType<() => { a: string }>,
-          required: true
+          required: true,
         },
         // required + arguments + object return
         fff: {
           type: Function as PropType<(a: number, b: string) => { a: boolean }>,
-          required: true
+          required: true,
         },
         hhh: {
           type: Boolean,
-          required: true
+          required: true,
         },
         // default + type casting
         ggg: {
           type: String as PropType<'foo' | 'bar'>,
-          default: 'foo'
+          default: 'foo',
         },
         // default + function
         ffff: {
           type: Function as PropType<(a: number, b: string) => { a: boolean }>,
-          default: (_a: number, _b: string) => ({ a: true })
+          default: (_a: number, _b: string) => ({ a: true }),
         },
         validated: {
           type: String,
           // validator requires explicit annotation
-          validator: (val: unknown) => val !== ''
+          validator: (val: unknown) => val !== '',
         },
         object: Object as PropType<object>,
-        zzz: Object as PropType<any>
+        zzz: Object as PropType<any>,
       },
       setup(props) {
         const refs = toRefs(props)
@@ -167,12 +167,12 @@ describe('object props', () => {
           setupA: 1,
           setupB: ref(1),
           setupC: {
-            a: ref(2)
+            a: ref(2),
           },
           setupD: undefined as Ref<number> | undefined,
-          setupProps: props
+          setupProps: props,
         }
-      }
+      },
     })
 
     const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
@@ -262,24 +262,24 @@ describe('object props', () => {
         // required should make property non-void
         b: {
           type: String,
-          required: true
+          required: true,
         },
         e: Function,
         // default value should infer type and make it non-void
         bb: {
-          default: 'hello'
+          default: 'hello',
         },
         bbb: {
           // Note: default function value requires arrow syntax + explicit
           // annotation
-          default: (props: any) => (props.bb as string) || 'foo'
+          default: (props: any) => (props.bb as string) || 'foo',
         },
         // explicit type casting
         cc: Array as PropType<string[]>,
         // required + type casting
         dd: {
           type: Object as PropType<{ n: 1 }>,
-          required: true
+          required: true,
         },
         // return type
         ee: Function as PropType<() => string>,
@@ -290,45 +290,45 @@ describe('object props', () => {
         // required + constructor type casting
         ddd: {
           type: Array as () => string[],
-          required: true
+          required: true,
         },
         // required + object return
         eee: {
           type: Function as PropType<() => { a: string }>,
-          required: true
+          required: true,
         },
         // required + arguments + object return
         fff: {
           type: Function as PropType<(a: number, b: string) => { a: boolean }>,
-          required: true
+          required: true,
         },
         hhh: {
           type: Boolean,
-          required: true
+          required: true,
         },
         // default + type casting
         ggg: {
           type: String as PropType<'foo' | 'bar'>,
-          default: 'foo'
+          default: 'foo',
         },
         // default + function
         ffff: {
           type: Function as PropType<(a: number, b: string) => { a: boolean }>,
-          default: (_a: number, _b: string) => ({ a: true })
+          default: (_a: number, _b: string) => ({ a: true }),
         },
         validated: {
           type: String,
           // validator requires explicit annotation
-          validator: (val: unknown) => val !== ''
+          validator: (val: unknown) => val !== '',
         },
-        object: Object as PropType<object>
+        object: Object as PropType<object>,
       },
 
       setup() {
         return {
-          setupA: 1
+          setupA: 1,
         }
-      }
+      },
     } as const
 
     const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
@@ -367,9 +367,9 @@ describe('array props', () => {
       props: ['a', 'b'],
       setup() {
         return {
-          c: 1
+          c: 1,
         }
-      }
+      },
     })
 
     const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
@@ -388,9 +388,9 @@ describe('array props', () => {
       props: ['a', 'b'] as const,
       setup() {
         return {
-          c: 1
+          c: 1,
         }
-      }
+      },
     }
 
     const { props, rawBindings, setup } = extractComponentOptions(MyComponent)
@@ -412,9 +412,9 @@ describe('no props', () => {
     const MyComponent = defineComponent({
       setup() {
         return {
-          setupA: 1
+          setupA: 1,
         }
-      }
+      },
     })
 
     const { rawBindings, setup } = extractComponentOptions(MyComponent)
@@ -433,9 +433,9 @@ describe('no props', () => {
     const MyComponent = {
       setup() {
         return {
-          setupA: 1
+          setupA: 1,
         }
-      }
+      },
     }
 
     const { rawBindings, setup } = extractComponentOptions(MyComponent)
@@ -469,7 +469,7 @@ describe('functional', () => {
 
     const MyComponent: FunctionalComponent<Props, Emits, Slots> = (
       props,
-      { emit, slots }
+      { emit, slots },
     ) => {
       expectType<Props>(props)
       expectType<{
@@ -508,7 +508,7 @@ describe('SetupContext', () => {
 
   describe('short emits', () => {
     const {
-      emit
+      emit,
     }: SetupContext<{
       a: [val: string]
       b: [val: number]
index 2fb20312b2c9b6e353a4282a60377c1ddd608ddb..a804bb10d5ddbab655bf9dc1398a9a647e3d748c 100644 (file)
@@ -1,22 +1,22 @@
 import {
+  type ComponentInstance,
+  type ComponentPublicInstance,
+  type FunctionalComponent,
   defineComponent,
-  FunctionalComponent,
-  ComponentPublicInstance,
-  ComponentInstance,
-  ref
+  ref,
 } from 'vue'
-import { expectType, describe } from './utils'
+import { describe, expectType } from './utils'
 
 describe('defineComponent', () => {
   const CompSetup = defineComponent({
     props: {
-      test: String
+      test: String,
     },
     setup() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   })
   const compSetup: ComponentInstance<typeof CompSetup> = {} as any
 
@@ -43,23 +43,23 @@ describe('options component', () => {
   // Options
   const CompOptions = defineComponent({
     props: {
-      test: String
+      test: String,
     },
     data() {
       return {
-        a: 1
+        a: 1,
       }
     },
     computed: {
       b() {
         return 'test'
-      }
+      },
     },
     methods: {
       func(a: string) {
         return true
-      }
-    }
+      },
+    },
   })
   const compOptions: ComponentInstance<typeof CompOptions> = {} as any
   expectType<string | undefined>(compOptions.test)
@@ -73,13 +73,13 @@ describe('object no defineComponent', () => {
 
   const CompObjectSetup = {
     props: {
-      test: String
+      test: String,
     },
     setup() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   }
   const compObjectSetup: ComponentInstance<typeof CompObjectSetup> = {} as any
   expectType<string | undefined>(compObjectSetup.test)
@@ -88,13 +88,13 @@ describe('object no defineComponent', () => {
 
   const CompObjectData = {
     props: {
-      test: String
+      test: String,
     },
     data() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   }
   const compObjectData: ComponentInstance<typeof CompObjectData> = {} as any
   expectType<string | undefined>(compObjectData.test)
@@ -104,9 +104,9 @@ describe('object no defineComponent', () => {
   const CompObjectNoProps = {
     data() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   }
   const compObjectNoProps: ComponentInstance<typeof CompObjectNoProps> =
     {} as any
@@ -129,7 +129,7 @@ describe('Generic component', () => {
           {props.msg} {count.value}
         </div>
       )
-    }
+    },
   )
 
   // defaults to known types since types are resolved on instantiation
index 4b3c5d7d195cd21131a1f26c3f8514f5caab3857..68364191945aa8b873c23283b3992c908bc523b3 100644 (file)
@@ -20,8 +20,8 @@ export const Custom = defineComponent({
     bar: String,
     baz: {
       type: Number,
-      required: true
-    }
+      required: true,
+    },
   },
 
   data: () => ({ counter: 0 }),
@@ -42,8 +42,8 @@ export const Custom = defineComponent({
       this.state = 'not valid'
       // @ts-expect-error
       this.$.appContext.config.globalProperties.state = 'not valid'
-    }
-  }
+    },
+  },
 })
 
 expectType<JSX.Element>(<Custom baz={1} />)
index 9c989c23b24a4ecdd62b65911324f387eb5a964c..41646751b8b78999fdb78c8af23a86d7fe82cd1c 100644 (file)
@@ -1,21 +1,21 @@
 import {
-  Component,
-  defineComponent,
-  PropType,
-  ref,
-  reactive,
+  type Component,
+  type ComponentOptions,
+  type ComponentPublicInstance,
+  type PropType,
+  type SetupContext,
+  type Slots,
+  type SlotsType,
+  type VNode,
   createApp,
-  ComponentPublicInstance,
-  ComponentOptions,
-  SetupContext,
+  defineComponent,
   h,
-  SlotsType,
-  Slots,
-  VNode,
+  reactive,
+  ref,
   withKeys,
-  withModifiers
+  withModifiers,
 } from 'vue'
-import { describe, expectType, IsUnion } from './utils'
+import { type IsUnion, describe, expectType } from './utils'
 
 describe('with object props', () => {
   interface ExpectedProps {
@@ -56,34 +56,34 @@ describe('with object props', () => {
     // required should make property non-void
     b: {
       type: String,
-      required: true as true
+      required: true as true,
     },
     e: Function,
     h: Boolean,
     j: Function as PropType<undefined | (() => string | undefined)>,
     // default value should infer type and make it non-void
     bb: {
-      default: 'hello'
+      default: 'hello',
     },
     bbb: {
       // Note: default function value requires arrow syntax + explicit
       // annotation
-      default: (props: any) => (props.bb as string) || 'foo'
+      default: (props: any) => (props.bb as string) || 'foo',
     },
     bbbb: {
       type: String,
-      default: undefined
+      default: undefined,
     },
     bbbbb: {
       type: String,
-      default: () => undefined
+      default: () => undefined,
     },
     // explicit type casting
     cc: Array as PropType<string[]>,
     // required + type casting
     dd: {
       type: Object as PropType<{ n: 1 }>,
-      required: true as true
+      required: true as true,
     },
     // return type
     ee: Function as PropType<() => string>,
@@ -94,31 +94,31 @@ describe('with object props', () => {
     // required + constructor type casting
     ddd: {
       type: Array as () => string[],
-      required: true as true
+      required: true as true,
     },
     // required + object return
     eee: {
       type: Function as PropType<() => { a: string }>,
-      required: true as true
+      required: true as true,
     },
     // required + arguments + object return
     fff: {
       type: Function as PropType<(a: number, b: string) => { a: boolean }>,
-      required: true as true
+      required: true as true,
     },
     hhh: {
       type: Boolean,
-      required: true as true
+      required: true as true,
     },
     // default + type casting
     ggg: {
       type: String as PropType<'foo' | 'bar'>,
-      default: 'foo'
+      default: 'foo',
     },
     // default + function
     ffff: {
       type: Function as PropType<(a: number, b: string) => { a: boolean }>,
-      default: (a: number, b: string) => ({ a: a > +b })
+      default: (a: number, b: string) => ({ a: a > +b }),
     },
     // union + function with different return types
     iii: Function as PropType<(() => string) | (() => number)>,
@@ -127,18 +127,18 @@ describe('with object props', () => {
       type: Function as PropType<
         ((arg1: string) => string) | ((arg1: string, arg2: string) => string)
       >,
-      required: true as true
+      required: true as true,
     },
     kkk: null,
     validated: {
       type: String,
       // validator requires explicit annotation
-      validator: (val: unknown) => val !== ''
+      validator: (val: unknown) => val !== '',
     },
     date: Date,
     l: [Date],
     ll: [Date, Number],
-    lll: [String, Number]
+    lll: [String, Number],
   }
 
   const MyComponent = defineComponent({
@@ -185,11 +185,11 @@ describe('with object props', () => {
       return {
         c: ref(1),
         d: {
-          e: ref('hi')
+          e: ref('hi'),
         },
         f: reactive({
-          g: ref('hello' as GT)
-        })
+          g: ref('hello' as GT),
+        }),
       }
     },
     provide() {
@@ -260,7 +260,7 @@ describe('with object props', () => {
       this.c = 2
 
       return null
-    }
+    },
   })
 
   expectType<Component>(MyComponent)
@@ -290,7 +290,7 @@ describe('with object props', () => {
       // should allow ref
       ref={'foo'}
       ref_for={true}
-    />
+    />,
   )
 
   expectType<Component>(
@@ -302,7 +302,7 @@ describe('with object props', () => {
       fff={(a, b) => ({ a: a > +b })}
       hhh={false}
       jjj={() => ''}
-    />
+    />,
   )
 
   // @ts-expect-error missing required props
@@ -327,13 +327,13 @@ describe('with object props', () => {
         default(): number {
           // @ts-expect-error
           return this.otherProp + 1
-        }
+        },
       },
       otherProp: {
         type: Number,
-        required: true
-      }
-    }
+        required: true,
+      },
+    },
   })
 })
 
@@ -343,9 +343,9 @@ describe('type inference w/ optional props declaration', () => {
       expectType<string>(props.msg)
       expectType<string[]>(props.a)
       return {
-        b: 1
+        b: 1,
       }
-    }
+    },
   })
 
   expectType<JSX.Element>(<MyComponent msg="1" a={['1']} />)
@@ -373,7 +373,7 @@ describe('type inference w/ array props declaration', () => {
       expectType<any>(props.a)
       expectType<any>(props.b)
       return {
-        c: 1
+        c: 1,
       }
     },
     render() {
@@ -384,7 +384,7 @@ describe('type inference w/ array props declaration', () => {
       expectType<any>(this.a)
       expectType<any>(this.b)
       expectType<number>(this.c)
-    }
+    },
   })
   expectType<JSX.Element>(<MyComponent a={[1, 2]} b="b" />)
   // @ts-expect-error
@@ -396,7 +396,7 @@ describe('type inference w/ options API', () => {
     props: { a: Number },
     setup() {
       return {
-        b: 123
+        b: 123,
       }
     },
     data() {
@@ -405,7 +405,7 @@ describe('type inference w/ options API', () => {
       expectType<number | undefined>(this.a)
       return {
         c: this.a || 123,
-        someRef: ref(0)
+        someRef: ref(0),
       }
     },
     computed: {
@@ -424,14 +424,14 @@ describe('type inference w/ options API', () => {
           expectType<number>(this.b)
           expectType<number>(this.d)
           expectType<number>(v)
-        }
-      }
+        },
+      },
     },
     watch: {
       a() {
         expectType<number>(this.b)
         this.b + 1
-      }
+      },
     },
     created() {
       // props
@@ -461,7 +461,7 @@ describe('type inference w/ options API', () => {
       },
       returnSomething() {
         return this.a
-      }
+      },
     },
     render() {
       // props
@@ -476,7 +476,7 @@ describe('type inference w/ options API', () => {
       expectType<number>(this.e)
       // method
       expectType<() => number | undefined>(this.returnSomething)
-    }
+    },
   })
 })
 
@@ -486,30 +486,30 @@ describe('with mixins', () => {
     props: {
       aP1: {
         type: String,
-        default: 'aP1'
+        default: 'aP1',
       },
-      aP2: Boolean
+      aP2: Boolean,
     },
     data() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   })
   const MixinB = defineComponent({
     props: ['bP1', 'bP2'],
     data() {
       return {
-        b: 2
+        b: 2,
       }
-    }
+    },
   })
   const MixinC = defineComponent({
     data() {
       return {
-        c: 3
+        c: 3,
       }
-    }
+    },
   })
   const MixinD = defineComponent({
     mixins: [MixinA],
@@ -520,7 +520,7 @@ describe('with mixins', () => {
       expectError<string>(this.dC2)
 
       return {
-        d: 4
+        d: 4,
       }
     },
     setup(props) {
@@ -532,8 +532,8 @@ describe('with mixins', () => {
       },
       dC2() {
         return this.aP1 + 'dC2'
-      }
-    }
+      },
+    },
   })
   const MyComponent = defineComponent({
     mixins: [MixinA, MixinB, MixinC, MixinD],
@@ -542,8 +542,8 @@ describe('with mixins', () => {
       // required should make property non-void
       z: {
         type: String,
-        required: true
-      }
+        required: true,
+      },
     },
 
     data(vm) {
@@ -623,12 +623,12 @@ describe('with mixins', () => {
       this.d = 5
 
       return null
-    }
+    },
   })
 
   // Test TSX
   expectType<JSX.Element>(
-    <MyComponent aP1={'aP'} aP2 bP1={1} bP2={[1, 2]} z={'z'} />
+    <MyComponent aP1={'aP'} aP2 bP1={1} bP2={[1, 2]} z={'z'} />,
   )
 
   // missing required props
@@ -648,19 +648,19 @@ describe('with extends', () => {
       aP1: Boolean,
       aP2: {
         type: Number,
-        default: 2
-      }
+        default: 2,
+      },
     },
     data() {
       return {
-        a: 1
+        a: 1,
       }
     },
     computed: {
       c(): number {
         return this.aP2 + this.a
-      }
-    }
+      },
+    },
   })
   const MyComponent = defineComponent({
     extends: Base,
@@ -668,8 +668,8 @@ describe('with extends', () => {
       // required should make property non-void
       z: {
         type: String,
-        required: true
-      }
+        required: true,
+      },
     },
     render() {
       const props = this.$props
@@ -690,7 +690,7 @@ describe('with extends', () => {
       this.a = 5
 
       return null
-    }
+    },
   })
 
   // Test TSX
@@ -713,19 +713,19 @@ describe('extends with mixins', () => {
     props: {
       mP1: {
         type: String,
-        default: 'mP1'
+        default: 'mP1',
       },
       mP2: Boolean,
       mP3: {
         type: Boolean,
-        required: true
-      }
+        required: true,
+      },
     },
     data() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   })
   const Base = defineComponent({
     emits: ['foo'],
@@ -733,23 +733,23 @@ describe('extends with mixins', () => {
       p1: Boolean,
       p2: {
         type: Number,
-        default: 2
+        default: 2,
       },
       p3: {
         type: Boolean,
-        required: true
-      }
+        required: true,
+      },
     },
     data() {
       return {
-        b: 2
+        b: 2,
       }
     },
     computed: {
       c(): number {
         return this.p2 + this.b
-      }
-    }
+      },
+    },
   })
   const MyComponent = defineComponent({
     extends: Base,
@@ -759,8 +759,8 @@ describe('extends with mixins', () => {
       // required should make property non-void
       z: {
         type: String,
-        required: true
-      }
+        required: true,
+      },
     },
     render() {
       const props = this.$props
@@ -792,7 +792,7 @@ describe('extends with mixins', () => {
       this.a = 5
 
       return null
-    }
+    },
   })
 
   // Test TSX
@@ -821,14 +821,14 @@ describe('extends with mixins', () => {
   const CompWithD = defineComponent({
     data() {
       return { foo: 1 }
-    }
+    },
   })
   const CompWithC = defineComponent({
     computed: {
       foo() {
         return 1
-      }
-    }
+      },
+    },
   })
   const CompWithM = defineComponent({ methods: { foo() {} } })
   const CompEmpty = defineComponent({})
@@ -837,19 +837,19 @@ describe('extends with mixins', () => {
     mixins: [CompWithD, CompEmpty],
     mounted() {
       expectType<number>(this.foo)
-    }
+    },
   })
   defineComponent({
     mixins: [CompWithC, CompEmpty],
     mounted() {
       expectType<number>(this.foo)
-    }
+    },
   })
   defineComponent({
     mixins: [CompWithM, CompEmpty],
     mounted() {
       expectType<() => void>(this.foo)
-    }
+    },
   })
 })
 
@@ -858,16 +858,16 @@ describe('compatibility w/ createApp', () => {
   createApp(comp).mount('#hello')
 
   const comp2 = defineComponent({
-    props: { foo: String }
+    props: { foo: String },
   })
   createApp(comp2).mount('#hello')
 
   const comp3 = defineComponent({
     setup() {
       return {
-        a: 1
+        a: 1,
       }
-    }
+    },
   })
   createApp(comp3).mount('#hello')
 })
@@ -876,7 +876,7 @@ describe('defineComponent', () => {
   describe('should accept components defined with defineComponent', () => {
     const comp = defineComponent({})
     defineComponent({
-      components: { comp }
+      components: { comp },
     })
   })
 
@@ -886,7 +886,7 @@ describe('defineComponent', () => {
       constructor(_props: { foo: string }) {}
     }
     defineComponent({
-      components: { Comp }
+      components: { Comp },
     })
   })
 })
@@ -905,7 +905,7 @@ describe('emits', () => {
   defineComponent({
     emits: {
       click: (n: number) => typeof n === 'number',
-      input: (b: string) => b.length > 1
+      input: (b: string) => b.length > 1,
     },
     setup(props, { emit }) {
       expectType<((n: number) => boolean) | undefined>(props.onClick)
@@ -955,7 +955,7 @@ describe('emits', () => {
         //  @ts-expect-error
         this.$emit('input', 1)
       })
-    }
+    },
   })
 
   // with array emits
@@ -976,13 +976,13 @@ describe('emits', () => {
       this.$emit('bar')
       //  @ts-expect-error
       this.$emit('nope')
-    }
+    },
   })
 
   // with tsx
   const Component = defineComponent({
     emits: {
-      click: (n: number) => typeof n === 'number'
+      click: (n: number) => typeof n === 'number',
     },
     setup(props, { emit }) {
       expectType<((n: number) => any) | undefined>(props.onClick)
@@ -991,7 +991,7 @@ describe('emits', () => {
       emit('click')
       //  @ts-expect-error
       emit('click', 'foo')
-    }
+    },
   })
 
   defineComponent({
@@ -1003,7 +1003,7 @@ describe('emits', () => {
           }}
         />
       )
-    }
+    },
   })
 
   // without emits
@@ -1011,7 +1011,7 @@ describe('emits', () => {
     setup(props, { emit }) {
       emit('test', 1)
       emit('test')
-    }
+    },
   })
 
   // emit should be valid when ComponentPublicInstance is used.
@@ -1026,8 +1026,8 @@ describe('emits', () => {
       foo(): boolean {
         // @ts-expect-error
         return this.bar === 3
-      }
-    }
+      },
+    },
   })
 })
 
@@ -1035,18 +1035,18 @@ describe('inject', () => {
   // with object inject
   defineComponent({
     props: {
-      a: String
+      a: String,
     },
     inject: {
       foo: 'foo',
-      bar: 'bar'
+      bar: 'bar',
     },
     created() {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
       this.foobar = 1
-    }
+    },
   })
 
   // with array inject
@@ -1058,7 +1058,7 @@ describe('inject', () => {
       expectType<unknown>(this.bar)
       //  @ts-expect-error
       this.foobar = 1
-    }
+    },
   })
 
   // with no props
@@ -1066,19 +1066,19 @@ describe('inject', () => {
     inject: {
       foo: {
         from: 'pfoo',
-        default: 'foo'
+        default: 'foo',
       },
       bar: {
         from: 'pbar',
-        default: 'bar'
-      }
+        default: 'bar',
+      },
     },
     created() {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
       this.foobar = 1
-    }
+    },
   })
 
   // without inject
@@ -1089,13 +1089,13 @@ describe('inject', () => {
       this.foo = 1
       //  @ts-expect-error
       this.bar = 1
-    }
+    },
   })
 })
 
 describe('componentOptions setup should be `SetupContext`', () => {
   expectType<ComponentOptions['setup']>(
-    {} as (props: Record<string, any>, ctx: SetupContext) => any
+    {} as (props: Record<string, any>, ctx: SetupContext) => any,
   )
 })
 
@@ -1104,17 +1104,17 @@ describe('extract instance type', () => {
     props: {
       baseA: {
         type: Number,
-        default: 1
-      }
-    }
+        default: 1,
+      },
+    },
   })
   const MixinA = defineComponent({
     props: {
       mA: {
         type: String,
-        default: ''
-      }
-    }
+        default: '',
+      },
+    },
   })
   const CompA = defineComponent({
     extends: Base,
@@ -1122,14 +1122,14 @@ describe('extract instance type', () => {
     props: {
       a: {
         type: Boolean,
-        default: false
+        default: false,
       },
       b: {
         type: String,
-        required: true
+        required: true,
       },
-      c: Number
-    }
+      c: Number,
+    },
   })
 
   const compA = {} as InstanceType<typeof CompA>
@@ -1162,11 +1162,11 @@ describe('async setup', () => {
       return {
         a: ref(1),
         b: {
-          c: ref('hi')
+          c: ref('hi'),
         },
         d: reactive({
-          e: ref('hello' as GT)
-        })
+          e: ref('hello' as GT),
+        }),
       }
     },
     render() {
@@ -1177,7 +1177,7 @@ describe('async setup', () => {
 
       // setup context properties should be mutable
       this.a = 2
-    }
+    },
   })
 
   const vm = {} as InstanceType<typeof Comp>
@@ -1199,7 +1199,7 @@ describe('DefineComponent should infer correct types when assigning to Component
       expectType<[]>(attrs)
       // @ts-expect-error should not be any
       expectType<[]>(slots)
-    }
+    },
   })
   expectType<Component>(component)
 })
@@ -1208,15 +1208,15 @@ describe('DefineComponent should infer correct types when assigning to Component
 describe('should allow to assign props', () => {
   const Child = defineComponent({
     props: {
-      bar: String
-    }
+      bar: String,
+    },
   })
 
   const Parent = defineComponent({
     props: {
       ...Child.props,
-      foo: String
-    }
+      foo: String,
+    },
   })
 
   const child = new Child()
@@ -1229,29 +1229,29 @@ describe('prop starting with `on*` is broken', () => {
     props: {
       onX: {
         type: Function as PropType<(a: 1) => void>,
-        required: true
-      }
+        required: true,
+      },
     },
     setup(props) {
       expectType<(a: 1) => void>(props.onX)
       props.onX(1)
-    }
+    },
   })
 
   defineComponent({
     props: {
       onX: {
         type: Function as PropType<(a: 1) => void>,
-        required: true
-      }
+        required: true,
+      },
     },
     emits: {
-      test: (a: 1) => true
+      test: (a: 1) => true,
     },
     setup(props) {
       expectType<(a: 1) => void>(props.onX)
       expectType<undefined | ((a: 1) => any)>(props.onTest)
-    }
+    },
   })
 })
 
@@ -1269,7 +1269,7 @@ describe('function syntax w/ generics', () => {
           {props.msg} {count.value}
         </div>
       )
-    }
+    },
   )
 
   expectType<JSX.Element>(<Comp msg="fse" list={['foo']} />)
@@ -1277,16 +1277,16 @@ describe('function syntax w/ generics', () => {
 
   expectType<JSX.Element>(
     // @ts-expect-error missing prop
-    <Comp msg={123} />
+    <Comp msg={123} />,
   )
 
   expectType<JSX.Element>(
     // @ts-expect-error generics don't match
-    <Comp msg="fse" list={[123]} />
+    <Comp msg="fse" list={[123]} />,
   )
   expectType<JSX.Element>(
     // @ts-expect-error generics don't match
-    <Comp msg={123} list={['123']} />
+    <Comp msg={123} list={['123']} />,
   )
 })
 
@@ -1299,8 +1299,8 @@ describe('function syntax w/ emits', () => {
       return () => {}
     },
     {
-      emits: ['foo']
-    }
+      emits: ['foo'],
+    },
   )
   expectType<JSX.Element>(<Foo msg="hi" onFoo={() => {}} />)
   // @ts-expect-error
@@ -1317,9 +1317,9 @@ describe('function syntax w/ emits', () => {
     },
     {
       emits: {
-        foo: (a: string) => true
-      }
-    }
+        foo: (a: string) => true,
+      },
+    },
   )
 })
 
@@ -1331,8 +1331,8 @@ describe('function syntax w/ runtime props', () => {
       return () => {}
     },
     {
-      props: ['msg']
-    }
+      props: ['msg'],
+    },
   )
 
   defineComponent(
@@ -1340,8 +1340,8 @@ describe('function syntax w/ runtime props', () => {
       return () => {}
     },
     {
-      props: ['msg']
-    }
+      props: ['msg'],
+    },
   )
 
   defineComponent(
@@ -1350,9 +1350,9 @@ describe('function syntax w/ runtime props', () => {
     },
     {
       props: {
-        msg: String
-      }
-    }
+        msg: String,
+      },
+    },
   )
 
   // @ts-expect-error string prop names don't match
@@ -1361,8 +1361,8 @@ describe('function syntax w/ runtime props', () => {
       return () => {}
     },
     {
-      props: ['bar']
-    }
+      props: ['bar'],
+    },
   )
 
   defineComponent(
@@ -1372,9 +1372,9 @@ describe('function syntax w/ runtime props', () => {
     {
       props: {
         // @ts-expect-error prop type mismatch
-        msg: Number
-      }
-    }
+        msg: Number,
+      },
+    },
   )
 
   // @ts-expect-error prop keys don't match
@@ -1385,9 +1385,9 @@ describe('function syntax w/ runtime props', () => {
     {
       props: {
         msg: String,
-        bar: String
-      }
-    }
+        bar: String,
+      },
+    },
   )
 })
 
@@ -1399,16 +1399,16 @@ export default {
   b: defineComponent({
     data() {
       return {}
-    }
+    },
   }),
   c: defineComponent({
-    props: ['a']
+    props: ['a'],
   }),
   d: defineComponent({
     props: {
-      a: Number
-    }
-  })
+      a: Number,
+    },
+  }),
 }
 
 describe('slots', () => {
@@ -1421,10 +1421,10 @@ describe('slots', () => {
     }>,
     setup(props, { slots }) {
       expectType<(scope: { foo: string; bar: number }) => VNode[]>(
-        slots.default
+        slots.default,
       )
       expectType<((scope: { data: string }) => VNode[]) | undefined>(
-        slots.optional
+        slots.optional,
       )
 
       slots.default({ foo: 'foo', bar: 1 })
@@ -1461,7 +1461,7 @@ describe('slots', () => {
       slots.optionalUndefinedScope?.('foo')
 
       expectType<typeof slots | undefined>(new comp1().$slots)
-    }
+    },
   })
 
   const comp2 = defineComponent({
@@ -1469,7 +1469,7 @@ describe('slots', () => {
       // unknown slots
       expectType<Slots>(slots)
       expectType<((...args: any[]) => VNode[]) | undefined>(slots.default)
-    }
+    },
   })
   expectType<Slots | undefined>(new comp2().$slots)
 })
@@ -1481,15 +1481,15 @@ describe('should work when props type is incompatible with setup returned type '
     props: {
       size: {
         type: String as PropType<SizeType>,
-        required: true
-      }
+        required: true,
+      },
     },
     setup(props) {
       expectType<SizeType>(props.size)
       return {
-        size: 1
+        size: 1,
       }
-    }
+    },
   })
   type CompInstance = InstanceType<typeof Comp>
 
@@ -1505,14 +1505,14 @@ describe('withKeys and withModifiers as pro', () => {
   ;<input onKeydown={onKeydown} onClick={onClick} />
 })
 
-import {
-  DefineComponent,
+import type {
+  AllowedComponentProps,
+  ComponentCustomProps,
   ComponentOptionsMixin,
+  DefineComponent,
   EmitsOptions,
+  ExtractPropTypes,
   VNodeProps,
-  AllowedComponentProps,
-  ComponentCustomProps,
-  ExtractPropTypes
 } from 'vue'
 
 // code generated by tsc / vue-tsc, make sure this continues to work
index f4f238641db9a4c001f6236a2c8378c7d2e9484b..2d48dbc1bc9ee5756501b983db12164c954322da 100644 (file)
@@ -1,26 +1,26 @@
 import {
-  defineCustomElement,
+  type VueElementConstructor,
   defineComponent,
-  type VueElementConstructor
+  defineCustomElement,
 } from 'vue'
-import { expectType, describe, test } from './utils'
+import { describe, expectType, test } from './utils'
 
 describe('inject', () => {
   // with object inject
   defineCustomElement({
     props: {
-      a: String
+      a: String,
     },
     inject: {
       foo: 'foo',
-      bar: 'bar'
+      bar: 'bar',
     },
     created() {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
       this.foobar = 1
-    }
+    },
   })
 
   // with array inject
@@ -32,7 +32,7 @@ describe('inject', () => {
       expectType<unknown>(this.bar)
       //  @ts-expect-error
       this.foobar = 1
-    }
+    },
   })
 
   // with no props
@@ -40,19 +40,19 @@ describe('inject', () => {
     inject: {
       foo: {
         from: 'pbar',
-        default: 'foo'
+        default: 'foo',
       },
       bar: {
         from: 'pfoo',
-        default: 'bar'
-      }
+        default: 'bar',
+      },
     },
     created() {
       expectType<unknown>(this.foo)
       expectType<unknown>(this.bar)
       //  @ts-expect-error
       this.foobar = 1
-    }
+    },
   })
 
   // without inject
@@ -63,7 +63,7 @@ describe('inject', () => {
       this.foo = 1
       //  @ts-expect-error
       this.bar = 1
-    }
+    },
   })
 })
 
@@ -71,11 +71,11 @@ describe('defineCustomElement using defineComponent return type', () => {
   test('with emits', () => {
     const Comp1Vue = defineComponent({
       props: {
-        a: String
+        a: String,
       },
       emits: {
-        click: () => true
-      }
+        click: () => true,
+      },
     })
     const Comp = defineCustomElement(Comp1Vue)
     expectType<VueElementConstructor>(Comp)
index a40a15ef383b52ec04c54e0f2c376f43a593ba94..3a5acc66ee9b5f2d3728988fbac3096e729c0f06 100644 (file)
@@ -1,16 +1,16 @@
-import { ExtractPropTypes, ExtractPublicPropTypes } from 'vue'
-import { expectType, Prettify } from './utils'
+import type { ExtractPropTypes, ExtractPublicPropTypes } from 'vue'
+import { type Prettify, expectType } from './utils'
 
 const propsOptions = {
   foo: {
-    default: 1
+    default: 1,
   },
   bar: {
     type: String,
-    required: true
+    required: true,
   },
   baz: Boolean,
-  qux: Array
+  qux: Array,
 } as const
 
 // internal facing props
index 22efc5849ed26cb73a1b704eb62d8ebdcdac5403..04eda68b50aa775a3257856e08ee0c434f0226dc 100644 (file)
@@ -1,4 +1,10 @@
-import { h, Text, FunctionalComponent, Component, VNode } from 'vue'
+import {
+  type Component,
+  type FunctionalComponent,
+  Text,
+  type VNode,
+  h,
+} from 'vue'
 import { expectType } from './utils'
 
 // simple function signature
@@ -33,13 +39,13 @@ const Bar: FunctionalComponent<
 
 // assigning runtime options
 Bar.props = {
-  foo: Number
+  foo: Number,
 }
 //  @ts-expect-error
 Bar.props = { foo: String }
 
 Bar.emits = {
-  update: value => value > 1
+  update: value => value > 1,
 }
 //  @ts-expect-error
 Bar.emits = { baz: () => void 0 }
index 2392c5850f11abe7f7b0b93b83e328e1f027a0a8..62e619c22bddd925b08167dfe1c6cf4a051c9d28 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  h,
-  defineComponent,
-  DefineComponent,
-  ref,
+  type Component,
+  type DefineComponent,
   Fragment,
-  Teleport,
   Suspense,
-  Component,
-  resolveComponent
+  Teleport,
+  defineComponent,
+  h,
+  ref,
+  resolveComponent,
 } from 'vue'
 import { describe, expectAssignable, expectType } from './utils'
 
@@ -36,12 +36,12 @@ describe('h inference w/ element', () => {
   h('div', {
     onClick: e => {
       expectType<MouseEvent>(e)
-    }
+    },
   })
   h('input', {
     onFocus(e) {
       expectType<FocusEvent>(e)
-    }
+    },
   })
 })
 
@@ -71,7 +71,7 @@ describe('h inference w/ Suspense', () => {
   h(Suspense, 'foo')
   h(Suspense, () => 'foo')
   h(Suspense, null, {
-    default: () => 'foo'
+    default: () => 'foo',
   })
   //  @ts-expect-error
   h(Suspense, { onResolve: 1 })
@@ -92,8 +92,8 @@ describe('h inference w/ functional component', () => {
 describe('h support w/ plain object component', () => {
   const Foo = {
     props: {
-      foo: String
-    }
+      foo: String,
+    },
   }
   h(Foo, { foo: 'ok' })
   h(Foo, { foo: 'ok', class: 'extra' })
@@ -106,9 +106,9 @@ describe('h inference w/ defineComponent', () => {
       foo: String,
       bar: {
         type: Number,
-        required: true
-      }
-    }
+        required: true,
+      },
+    },
   })
 
   h(Foo, { bar: 1 })
@@ -169,7 +169,7 @@ describe('h support for generic component type', () => {
 describe('describeComponent extends Component', () => {
   // functional
   expectAssignable<Component>(
-    defineComponent((_props: { foo?: string; bar: number }) => () => {})
+    defineComponent((_props: { foo?: string; bar: number }) => () => {}),
   )
 
   // typed props
@@ -178,8 +178,8 @@ describe('describeComponent extends Component', () => {
   // prop arrays
   expectAssignable<Component>(
     defineComponent({
-      props: ['a', 'b']
-    })
+      props: ['a', 'b'],
+    }),
   )
 
   // prop object
@@ -189,10 +189,10 @@ describe('describeComponent extends Component', () => {
         foo: String,
         bar: {
           type: Number,
-          required: true
-        }
-      }
-    })
+          required: true,
+        },
+      },
+    }),
   )
 })
 
@@ -202,9 +202,9 @@ describe('component w/ props w/ default value', () => {
     props: {
       message: {
         type: String,
-        default: 'hello'
-      }
-    }
+        default: 'hello',
+      },
+    },
   })
 
   h(MyComponent, {})
@@ -214,8 +214,8 @@ describe('component w/ props w/ default value', () => {
 describe('Boolean prop implicit false', () => {
   const MyComponent = defineComponent({
     props: {
-      visible: Boolean
-    }
+      visible: Boolean,
+    },
   })
 
   h(MyComponent, {})
@@ -224,13 +224,13 @@ describe('Boolean prop implicit false', () => {
     props: {
       visible: {
         type: Boolean,
-        required: true
-      }
-    }
+        required: true,
+      },
+    },
   })
 
   h(RequiredComponent, {
-    visible: true
+    visible: true,
   })
   // @ts-expect-error
   h(RequiredComponent, {})
@@ -240,7 +240,7 @@ describe('Boolean prop implicit false', () => {
 describe('resolveComponent should work', () => {
   h(resolveComponent('test'))
   h(resolveComponent('test'), {
-    message: '1'
+    message: '1',
   })
 })
 
@@ -249,7 +249,7 @@ describe('h should work with multiple types', () => {
   const serializers = {
     Paragraph: 'p',
     Component: {} as Component,
-    DefineComponent: {} as DefineComponent
+    DefineComponent: {} as DefineComponent,
   }
 
   const sampleComponent = serializers['' as keyof typeof serializers]
index e611f900de5b6eb7e519d6e11b683b5be6c894e4..55116f5692e24a3eea15d123f1a308d9975a3908 100644 (file)
@@ -1,4 +1,4 @@
-import { provide, inject, ref, Ref, InjectionKey } from 'vue'
+import { type InjectionKey, type Ref, inject, provide, ref } from 'vue'
 import { expectType } from './utils'
 
 // non-symbol keys
index e0d8e207f0d2ad319b557b028540800f70552abb..ec220f68198e71c8bc6eb85dc40f82ab6a512f97 100644 (file)
@@ -1,4 +1,11 @@
-import { ref, readonly, shallowReadonly, Ref, reactive, markRaw } from 'vue'
+import {
+  type Ref,
+  markRaw,
+  reactive,
+  readonly,
+  ref,
+  shallowReadonly,
+} from 'vue'
 import { describe, expectType } from './utils'
 
 describe('should support DeepReadonly', () => {
@@ -21,18 +28,18 @@ describe('should support markRaw', () => {
   }
   const test = new Test<number>()
   const plain = {
-    ref: ref(1)
+    ref: ref(1),
   }
 
   const r = reactive({
     class: {
       raw: markRaw(test),
-      reactive: test
+      reactive: test,
     },
     plain: {
       raw: markRaw(plain),
-      reactive: plain
-    }
+      reactive: plain,
+    },
   })
 
   expectType<Test<number>>(r.class.raw)
index fc3c9e65e4c8b3fbbc1630383e9bfe5318097c0d..5d4c9d95dabd476b3906fc798ef0438bb84b1271 100644 (file)
@@ -1,24 +1,24 @@
 import {
-  Ref,
-  ref,
-  shallowRef,
+  type ComputedRef,
+  type MaybeRef,
+  type MaybeRefOrGetter,
+  type Ref,
+  type ShallowRef,
+  type ToRefs,
+  computed,
   isRef,
-  unref,
-  reactive,
   proxyRefs,
+  reactive,
+  readonly,
+  ref,
+  shallowReactive,
+  shallowRef,
   toRef,
-  toValue,
   toRefs,
-  ToRefs,
-  shallowReactive,
-  readonly,
-  MaybeRef,
-  MaybeRefOrGetter,
-  ComputedRef,
-  computed,
-  ShallowRef
+  toValue,
+  unref,
 } from 'vue'
-import { expectType, describe, IsUnion, IsAny } from './utils'
+import { type IsAny, type IsUnion, describe, expectType } from './utils'
 
 function plainType(arg: number | Ref<number>) {
   // ref coercing
@@ -37,7 +37,7 @@ function plainType(arg: number | Ref<number>) {
 
   // ref inner type should be unwrapped
   const nestedRef = ref({
-    foo: ref(1)
+    foo: ref(1),
   })
   expectType<{ foo: number }>(nestedRef.value)
 
@@ -60,7 +60,7 @@ function plainType(arg: number | Ref<number>) {
 
   // with symbol
   expectType<Ref<IteratorFoo | null | undefined>>(
-    ref<IteratorFoo | null | undefined>()
+    ref<IteratorFoo | null | undefined>(),
   )
 
   // should not unwrap ref inside arrays
@@ -101,13 +101,11 @@ function bailType(arg: HTMLElement | Ref<HTMLElement>) {
   expectType<HTMLElement>(unref(arg))
 
   // ref inner type should be unwrapped
-  // eslint-disable-next-line no-restricted-globals
   const nestedRef = ref({ foo: ref(document.createElement('DIV')) })
 
   expectType<Ref<{ foo: HTMLElement }>>(nestedRef)
   expectType<{ foo: HTMLElement }>(nestedRef.value)
 }
-// eslint-disable-next-line no-restricted-globals
 const el = document.createElement('DIV')
 bailType(el)
 
@@ -127,7 +125,7 @@ function withSymbol() {
     [Symbol.toPrimitive]: new WeakMap<Ref<boolean>, string>(),
     [Symbol.toStringTag]: { weakSet: new WeakSet<Ref<boolean>>() },
     [Symbol.unscopables]: { weakMap: new WeakMap<Ref<boolean>, string>() },
-    [customSymbol]: { arr: [ref(1)] }
+    [customSymbol]: { arr: [ref(1)] },
   }
 
   const objRef = ref(obj)
@@ -144,10 +142,10 @@ function withSymbol() {
   expectType<WeakSet<Ref<boolean>>>(objRef.value[Symbol.split])
   expectType<WeakMap<Ref<boolean>, string>>(objRef.value[Symbol.toPrimitive])
   expectType<{ weakSet: WeakSet<Ref<boolean>> }>(
-    objRef.value[Symbol.toStringTag]
+    objRef.value[Symbol.toStringTag],
   )
   expectType<{ weakMap: WeakMap<Ref<boolean>, string> }>(
-    objRef.value[Symbol.unscopables]
+    objRef.value[Symbol.unscopables],
   )
   expectType<{ arr: Ref<number>[] }>(objRef.value[customSymbol])
 }
@@ -157,8 +155,8 @@ withSymbol()
 const state = reactive({
   foo: {
     value: 1,
-    label: 'bar'
-  }
+    label: 'bar',
+  },
 })
 
 expectType<string>(state.foo.label)
@@ -227,16 +225,16 @@ describe('shallowRef with generic', <T extends { name: string }>() => {
 {
   // should return ShallowRef<T> | Ref<T>, not ShallowRef<T | Ref<T>>
   expectType<ShallowRef<{ name: string }> | Ref<{ name: string }>>(
-    shallowRef({} as MaybeRef<{ name: string }>)
+    shallowRef({} as MaybeRef<{ name: string }>),
   )
   expectType<ShallowRef<number> | Ref<string[]> | ShallowRef<string>>(
-    shallowRef('' as Ref<string[]> | string | number)
+    shallowRef('' as Ref<string[]> | string | number),
   )
 }
 
 // proxyRefs: should return `reactive` directly
 const r1 = reactive({
-  k: 'v'
+  k: 'v',
 })
 const p1 = proxyRefs(r1)
 expectType<typeof r1>(p1)
@@ -247,9 +245,9 @@ const r2 = {
   c: computed(() => 1),
   u: undefined,
   obj: {
-    k: ref('foo')
+    k: ref('foo'),
   },
-  union: Math.random() > 0 - 5 ? ref({ name: 'yo' }) : null
+  union: Math.random() > 0 - 5 ? ref({ name: 'yo' }) : null,
 }
 const p2 = proxyRefs(r2)
 expectType<number>(p2.a)
@@ -267,7 +265,7 @@ expectType<{ name: string } | null>(p2.union)
   } = {
     a: 1,
     b: ref(1),
-    c: 1
+    c: 1,
   }
 
   // toRef
@@ -294,8 +292,8 @@ expectType<{ name: string } | null>(p2.union)
   // Both should not do any unwrapping
   const someReactive = shallowReactive({
     a: {
-      b: ref(42)
-    }
+      b: ref(42),
+    },
   })
 
   const toRefResult = toRef(someReactive, 'a')
@@ -327,8 +325,8 @@ interface AppData {
 
 const data: ToRefs<AppData> = toRefs(
   reactive({
-    state: 'state1'
-  })
+    state: 'state1',
+  }),
 )
 
 switch (data.state.value) {
@@ -355,9 +353,9 @@ describe('shallow reactive in reactive', () => {
   const baz = reactive({
     foo: shallowReactive({
       a: {
-        b: ref(42)
-      }
-    })
+        b: ref(42),
+      },
+    }),
   })
 
   const foo = toRef(baz, 'foo')
@@ -372,10 +370,10 @@ describe('shallow ref in reactive', () => {
       bar: {
         baz: ref(123),
         qux: reactive({
-          z: ref(123)
-        })
-      }
-    })
+          z: ref(123),
+        }),
+      },
+    }),
   })
 
   expectType<Ref<number>>(x.foo.bar.baz)
@@ -384,7 +382,7 @@ describe('shallow ref in reactive', () => {
 
 describe('ref in shallow ref', () => {
   const x = shallowRef({
-    a: ref(123)
+    a: ref(123),
   })
 
   expectType<Ref<number>>(x.value.a)
@@ -393,8 +391,8 @@ describe('ref in shallow ref', () => {
 describe('reactive in shallow ref', () => {
   const x = shallowRef({
     a: reactive({
-      b: ref(0)
-    })
+      b: ref(0),
+    }),
   })
 
   expectType<number>(x.value.a.b)
@@ -405,7 +403,7 @@ describe('toRef <-> toValue', () => {
     a: MaybeRef<string>,
     b: () => string,
     c: MaybeRefOrGetter<string>,
-    d: ComputedRef<string>
+    d: ComputedRef<string>,
   ) {
     const r = toRef(a)
     expectType<Ref<string>>(r)
@@ -436,7 +434,7 @@ describe('toRef <-> toValue', () => {
       r: toValue(r),
       rb: toValue(rb),
       rc: toValue(rc),
-      rd: toValue(rd)
+      rd: toValue(rd),
     }
   }
 
@@ -450,7 +448,7 @@ describe('toRef <-> toValue', () => {
       'foo',
       () => 'bar',
       ref('baz'),
-      computed(() => 'hi')
-    )
+      computed(() => 'hi'),
+    ),
   )
 })
index 0e06e849b22199a82d94430b1de59fe27e12c8b6..7f67c62943d106b2ad44d381a213e3132665dfcb 100644 (file)
@@ -1,15 +1,15 @@
 import {
-  defineProps,
+  type Ref,
+  type Slots,
+  type VNode,
   defineEmits,
+  defineModel,
+  defineProps,
+  defineSlots,
+  toRefs,
   useAttrs,
   useSlots,
   withDefaults,
-  Slots,
-  defineSlots,
-  VNode,
-  Ref,
-  defineModel,
-  toRefs
 } from 'vue'
 import { describe, expectType } from './utils'
 import { defineComponent } from 'vue'
@@ -63,8 +63,8 @@ describe('defineProps w/ type declaration + withDefaults', () => {
       fn: () => {},
       genStr: () => '',
       y: undefined,
-      z: 'string'
-    }
+      z: 'string',
+    },
   )
 
   res.number + 1
@@ -97,8 +97,8 @@ describe('defineProps w/ union type declaration + withDefaults', () => {
       union1: 123,
       union2: () => [123],
       union3: () => ({ x: 123 }),
-      union4: () => 123
-    }
+      union4: () => 123,
+    },
   )
 })
 
@@ -124,8 +124,8 @@ describe('defineProps w/ generic type declaration + withDefaults', <T extends
       generic2: () => ({ x: 123 }) as { x: T },
 
       generic3: () => 'test' as TString,
-      generic4: () => ({ a: 'test' }) as TA
-    }
+      generic4: () => ({ a: 'test' }) as TA,
+    },
   )
 
   res.n + 1
@@ -147,7 +147,7 @@ describe('withDefaults w/ boolean type', () => {
     defineProps<{
       bool?: boolean
     }>(),
-    { bool: false }
+    { bool: false },
   )
   expectType<boolean>(res1.bool)
 
@@ -156,8 +156,8 @@ describe('withDefaults w/ boolean type', () => {
       bool?: boolean
     }>(),
     {
-      bool: undefined
-    }
+      bool: undefined,
+    },
   )
   expectType<boolean | undefined>(res2.bool)
 })
@@ -168,12 +168,12 @@ describe('defineProps w/ runtime declaration', () => {
     foo: String,
     bar: {
       type: Number,
-      default: 1
+      default: 1,
     },
     baz: {
       type: Array,
-      required: true
-    }
+      required: true,
+    },
   })
   expectType<{
     foo?: string
@@ -233,7 +233,7 @@ describe('defineEmits w/ alt type declaration', () => {
 describe('defineEmits w/ runtime declaration', () => {
   const emit = defineEmits({
     foo: () => {},
-    bar: null
+    bar: null,
   })
   emit('foo')
   emit('bar', 123)
@@ -275,7 +275,7 @@ describe('defineSlots generic', <T extends Record<string, any>>() => {
 
   for (const key of Object.keys(props.item) as (keyof T & string)[]) {
     slots[`slot-${String(key)}`]?.({
-      item: props.item
+      item: props.item,
     })
   }
   slots.label?.({ item: props.item })
@@ -329,20 +329,20 @@ describe('useModel', () => {
 
       // @ts-expect-error
       useModel(props, 'bar')
-    }
+    },
   })
 
   defineComponent({
     props: {
       foo: String,
       bar: { type: Number, required: true },
-      baz: { type: Boolean }
+      baz: { type: Boolean },
     },
     setup(props) {
       expectType<Ref<string | undefined>>(useModel(props, 'foo'))
       expectType<Ref<number>>(useModel(props, 'bar'))
       expectType<Ref<boolean>>(useModel(props, 'baz'))
-    }
+    },
   })
 })
 
@@ -374,20 +374,20 @@ describe('defineSlots generic', <T extends Record<string, any>>() => {
 
   // @ts-expect-error non existing slot
   slots['foo-asdas']?.({
-    item: props.item
+    item: props.item,
   })
   for (const key in props.item) {
     slots[`slot-${String(key)}`]?.({
-      item: props.item
+      item: props.item,
     })
     slots[`slot-${String(key as keyof T)}`]?.({
-      item: props.item
+      item: props.item,
     })
   }
 
   for (const key of Object.keys(props.item) as (keyof T)[]) {
     slots[`slot-${String(key)}`]?.({
-      item: props.item
+      item: props.item,
     })
   }
   slots.label?.({ item: props.item })
index 5e171e1f75f744151e7f83c8cb6792d8598b84c7..9b09b3fda82968fc53b6ee90bbb24a4335b5006f 100644 (file)
@@ -1,5 +1,5 @@
 // TSX w/ defineComponent is tested in defineComponent.test-d.tsx
-import { KeepAlive, Suspense, Fragment, Teleport, VNode } from 'vue'
+import { Fragment, KeepAlive, Suspense, Teleport, type VNode } from 'vue'
 import { expectType } from './utils'
 
 expectType<VNode>(<div />)
@@ -14,7 +14,7 @@ expectType<JSX.Element>(<input value="foo" />)
 // allow array styles and nested array styles
 expectType<JSX.Element>(<div style={[{ color: 'red' }]} />)
 expectType<JSX.Element>(
-  <div style={[{ color: 'red' }, [{ fontSize: '1em' }]]} />
+  <div style={[{ color: 'red' }, [{ fontSize: '1em' }]]} />,
 )
 
 // allow undefined, string, object, array and nested array classes
@@ -26,7 +26,7 @@ expectType<JSX.Element>(<div class={['foo', ['bar'], [['baz']]]} />)
 expectType<JSX.Element>(<div class={{ foo: true, bar: false, baz: true }} />)
 expectType<JSX.Element>(<div class={{}} />)
 expectType<JSX.Element>(
-  <div class={['foo', ['bar'], { baz: true }, [{ qux: true }]]} />
+  <div class={['foo', ['bar'], { baz: true }, [{ qux: true }]]} />,
 )
 expectType<JSX.Element>(
   <div
@@ -37,9 +37,9 @@ expectType<JSX.Element>(
       { qux: '' },
       { quux: null },
       { corge: undefined },
-      { grault: NaN }
+      { grault: NaN },
     ]}
-  />
+  />,
 )
 expectType<JSX.Element>(
   <div
@@ -48,9 +48,9 @@ expectType<JSX.Element>(
       { bar: 'not-empty' },
       { baz: 1 },
       { qux: {} },
-      { quux: [] }
+      { quux: [] },
     ]}
-  />
+  />,
 )
 
 // #7955
@@ -83,7 +83,7 @@ expectType<JSX.Element>(
       // infer correct event type
       expectType<EventTarget | null>(e.target)
     }}
-  />
+  />,
 )
 
 // built-in types
@@ -108,7 +108,7 @@ expectType<JSX.Element>(<KeepAlive key="1" />)
 expectType<JSX.Element>(<Suspense />)
 expectType<JSX.Element>(<Suspense key="1" />)
 expectType<JSX.Element>(
-  <Suspense onResolve={() => {}} onFallback={() => {}} onPending={() => {}} />
+  <Suspense onResolve={() => {}} onFallback={() => {}} onPending={() => {}} />,
 )
 // @ts-expect-error
 ;<Suspense onResolve={123} />
@@ -118,5 +118,5 @@ expectType<JSX.Element>(
   <svg
     xmlnsXlink="http://www.w3.org/1999/xlink"
     xmlns="http://www.w3.org/2000/svg"
-  />
+  />,
 )
index cc631d37acbda0540e2abbbf0ae4b8d17c0d2cea..323716d8a05c06caf919338dd8e9b0a14c195426 100644 (file)
@@ -1,4 +1,4 @@
-import { ref, computed, watch, defineComponent, shallowRef } from 'vue'
+import { computed, defineComponent, ref, shallowRef, watch } from 'vue'
 import { expectType } from './utils'
 
 const source = ref('foo')
@@ -29,7 +29,7 @@ watch(
     expectType<string>(value)
     expectType<string | undefined>(oldValue)
   },
-  { immediate: true }
+  { immediate: true },
 )
 
 watch(
@@ -37,10 +37,10 @@ watch(
   (values, oldValues) => {
     expectType<[string, string, number]>(values)
     expectType<[string | undefined, string | undefined, number | undefined]>(
-      oldValues
+      oldValues,
     )
   },
-  { immediate: true }
+  { immediate: true },
 )
 
 // const array
@@ -52,12 +52,12 @@ watch(
       Readonly<[string | undefined, string | undefined, number | undefined]>
     >(oldValues)
   },
-  { immediate: true }
+  { immediate: true },
 )
 
 // should provide correct ref.value inner type to callbacks
 const nestedRefSource = ref({
-  foo: ref(1)
+  foo: ref(1),
 })
 
 watch(nestedRefSource, (v, ov) => {
@@ -88,9 +88,9 @@ defineComponent({
       (v, ov) => {
         expectType<number>(v)
         expectType<number>(ov)
-      }
+      },
     )
-  }
+  },
 })
 
 {
index 65f36d34775984aedd587c71e1397c6dbc31814b..1367b69cd5b014f25c6b9eca280355b56b0c023c 100644 (file)
@@ -41,7 +41,7 @@ declare module 'estree-walker' {
       enter?: (node: T, parent: T | undefined) => any
       leave?: (node: T, parent: T | undefined) => any
       exit?: (node: T) => any
-    } & ThisType<{ skip: () => void }>
+    } & ThisType<{ skip: () => void }>,
   )
 }
 
index 0cbe10fc201457834b004358b91f3962977a748c..a0de8feaf33c2cc6c20fe007512b8af2ecf199c3 100644 (file)
@@ -1,4 +1,4 @@
-import { reactive, effect, toRaw, isReactive } from '../../src'
+import { effect, isReactive, reactive, toRaw } from '../../src'
 
 describe('reactivity/collections', () => {
   function coverCollectionFn(collection: Map<any, any>, fnName: string) {
@@ -69,7 +69,6 @@ describe('reactivity/collections', () => {
       const map = reactive(new Map())
       effect(() => {
         dummy = 0
-        // eslint-disable-next-line no-unused-vars
         for (let [key, num] of map) {
           key
           dummy += num
@@ -164,7 +163,6 @@ describe('reactivity/collections', () => {
       effect(() => {
         dummy = ''
         dummy2 = 0
-        // eslint-disable-next-line no-unused-vars
         for (let [key, num] of map.entries()) {
           dummy += key
           dummy2 += num
@@ -411,7 +409,7 @@ describe('reactivity/collections', () => {
       const map = reactive(raw)
       map.set(key, 2)
       expect(
-        `Reactive Map contains both the raw and reactive`
+        `Reactive Map contains both the raw and reactive`,
       ).toHaveBeenWarned()
     })
 
index ae74eb476acd65ce1581682284c8cccadd32e75f..2aeef198256b6920bfc94e006e615de71c9c0222 100644 (file)
@@ -1,4 +1,4 @@
-import { reactive, effect, isReactive, toRaw } from '../../src'
+import { effect, isReactive, reactive, toRaw } from '../../src'
 
 describe('reactivity/collections', () => {
   function coverCollectionFn(collection: Set<any>, fnName: string) {
@@ -125,7 +125,6 @@ describe('reactivity/collections', () => {
       const set = reactive(new Set<number>())
       effect(() => {
         dummy = 0
-        // eslint-disable-next-line no-unused-vars
         for (let [key, num] of set.entries()) {
           key
           dummy += num
@@ -413,7 +412,7 @@ describe('reactivity/collections', () => {
       const set = reactive(raw)
       set.delete(key)
       expect(
-        `Reactive Set contains both the raw and reactive`
+        `Reactive Set contains both the raw and reactive`,
       ).toHaveBeenWarned()
     })
 
index d7657a9f94ce9f2ef6a239a2daf9dd58e1b31f3f..757808a43f8964ea8f9c0f397d5c50b953cffb3f 100644 (file)
@@ -1,4 +1,4 @@
-import { reactive, effect, toRaw, isReactive } from '../../src'
+import { effect, isReactive, reactive, toRaw } from '../../src'
 
 describe('reactivity/collections', () => {
   describe('WeakMap', () => {
index 9ec30019756f19b7dbbd1e21abbb6dc371e66386..c9a4b68aaa68f9f1614c96d29323601c40bd4550 100644 (file)
@@ -1,4 +1,4 @@
-import { reactive, isReactive, effect, toRaw } from '../../src'
+import { effect, isReactive, reactive, toRaw } from '../../src'
 
 describe('reactivity/collections', () => {
   describe('WeakSet', () => {
index 11eb002fc888fa9092c6323e05f318592cb165af..2f13ea653fb589daf339fac59e17c1f521ffe010 100644 (file)
@@ -14,7 +14,7 @@ describe('reactivity/collections', () => {
 
         sroMap.set(key, {} as any)
         expect(
-          `Set operation on key "[object Object]" failed: target is readonly.`
+          `Set operation on key "[object Object]" failed: target is readonly.`,
         ).toHaveBeenWarned()
       })
 
@@ -28,7 +28,7 @@ describe('reactivity/collections', () => {
 
         sroMap.get(key)!.foo = 2
         expect(
-          `Set operation on key "foo" failed: target is readonly.`
+          `Set operation on key "foo" failed: target is readonly.`,
         ).not.toHaveBeenWarned()
       })
     })
@@ -48,7 +48,7 @@ describe('reactivity/collections', () => {
 
       values1[0].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
 
       expect(isReadonly(values2[0][1])).toBe(false)
@@ -57,7 +57,7 @@ describe('reactivity/collections', () => {
 
       values2[0][1].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
     })
 
@@ -73,7 +73,7 @@ describe('reactivity/collections', () => {
 
         val.foo = 2
         expect(
-          `Set operation on key "foo" failed: target is readonly.`
+          `Set operation on key "foo" failed: target is readonly.`,
         ).not.toHaveBeenWarned()
       })
     })
@@ -91,7 +91,7 @@ describe('reactivity/collections', () => {
 
         sroSet.add({} as any)
         expect(
-          `Add operation on key "[object Object]" failed: target is readonly.`
+          `Add operation on key "[object Object]" failed: target is readonly.`,
         ).toHaveBeenWarned()
       })
     })
@@ -109,12 +109,12 @@ describe('reactivity/collections', () => {
 
       sroSet.add({} as any)
       expect(
-        `Add operation on key "[object Object]" failed: target is readonly.`
+        `Add operation on key "[object Object]" failed: target is readonly.`,
       ).toHaveBeenWarned()
 
       values[0].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
     })
 
@@ -132,7 +132,7 @@ describe('reactivity/collections', () => {
 
       values1[0].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
 
       expect(isReadonly(values2[0][1])).toBe(false)
@@ -141,7 +141,7 @@ describe('reactivity/collections', () => {
 
       values2[0][1].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
     })
 
@@ -157,7 +157,7 @@ describe('reactivity/collections', () => {
 
         val.foo = 2
         expect(
-          `Set operation on key "foo" failed: target is readonly.`
+          `Set operation on key "foo" failed: target is readonly.`,
         ).not.toHaveBeenWarned()
       })
     })
index 73c20acdfad72525aef31e6f72b6278f7a1a5722..0ffa288ff1ee8722901d8005189d74a5d4f653d9 100644 (file)
@@ -1,5 +1,5 @@
-import { describe, bench } from 'vitest'
-import { ComputedRef, Ref, computed, ref } from '../src/index'
+import { bench, describe } from 'vitest'
+import { type ComputedRef, type Ref, computed, ref } from '../src/index'
 
 describe('computed', () => {
   bench('create computed', () => {
index d9b8f888cafea0ee3311172a8ef08132b1c263b0..f66935d4c8d29af78bb864406b4c73e648fc0cd3 100644 (file)
@@ -1,15 +1,15 @@
 import {
+  type DebuggerEvent,
+  ITERATE_KEY,
+  TrackOpTypes,
+  TriggerOpTypes,
+  type WritableComputedRef,
   computed,
-  reactive,
   effect,
-  ref,
-  WritableComputedRef,
   isReadonly,
-  DebuggerEvent,
+  reactive,
+  ref,
   toRaw,
-  TrackOpTypes,
-  ITERATE_KEY,
-  TriggerOpTypes
 } from '../src'
 
 describe('reactivity/computed', () => {
@@ -140,7 +140,7 @@ describe('reactivity/computed', () => {
       get: () => n.value + 1,
       set: val => {
         n.value = val - 1
-      }
+      },
     })
 
     expect(plusOne.value).toBe(2)
@@ -157,7 +157,7 @@ describe('reactivity/computed', () => {
       get: () => n.value + 1,
       set: val => {
         n.value = val - 1
-      }
+      },
     })
 
     let dummy
@@ -193,7 +193,7 @@ describe('reactivity/computed', () => {
     ;(plusOne as WritableComputedRef<number>).value++ // Type cast to prevent TS from preventing the error
 
     expect(
-      'Write operation failed: computed value is readonly'
+      'Write operation failed: computed value is readonly',
     ).toHaveBeenWarnedLast()
   })
 
@@ -209,7 +209,7 @@ describe('reactivity/computed', () => {
       },
       set(v) {
         a = v
-      }
+      },
     })
     expect(isReadonly(z)).toBe(false)
     expect(isReadonly(z.value.a)).toBe(false)
@@ -228,7 +228,7 @@ describe('reactivity/computed', () => {
     })
     const obj = reactive({ foo: 1, bar: 2 })
     const c = computed(() => (obj.foo, 'bar' in obj, Object.keys(obj)), {
-      onTrack
+      onTrack,
     })
     expect(c.value).toEqual(['foo', 'bar'])
     expect(onTrack).toHaveBeenCalledTimes(3)
@@ -237,20 +237,20 @@ describe('reactivity/computed', () => {
         effect: c.effect,
         target: toRaw(obj),
         type: TrackOpTypes.GET,
-        key: 'foo'
+        key: 'foo',
       },
       {
         effect: c.effect,
         target: toRaw(obj),
         type: TrackOpTypes.HAS,
-        key: 'bar'
+        key: 'bar',
       },
       {
         effect: c.effect,
         target: toRaw(obj),
         type: TrackOpTypes.ITERATE,
-        key: ITERATE_KEY
-      }
+        key: ITERATE_KEY,
+      },
     ])
   })
 
@@ -274,7 +274,7 @@ describe('reactivity/computed', () => {
       type: TriggerOpTypes.SET,
       key: 'foo',
       oldValue: 1,
-      newValue: 2
+      newValue: 2,
     })
 
     delete obj.foo
@@ -285,7 +285,7 @@ describe('reactivity/computed', () => {
       target: toRaw(obj),
       type: TriggerOpTypes.DELETE,
       key: 'foo',
-      oldValue: 2
+      oldValue: 2,
     })
   })
 
@@ -294,7 +294,7 @@ describe('reactivity/computed', () => {
     const cSpy = vi.fn()
 
     const a = ref<null | { v: number }>({
-      v: 1
+      v: 1,
     })
     const b = computed(() => {
       return a.value
index 2ebb2edea8a7dde2106876ef363366a4c32d048b..9109177bf49a437abc824205e04738c53dd9f0bb 100644 (file)
@@ -1,15 +1,15 @@
 import {
-  reactive,
-  effect,
-  stop,
-  toRaw,
+  type DebuggerEvent,
+  type ReactiveEffectRunner,
   TrackOpTypes,
   TriggerOpTypes,
-  DebuggerEvent,
+  effect,
   markRaw,
-  shallowReactive,
+  reactive,
   readonly,
-  ReactiveEffectRunner
+  shallowReactive,
+  stop,
+  toRaw,
 } from '../src/index'
 import { pauseScheduling, resetScheduling } from '../src/effect'
 import { ITERATE_KEY, getDepFromReactive } from '../src/reactiveEffect'
@@ -129,7 +129,7 @@ describe('reactivity/effect', () => {
       },
       get prop() {
         return hiddenValue
-      }
+      },
     })
     Object.setPrototypeOf(obj, parent)
     effect(() => (dummy = obj.prop))
@@ -277,7 +277,7 @@ describe('reactivity/effect', () => {
       a: 1,
       get b() {
         return this.a
-      }
+      },
     })
 
     let dummy
@@ -292,7 +292,7 @@ describe('reactivity/effect', () => {
       a: 1,
       b() {
         return this.a
-      }
+      },
     })
 
     let dummy
@@ -349,7 +349,7 @@ describe('reactivity/effect', () => {
       },
       get prop() {
         return hiddenValue
-      }
+      },
     })
     Object.setPrototypeOf(obj, parent)
     effect(() => (dummy = obj.prop))
@@ -712,7 +712,7 @@ describe('reactivity/effect', () => {
       () => {
         dummy = obj.foo
       },
-      { scheduler }
+      { scheduler },
     )
     expect(scheduler).not.toHaveBeenCalled()
     expect(dummy).toBe(1)
@@ -740,7 +740,7 @@ describe('reactivity/effect', () => {
         dummy = 'bar' in obj
         dummy = Object.keys(obj)
       },
-      { onTrack }
+      { onTrack },
     )
     expect(dummy).toEqual(['foo', 'bar'])
     expect(onTrack).toHaveBeenCalledTimes(3)
@@ -749,20 +749,20 @@ describe('reactivity/effect', () => {
         effect: runner.effect,
         target: toRaw(obj),
         type: TrackOpTypes.GET,
-        key: 'foo'
+        key: 'foo',
       },
       {
         effect: runner.effect,
         target: toRaw(obj),
         type: TrackOpTypes.HAS,
-        key: 'bar'
+        key: 'bar',
       },
       {
         effect: runner.effect,
         target: toRaw(obj),
         type: TrackOpTypes.ITERATE,
-        key: ITERATE_KEY
-      }
+        key: ITERATE_KEY,
+      },
     ])
   })
 
@@ -777,7 +777,7 @@ describe('reactivity/effect', () => {
       () => {
         dummy = obj.foo
       },
-      { onTrigger }
+      { onTrigger },
     )
 
     obj.foo!++
@@ -789,7 +789,7 @@ describe('reactivity/effect', () => {
       type: TriggerOpTypes.SET,
       key: 'foo',
       oldValue: 1,
-      newValue: 2
+      newValue: 2,
     })
 
     delete obj.foo
@@ -800,7 +800,7 @@ describe('reactivity/effect', () => {
       target: toRaw(obj),
       type: TriggerOpTypes.DELETE,
       key: 'foo',
-      oldValue: 2
+      oldValue: 2,
     })
   })
 
@@ -824,7 +824,7 @@ describe('reactivity/effect', () => {
   it('events: onStop', () => {
     const onStop = vi.fn()
     const runner = effect(() => {}, {
-      onStop
+      onStop,
     })
 
     stop(runner)
@@ -856,8 +856,8 @@ describe('reactivity/effect', () => {
   it('markRaw', () => {
     const obj = reactive({
       foo: markRaw({
-        prop: 0
-      })
+        prop: 0,
+      }),
     })
     let dummy
     effect(() => {
@@ -872,7 +872,7 @@ describe('reactivity/effect', () => {
 
   it('should not be triggered when the value and the old value both are NaN', () => {
     const obj = reactive({
-      foo: NaN
+      foo: NaN,
     })
     const fnSpy = vi.fn(() => obj.foo)
     effect(fnSpy)
@@ -1058,7 +1058,7 @@ describe('reactivity/effect', () => {
       const obj = reactive<{ a: number; b: number; c: 'a' | 'b' }>({
         a: 1,
         b: 2,
-        c: 'a'
+        c: 'a',
       })
       expect(getDepFromReactive(toRaw(obj), 'prop')).toBeUndefined()
       effect(() => obj[obj.c])
index b26a90a09db01a02c00ca5cdf38e3d0896f5a64b..f7e3241ccd6923280bbd2a89b3653784e91dde7c 100644 (file)
@@ -1,13 +1,13 @@
 import { nextTick, watch, watchEffect } from '@vue/runtime-core'
 import {
-  reactive,
-  effect,
+  type ComputedRef,
   EffectScope,
-  onScopeDispose,
   computed,
+  effect,
+  getCurrentScope,
+  onScopeDispose,
+  reactive,
   ref,
-  ComputedRef,
-  getCurrentScope
 } from '../src'
 
 describe('reactivity/effect/scope', () => {
@@ -213,7 +213,7 @@ describe('reactivity/effect/scope', () => {
     onScopeDispose(spy)
 
     expect(
-      '[Vue warn] onScopeDispose() is called when there is no active effect scope to be associated with.'
+      '[Vue warn] onScopeDispose() is called when there is no active effect scope to be associated with.',
     ).toHaveBeenWarned()
 
     scope.stop()
index 7676a0e12d0b7b10725ae505f35b12f4d719811a..953765dd1d9c69b1ab283d075238b2534ce192df 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  ComputedRef,
+  type ComputedRef,
   computed,
   effect,
   reactive,
   shallowRef as ref,
-  toRaw
+  toRaw,
 } from '../src/index'
 import { getDepFromReactive } from '../src/reactiveEffect'
 
index 1ea1ba4a901732f9127a5ec2b8baf50842a84623..5e1e0922e50481408ae77e5d73916ee865393d5b 100644 (file)
@@ -1,5 +1,5 @@
-import { ref, isRef } from '../src/ref'
-import { reactive, isReactive, toRaw, markRaw } from '../src/reactive'
+import { isRef, ref } from '../src/ref'
+import { isReactive, markRaw, reactive, toRaw } from '../src/reactive'
 import { computed } from '../src/computed'
 import { effect } from '../src/effect'
 
@@ -35,9 +35,9 @@ describe('reactivity/reactive', () => {
   test('nested reactives', () => {
     const original = {
       nested: {
-        foo: 1
+        foo: 1,
       },
-      array: [{ bar: 2 }]
+      array: [{ bar: 2 }],
     }
     const observed = reactive(original)
     expect(isReactive(observed.nested)).toBe(true)
@@ -209,7 +209,7 @@ describe('reactivity/reactive', () => {
     // writable
     const b = computed({
       get: () => 1,
-      set: () => {}
+      set: () => {},
     })
     const obj = reactive({ a, b })
     // check type
@@ -238,7 +238,7 @@ describe('reactivity/reactive', () => {
     const assertValue = (value: any) => {
       reactive(value)
       expect(
-        `value cannot be made reactive: ${String(value)}`
+        `value cannot be made reactive: ${String(value)}`,
       ).toHaveBeenWarnedLast()
     }
 
@@ -271,7 +271,7 @@ describe('reactivity/reactive', () => {
   test('markRaw', () => {
     const obj = reactive({
       foo: { a: 1 },
-      bar: markRaw({ b: 2 })
+      bar: markRaw({ b: 2 }),
     })
     expect(isReactive(obj.foo)).toBe(true)
     expect(isReactive(obj.bar)).toBe(false)
@@ -282,7 +282,7 @@ describe('reactivity/reactive', () => {
       foo: Object.preventExtensions({ a: 1 }),
       // sealed or frozen objects are considered non-extensible as well
       bar: Object.freeze({ a: 1 }),
-      baz: Object.seal({ a: 1 })
+      baz: Object.seal({ a: 1 }),
     })
     expect(isReactive(obj.foo)).toBe(false)
     expect(isReactive(obj.bar)).toBe(false)
@@ -292,7 +292,7 @@ describe('reactivity/reactive', () => {
   test('should not observe objects with __v_skip', () => {
     const original = {
       foo: 1,
-      __v_skip: true
+      __v_skip: true,
     }
     const observed = reactive(original)
     expect(isReactive(observed)).toBe(false)
index 596b9f1a33e0fa40c6649dece0a788b8240f6122..9ce0dc531d15f738a1b3c767ded8d3045cf3d11d 100644 (file)
@@ -35,7 +35,7 @@ for (let amount = 1e1; amount < 1e4; amount *= 10) {
       () => {
         r[0]++
         c.value
-      }
+      },
     )
   }
 
index 7eb800b80bbc6999d98b539cb64513cb22bfb6a0..1c6fcefd592112bf4e55b73c54f99eecf3622105 100644 (file)
@@ -1,5 +1,5 @@
-import { reactive, isReactive, toRaw } from '../src/reactive'
-import { ref, isRef } from '../src/ref'
+import { isReactive, reactive, toRaw } from '../src/reactive'
+import { isRef, ref } from '../src/ref'
 import { effect } from '../src/effect'
 
 describe('reactivity/reactive/Array', () => {
index 579904bafe707a7e993c97b55a27e7cfd871fa4d..70a034e96c38508a22778f4d45f575b079d55d35 100644 (file)
@@ -1,5 +1,5 @@
 import { bench } from 'vitest'
-import { reactive, computed, ComputedRef } from '../src'
+import { type ComputedRef, computed, reactive } from '../src'
 
 function createMap(obj: Record<string, any>) {
   const map = new Map()
index 43af8a96c51498e0c2abef0be9c1f725834acf51..71632283f69a630e50963b90bdbe3694b9a4d964 100644 (file)
@@ -1,5 +1,5 @@
 import { bench } from 'vitest'
-import { ComputedRef, computed, reactive } from '../src'
+import { type ComputedRef, computed, reactive } from '../src'
 
 bench('create reactive obj', () => {
   reactive({ a: 1 })
index 448419d31766d81e8441f422c2ac207038150d87..66da71a8c9e3bb4c226d166b5df2281d348ef5f9 100644 (file)
@@ -1,14 +1,14 @@
 import {
-  reactive,
-  readonly,
-  toRaw,
+  computed,
+  effect,
+  isProxy,
   isReactive,
   isReadonly,
   markRaw,
-  effect,
+  reactive,
+  readonly,
   ref,
-  isProxy,
-  computed
+  toRaw,
 } from '../src'
 
 /**
@@ -44,49 +44,49 @@ describe('reactivity/readonly', () => {
       const original = {
         foo: 1,
         bar: {
-          baz: 2
+          baz: 2,
         },
-        [qux]: 3
+        [qux]: 3,
       }
       const wrapped: Writable<typeof original> = readonly(original)
 
       wrapped.foo = 2
       expect(wrapped.foo).toBe(1)
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
 
       wrapped.bar.baz = 3
       expect(wrapped.bar.baz).toBe(2)
       expect(
-        `Set operation on key "baz" failed: target is readonly.`
+        `Set operation on key "baz" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
 
       wrapped[qux] = 4
       expect(wrapped[qux]).toBe(3)
       expect(
-        `Set operation on key "Symbol(qux)" failed: target is readonly.`
+        `Set operation on key "Symbol(qux)" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
 
       // @ts-expect-error
       delete wrapped.foo
       expect(wrapped.foo).toBe(1)
       expect(
-        `Delete operation on key "foo" failed: target is readonly.`
+        `Delete operation on key "foo" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
 
       // @ts-expect-error
       delete wrapped.bar.baz
       expect(wrapped.bar.baz).toBe(2)
       expect(
-        `Delete operation on key "baz" failed: target is readonly.`
+        `Delete operation on key "baz" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
 
       // @ts-expect-error
       delete wrapped[qux]
       expect(wrapped[qux]).toBe(3)
       expect(
-        `Delete operation on key "Symbol(qux)" failed: target is readonly.`
+        `Delete operation on key "Symbol(qux)" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
     })
 
@@ -131,12 +131,12 @@ describe('reactivity/readonly', () => {
       wrapped[0] = 1
       expect(wrapped[0]).not.toBe(1)
       expect(
-        `Set operation on key "0" failed: target is readonly.`
+        `Set operation on key "0" failed: target is readonly.`,
       ).toHaveBeenWarned()
       wrapped[0].foo = 2
       expect(wrapped[0].foo).toBe(1)
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).toHaveBeenWarned()
 
       // should block length mutation
@@ -144,7 +144,7 @@ describe('reactivity/readonly', () => {
       expect(wrapped.length).toBe(1)
       expect(wrapped[0].foo).toBe(1)
       expect(
-        `Set operation on key "length" failed: target is readonly.`
+        `Set operation on key "length" failed: target is readonly.`,
       ).toHaveBeenWarned()
 
       // mutation methods invoke set/length internally and thus are blocked as well
@@ -180,7 +180,7 @@ describe('reactivity/readonly', () => {
         const key2 = {}
         const original = new Collection([
           [key1, {}],
-          [key2, {}]
+          [key2, {}],
         ])
         const wrapped = readonly(original)
         expect(wrapped).not.toBe(original)
@@ -207,7 +207,7 @@ describe('reactivity/readonly', () => {
         expect(dummy).toBeUndefined()
         expect(map.has(key)).toBe(false)
         expect(
-          `Set operation on key "${key}" failed: target is readonly.`
+          `Set operation on key "${key}" failed: target is readonly.`,
         ).toHaveBeenWarned()
       })
 
@@ -233,7 +233,7 @@ describe('reactivity/readonly', () => {
           const key2 = {}
           const original = new Map([
             [key1, {}],
-            [key2, {}]
+            [key2, {}],
           ])
           const wrapped: any = readonly(original)
           expect(wrapped.size).toBe(2)
@@ -255,8 +255,8 @@ describe('reactivity/readonly', () => {
           const original = reactive(
             new Map([
               [key1, {}],
-              [key2, {}]
-            ])
+              [key2, {}],
+            ]),
           )
           const wrapped: any = readonly(original)
           expect(wrapped.size).toBe(2)
@@ -280,7 +280,7 @@ describe('reactivity/readonly', () => {
           const wrapped = readonly(new Collection())
           expect(wrapped.clear()).toBeUndefined()
           expect(
-            `Clear operation failed: target is readonly.`
+            `Clear operation failed: target is readonly.`,
           ).toHaveBeenWarned()
         })
       }
@@ -317,7 +317,7 @@ describe('reactivity/readonly', () => {
         expect(dummy).toBe(false)
         expect(set.has(key)).toBe(false)
         expect(
-          `Add operation on key "${key}" failed: target is readonly.`
+          `Add operation on key "${key}" failed: target is readonly.`,
         ).toHaveBeenWarned()
       })
 
@@ -345,7 +345,7 @@ describe('reactivity/readonly', () => {
           const wrapped = readonly(new Collection())
           expect(wrapped.clear()).toBeUndefined()
           expect(
-            `Clear operation failed: target is readonly.`
+            `Clear operation failed: target is readonly.`,
           ).toHaveBeenWarned()
         })
       }
@@ -447,7 +447,7 @@ describe('reactivity/readonly', () => {
   test('markRaw', () => {
     const obj = readonly({
       foo: { a: 1 },
-      bar: markRaw({ b: 2 })
+      bar: markRaw({ b: 2 }),
     })
     expect(isReadonly(obj.foo)).toBe(true)
     expect(isReactive(obj.bar)).toBe(false)
@@ -459,7 +459,7 @@ describe('reactivity/readonly', () => {
     n.value = 2
     expect(n.value).toBe(1)
     expect(
-      `Set operation on key "value" failed: target is readonly.`
+      `Set operation on key "value" failed: target is readonly.`,
     ).toHaveBeenWarned()
   })
 
@@ -473,13 +473,13 @@ describe('reactivity/readonly', () => {
 
     expect(rC.value).toBe(true)
     expect(
-      'Set operation on key "_dirty" failed: target is readonly.'
+      'Set operation on key "_dirty" failed: target is readonly.',
     ).not.toHaveBeenWarned()
     // @ts-expect-error - non-existent property
     rC.randomProperty = true
 
     expect(
-      'Set operation on key "randomProperty" failed: target is readonly.'
+      'Set operation on key "randomProperty" failed: target is readonly.',
     ).toHaveBeenWarned()
   })
 
index a1b625ab7accc17b836c87b6d971af76e9fee8d1..286d53e884024aa1f2427db936428de7bf1445be 100644 (file)
@@ -1,4 +1,4 @@
-import { describe, bench } from 'vitest'
+import { bench, describe } from 'vitest'
 import { ref } from '../src/index'
 
 describe('ref', () => {
index 0ee32866da8e4f0d91199763d6c5cd6d1a51733d..2b2024d972391505de3da68a64302f85216722ff 100644 (file)
@@ -1,20 +1,20 @@
 import {
-  ref,
+  type Ref,
   effect,
-  reactive,
+  isReactive,
   isRef,
+  reactive,
+  ref,
   toRef,
   toRefs,
-  Ref,
-  isReactive
 } from '../src/index'
 import { computed } from '@vue/runtime-dom'
-import { shallowRef, unref, customRef, triggerRef } from '../src/ref'
+import { customRef, shallowRef, triggerRef, unref } from '../src/ref'
 import {
   isReadonly,
   isShallow,
   readonly,
-  shallowReactive
+  shallowReactive,
 } from '../src/reactive'
 
 describe('reactivity/ref', () => {
@@ -44,7 +44,7 @@ describe('reactivity/ref', () => {
 
   it('should make nested properties reactive', () => {
     const a = ref({
-      count: 1
+      count: 1,
     })
     let dummy
     effect(() => {
@@ -71,8 +71,8 @@ describe('reactivity/ref', () => {
     const obj = reactive({
       a,
       b: {
-        c: a
-      }
+        c: a,
+      },
     })
 
     let dummy1: number
@@ -104,7 +104,7 @@ describe('reactivity/ref', () => {
 
   it('should unwrap nested values in types', () => {
     const a = {
-      b: ref(0)
+      b: ref(0),
     }
 
     const c = ref(a)
@@ -138,7 +138,7 @@ describe('reactivity/ref', () => {
       '1',
       { a: 1 },
       () => 0,
-      ref(0)
+      ref(0),
     ]
     const tupleRef = ref(tuple)
 
@@ -169,7 +169,7 @@ describe('reactivity/ref', () => {
       [Symbol.toPrimitive]: new WeakMap<Ref<boolean>, string>(),
       [Symbol.toStringTag]: { weakSet: new WeakSet<Ref<boolean>>() },
       [Symbol.unscopables]: { weakMap: new WeakMap<Ref<boolean>, string>() },
-      [customSymbol]: { arr: [ref(1)] }
+      [customSymbol]: { arr: [ref(1)] },
     }
 
     const objRef = ref(obj)
@@ -188,7 +188,7 @@ describe('reactivity/ref', () => {
       Symbol.toPrimitive,
       Symbol.toStringTag,
       Symbol.unscopables,
-      customSymbol
+      customSymbol,
     ]
 
     keys.forEach(key => {
@@ -248,7 +248,7 @@ describe('reactivity/ref', () => {
 
   test('toRef', () => {
     const a = reactive({
-      x: 1
+      x: 1,
     })
     const x = toRef(a, 'x')
     expect(isRef(x)).toBe(true)
@@ -313,7 +313,7 @@ describe('reactivity/ref', () => {
   test('toRefs', () => {
     const a = reactive({
       x: 1,
-      y: 2
+      y: 2,
     })
 
     const { x, y } = toRefs(a)
@@ -386,7 +386,7 @@ describe('reactivity/ref', () => {
       set(newValue: number) {
         value = newValue
         _trigger = trigger
-      }
+      },
     }))
 
     expect(isRef(custom)).toBe(true)
index bc49078029ad25e59d7e61d2110b78ae58579b30..e9b64d39b36aef655d16734dbb2f662e7fad0840 100644 (file)
@@ -3,11 +3,11 @@ import {
   isShallow,
   reactive,
   shallowReactive,
-  shallowReadonly
+  shallowReadonly,
 } from '../src/reactive'
 
 import { effect } from '../src/effect'
-import { Ref, isRef, ref } from '../src/ref'
+import { type Ref, isRef, ref } from '../src/ref'
 
 describe('shallowReactive', () => {
   test('should not make non-reactive properties reactive', () => {
@@ -50,7 +50,7 @@ describe('shallowReactive', () => {
   // vuejs/vue#12597
   test('should not unwrap refs', () => {
     const foo = shallowReactive({
-      bar: ref(123)
+      bar: ref(123),
     })
     expect(isRef(foo.bar)).toBe(true)
     expect(foo.bar.value).toBe(123)
@@ -60,7 +60,7 @@ describe('shallowReactive', () => {
   test('should not mutate refs', () => {
     const original = ref(123)
     const foo = shallowReactive<{ bar: Ref<number> | number }>({
-      bar: original
+      bar: original,
     })
     expect(foo.bar).toBe(original)
     foo.bar = 234
@@ -133,8 +133,8 @@ describe('shallowReactive', () => {
           a = Array.from(shallowSet)
         },
         {
-          onTrack: onTrackFn
-        }
+          onTrack: onTrackFn,
+        },
       )
 
       expect(a).toMatchObject([])
@@ -178,8 +178,8 @@ describe('shallowReactive', () => {
           a = Array.from(shallowArray)
         },
         {
-          onTrack: onTrackFn
-        }
+          onTrack: onTrackFn,
+        },
       )
 
       expect(a).toMatchObject([])
index b6736f4a59586e9b22321c25ff8abab266eb712c..193bc27c520cda53f5af75ced3e484ff1e799341 100644 (file)
@@ -12,7 +12,7 @@ describe('reactivity/shallowReadonly', () => {
     props.n = 2
     expect(props.n).toBe(1)
     expect(
-      `Set operation on key "n" failed: target is readonly.`
+      `Set operation on key "n" failed: target is readonly.`,
     ).toHaveBeenWarned()
   })
 
@@ -23,7 +23,7 @@ describe('reactivity/shallowReadonly', () => {
     props.n.foo = 2
     expect(props.n.foo).toBe(2)
     expect(
-      `Set operation on key "foo" failed: target is readonly.`
+      `Set operation on key "foo" failed: target is readonly.`,
     ).not.toHaveBeenWarned()
   })
 
@@ -50,7 +50,7 @@ describe('reactivity/shallowReadonly', () => {
 
         sroMap.set(key, {} as any)
         expect(
-          `Set operation on key "[object Object]" failed: target is readonly.`
+          `Set operation on key "[object Object]" failed: target is readonly.`,
         ).toHaveBeenWarned()
       })
 
@@ -64,7 +64,7 @@ describe('reactivity/shallowReadonly', () => {
 
         sroMap.get(key)!.foo = 2
         expect(
-          `Set operation on key "foo" failed: target is readonly.`
+          `Set operation on key "foo" failed: target is readonly.`,
         ).not.toHaveBeenWarned()
       })
     })
@@ -84,7 +84,7 @@ describe('reactivity/shallowReadonly', () => {
 
       values1[0].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
 
       expect(isReadonly(values2[0][1])).toBe(false)
@@ -93,7 +93,7 @@ describe('reactivity/shallowReadonly', () => {
 
       values2[0][1].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
     })
 
@@ -109,7 +109,7 @@ describe('reactivity/shallowReadonly', () => {
 
         val.foo = 2
         expect(
-          `Set operation on key "foo" failed: target is readonly.`
+          `Set operation on key "foo" failed: target is readonly.`,
         ).not.toHaveBeenWarned()
       })
     })
@@ -133,7 +133,7 @@ describe('reactivity/shallowReadonly', () => {
 
         sroSet.add({} as any)
         expect(
-          `Add operation on key "[object Object]" failed: target is readonly.`
+          `Add operation on key "[object Object]" failed: target is readonly.`,
         ).toHaveBeenWarned()
       })
     })
@@ -151,12 +151,12 @@ describe('reactivity/shallowReadonly', () => {
 
       sroSet.add({} as any)
       expect(
-        `Add operation on key "[object Object]" failed: target is readonly.`
+        `Add operation on key "[object Object]" failed: target is readonly.`,
       ).toHaveBeenWarned()
 
       values[0].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
     })
 
@@ -174,7 +174,7 @@ describe('reactivity/shallowReadonly', () => {
 
       values1[0].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
 
       expect(isReadonly(values2[0][1])).toBe(false)
@@ -183,7 +183,7 @@ describe('reactivity/shallowReadonly', () => {
 
       values2[0][1].foo = 2
       expect(
-        `Set operation on key "foo" failed: target is readonly.`
+        `Set operation on key "foo" failed: target is readonly.`,
       ).not.toHaveBeenWarned()
     })
 
@@ -199,7 +199,7 @@ describe('reactivity/shallowReadonly', () => {
 
         val.foo = 2
         expect(
-          `Set operation on key "foo" failed: target is readonly.`
+          `Set operation on key "foo" failed: target is readonly.`,
         ).not.toHaveBeenWarned()
       })
     })
index 0dffcf3588910feaca3e6817d2438adb05c8403b..a1b3003a5e7b90795be13649bc04677e9487e20d 100644 (file)
@@ -1,31 +1,31 @@
 import {
+  type Target,
+  isReadonly,
+  isShallow,
   reactive,
+  reactiveMap,
   readonly,
-  toRaw,
-  Target,
   readonlyMap,
-  reactiveMap,
   shallowReactiveMap,
   shallowReadonlyMap,
-  isReadonly,
-  isShallow
+  toRaw,
 } from './reactive'
 import { ReactiveFlags, TrackOpTypes, TriggerOpTypes } from './constants'
 import {
+  pauseScheduling,
   pauseTracking,
+  resetScheduling,
   resetTracking,
-  pauseScheduling,
-  resetScheduling
 } from './effect'
-import { track, trigger, ITERATE_KEY } from './reactiveEffect'
+import { ITERATE_KEY, track, trigger } from './reactiveEffect'
 import {
-  isObject,
-  hasOwn,
-  isSymbol,
   hasChanged,
+  hasOwn,
   isArray,
   isIntegerKey,
-  makeMap
+  isObject,
+  isSymbol,
+  makeMap,
 } from '@vue/shared'
 import { isRef } from './ref'
 import { warn } from './warning'
@@ -40,7 +40,7 @@ const builtInSymbols = new Set(
     // function
     .filter(key => key !== 'arguments' && key !== 'caller')
     .map(key => (Symbol as any)[key])
-    .filter(isSymbol)
+    .filter(isSymbol),
 )
 
 const arrayInstrumentations = /*#__PURE__*/ createArrayInstrumentations()
@@ -89,7 +89,7 @@ function hasOwnProperty(this: object, key: string) {
 class BaseReactiveHandler implements ProxyHandler<Target> {
   constructor(
     protected readonly _isReadonly = false,
-    protected readonly _shallow = false
+    protected readonly _shallow = false,
   ) {}
 
   get(target: Target, key: string | symbol, receiver: object) {
@@ -172,7 +172,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
     target: object,
     key: string | symbol,
     value: unknown,
-    receiver: object
+    receiver: object,
   ): boolean {
     let oldValue = (target as any)[key]
     if (!this._shallow) {
@@ -230,7 +230,7 @@ class MutableReactiveHandler extends BaseReactiveHandler {
     track(
       target,
       TrackOpTypes.ITERATE,
-      isArray(target) ? 'length' : ITERATE_KEY
+      isArray(target) ? 'length' : ITERATE_KEY,
     )
     return Reflect.ownKeys(target)
   }
@@ -245,7 +245,7 @@ class ReadonlyReactiveHandler extends BaseReactiveHandler {
     if (__DEV__) {
       warn(
         `Set operation on key "${String(key)}" failed: target is readonly.`,
-        target
+        target,
       )
     }
     return true
@@ -255,7 +255,7 @@ class ReadonlyReactiveHandler extends BaseReactiveHandler {
     if (__DEV__) {
       warn(
         `Delete operation on key "${String(key)}" failed: target is readonly.`,
-        target
+        target,
       )
     }
     return true
@@ -269,7 +269,7 @@ export const readonlyHandlers: ProxyHandler<object> =
   /*#__PURE__*/ new ReadonlyReactiveHandler()
 
 export const shallowReactiveHandlers = /*#__PURE__*/ new MutableReactiveHandler(
-  true
+  true,
 )
 
 // Props handlers are special in the sense that it should not unwrap top-level
index 595f06970dc768af100a09f00adc1c20d649e09c..58e69b1cc628dbc167c95582f9c593fcd953a0d3 100644 (file)
@@ -1,12 +1,12 @@
 import { toRaw, toReactive, toReadonly } from './reactive'
 import {
+  ITERATE_KEY,
+  MAP_KEY_ITERATE_KEY,
   track,
   trigger,
-  ITERATE_KEY,
-  MAP_KEY_ITERATE_KEY
 } from './reactiveEffect'
 import { ReactiveFlags, TrackOpTypes, TriggerOpTypes } from './constants'
-import { capitalize, hasOwn, hasChanged, toRawType, isMap } from '@vue/shared'
+import { capitalize, hasChanged, hasOwn, isMap, toRawType } from '@vue/shared'
 
 type CollectionTypes = IterableCollections | WeakCollections
 
@@ -24,7 +24,7 @@ function get(
   target: MapTypes,
   key: unknown,
   isReadonly = false,
-  isShallow = false
+  isShallow = false,
 ) {
   // #1772: readonly(reactive(Map)) should return readonly + reactive version
   // of the value
@@ -146,7 +146,7 @@ function createForEach(isReadonly: boolean, isShallow: boolean) {
   return function forEach(
     this: IterableCollections,
     callback: Function,
-    thisArg?: unknown
+    thisArg?: unknown,
   ) {
     const observed = this as any
     const target = observed[ReactiveFlags.RAW]
@@ -178,7 +178,7 @@ interface IterationResult {
 function createIterableMethod(
   method: string | symbol,
   isReadonly: boolean,
-  isShallow: boolean
+  isShallow: boolean,
 ) {
   return function (
     this: IterableCollections,
@@ -196,7 +196,7 @@ function createIterableMethod(
       track(
         rawTarget,
         TrackOpTypes.ITERATE,
-        isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
+        isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY,
       )
     // return a wrapped iterator which returns observed versions of the
     // values emitted from the real iterator
@@ -208,13 +208,13 @@ function createIterableMethod(
           ? { value, done }
           : {
               value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
-              done
+              done,
             }
       },
       // iterable protocol
       [Symbol.iterator]() {
         return this
-      }
+      },
     }
   }
 }
@@ -225,7 +225,7 @@ function createReadonlyMethod(type: TriggerOpTypes): Function {
       const key = args[0] ? `on key "${args[0]}" ` : ``
       console.warn(
         `${capitalize(type)} operation ${key}failed: target is readonly.`,
-        toRaw(this)
+        toRaw(this),
       )
     }
     return type === TriggerOpTypes.DELETE
@@ -249,7 +249,7 @@ function createInstrumentations() {
     set,
     delete: deleteEntry,
     clear,
-    forEach: createForEach(false, false)
+    forEach: createForEach(false, false),
   }
 
   const shallowInstrumentations: Record<string, Function | number> = {
@@ -264,7 +264,7 @@ function createInstrumentations() {
     set,
     delete: deleteEntry,
     clear,
-    forEach: createForEach(false, true)
+    forEach: createForEach(false, true),
   }
 
   const readonlyInstrumentations: Record<string, Function | number> = {
@@ -281,7 +281,7 @@ function createInstrumentations() {
     set: createReadonlyMethod(TriggerOpTypes.SET),
     delete: createReadonlyMethod(TriggerOpTypes.DELETE),
     clear: createReadonlyMethod(TriggerOpTypes.CLEAR),
-    forEach: createForEach(true, false)
+    forEach: createForEach(true, false),
   }
 
   const shallowReadonlyInstrumentations: Record<string, Function | number> = {
@@ -298,7 +298,7 @@ function createInstrumentations() {
     set: createReadonlyMethod(TriggerOpTypes.SET),
     delete: createReadonlyMethod(TriggerOpTypes.DELETE),
     clear: createReadonlyMethod(TriggerOpTypes.CLEAR),
-    forEach: createForEach(true, true)
+    forEach: createForEach(true, true),
   }
 
   const iteratorMethods = ['keys', 'values', 'entries', Symbol.iterator]
@@ -306,22 +306,22 @@ function createInstrumentations() {
     mutableInstrumentations[method as string] = createIterableMethod(
       method,
       false,
-      false
+      false,
     )
     readonlyInstrumentations[method as string] = createIterableMethod(
       method,
       true,
-      false
+      false,
     )
     shallowInstrumentations[method as string] = createIterableMethod(
       method,
       false,
-      true
+      true,
     )
     shallowReadonlyInstrumentations[method as string] = createIterableMethod(
       method,
       true,
-      true
+      true,
     )
   })
 
@@ -329,7 +329,7 @@ function createInstrumentations() {
     mutableInstrumentations,
     readonlyInstrumentations,
     shallowInstrumentations,
-    shallowReadonlyInstrumentations
+    shallowReadonlyInstrumentations,
   ]
 }
 
@@ -337,7 +337,7 @@ const [
   mutableInstrumentations,
   readonlyInstrumentations,
   shallowInstrumentations,
-  shallowReadonlyInstrumentations
+  shallowReadonlyInstrumentations,
 ] = /* #__PURE__*/ createInstrumentations()
 
 function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) {
@@ -352,7 +352,7 @@ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) {
   return (
     target: CollectionTypes,
     key: string | symbol,
-    receiver: CollectionTypes
+    receiver: CollectionTypes,
   ) => {
     if (key === ReactiveFlags.IS_REACTIVE) {
       return !isReadonly
@@ -367,32 +367,32 @@ function createInstrumentationGetter(isReadonly: boolean, shallow: boolean) {
         ? instrumentations
         : target,
       key,
-      receiver
+      receiver,
     )
   }
 }
 
 export const mutableCollectionHandlers: ProxyHandler<CollectionTypes> = {
-  get: /*#__PURE__*/ createInstrumentationGetter(false, false)
+  get: /*#__PURE__*/ createInstrumentationGetter(false, false),
 }
 
 export const shallowCollectionHandlers: ProxyHandler<CollectionTypes> = {
-  get: /*#__PURE__*/ createInstrumentationGetter(false, true)
+  get: /*#__PURE__*/ createInstrumentationGetter(false, true),
 }
 
 export const readonlyCollectionHandlers: ProxyHandler<CollectionTypes> = {
-  get: /*#__PURE__*/ createInstrumentationGetter(true, false)
+  get: /*#__PURE__*/ createInstrumentationGetter(true, false),
 }
 
 export const shallowReadonlyCollectionHandlers: ProxyHandler<CollectionTypes> =
   {
-    get: /*#__PURE__*/ createInstrumentationGetter(true, true)
+    get: /*#__PURE__*/ createInstrumentationGetter(true, true),
   }
 
 function checkIdentityKeys(
   target: CollectionTypes,
   has: (key: unknown) => boolean,
-  key: unknown
+  key: unknown,
 ) {
   const rawKey = toRaw(key)
   if (rawKey !== key && has.call(target, rawKey)) {
@@ -402,7 +402,7 @@ function checkIdentityKeys(
         `versions of the same object${type === `Map` ? ` as keys` : ``}, ` +
         `which can lead to inconsistencies. ` +
         `Avoid differentiating between the raw and reactive versions ` +
-        `of an object and only use the reactive version if possible.`
+        `of an object and only use the reactive version if possible.`,
     )
   }
 }
index c48e2f0df2c4983daefaf39d8a2ef3b1e4c37ae3..8dab864ed697c7fc36d90f2b3e96a5c88f55663f 100644 (file)
@@ -1,8 +1,8 @@
-import { DebuggerOptions, ReactiveEffect } from './effect'
-import { Ref, trackRefValue, triggerRefValue } from './ref'
-import { hasChanged, isFunction, NOOP } from '@vue/shared'
+import { type DebuggerOptions, ReactiveEffect } from './effect'
+import { type Ref, trackRefValue, triggerRefValue } from './ref'
+import { NOOP, hasChanged, isFunction } from '@vue/shared'
 import { toRaw } from './reactive'
-import { Dep } from './dep'
+import type { Dep } from './dep'
 import { DirtyLevels, ReactiveFlags } from './constants'
 
 declare const ComputedRefSymbol: unique symbol
@@ -39,11 +39,11 @@ export class ComputedRefImpl<T> {
     getter: ComputedGetter<T>,
     private readonly _setter: ComputedSetter<T>,
     isReadonly: boolean,
-    isSSR: boolean
+    isSSR: boolean,
   ) {
     this.effect = new ReactiveEffect(
       () => getter(this._value),
-      () => triggerRefValue(this, DirtyLevels.ComputedValueMaybeDirty)
+      () => triggerRefValue(this, DirtyLevels.ComputedValueMaybeDirty),
     )
     this.effect.computed = this
     this.effect.active = this._cacheable = !isSSR
@@ -112,16 +112,16 @@ export class ComputedRefImpl<T> {
  */
 export function computed<T>(
   getter: ComputedGetter<T>,
-  debugOptions?: DebuggerOptions
+  debugOptions?: DebuggerOptions,
 ): ComputedRef<T>
 export function computed<T>(
   options: WritableComputedOptions<T>,
-  debugOptions?: DebuggerOptions
+  debugOptions?: DebuggerOptions,
 ): WritableComputedRef<T>
 export function computed<T>(
   getterOrOptions: ComputedGetter<T> | WritableComputedOptions<T>,
   debugOptions?: DebuggerOptions,
-  isSSR = false
+  isSSR = false,
 ) {
   let getter: ComputedGetter<T>
   let setter: ComputedSetter<T>
index f87c62604a89e43fdd86ba236a8dd4bdafd93113..3377ef57a74400aacc97481062ecc6e78e2518d5 100644 (file)
@@ -4,14 +4,14 @@
 export enum TrackOpTypes {
   GET = 'get',
   HAS = 'has',
-  ITERATE = 'iterate'
+  ITERATE = 'iterate',
 }
 
 export enum TriggerOpTypes {
   SET = 'set',
   ADD = 'add',
   DELETE = 'delete',
-  CLEAR = 'clear'
+  CLEAR = 'clear',
 }
 
 export enum ReactiveFlags {
@@ -19,12 +19,12 @@ export enum ReactiveFlags {
   IS_REACTIVE = '__v_isReactive',
   IS_READONLY = '__v_isReadonly',
   IS_SHALLOW = '__v_isShallow',
-  RAW = '__v_raw'
+  RAW = '__v_raw',
 }
 
 export enum DirtyLevels {
   NotDirty = 0,
   ComputedValueMaybeDirty = 1,
   ComputedValueDirty = 2,
-  Dirty = 3
+  Dirty = 3,
 }
index eafb2a8af3f59cd949d95fa48e0e841788f4740b..c8e8a130dc9bc199ea201ec0eb206171a7f6afcf 100644 (file)
@@ -8,7 +8,7 @@ export type Dep = Map<ReactiveEffect, number> & {
 
 export const createDep = (
   cleanup: () => void,
-  computed?: ComputedRefImpl<any>
+  computed?: ComputedRefImpl<any>,
 ): Dep => {
   const dep = new Map() as Dep
   dep.cleanup = cleanup
index 3a25295011c05b95187d8fa5da5e43ceff4598fb..676a98821d0acd8fab4de91020986a3de18f5cb0 100644 (file)
@@ -1,8 +1,12 @@
 import { NOOP, extend } from '@vue/shared'
 import type { ComputedRefImpl } from './computed'
-import { DirtyLevels, TrackOpTypes, TriggerOpTypes } from './constants'
+import {
+  DirtyLevels,
+  type TrackOpTypes,
+  type TriggerOpTypes,
+} from './constants'
 import type { Dep } from './dep'
-import { EffectScope, recordEffectScope } from './effectScope'
+import { type EffectScope, recordEffectScope } from './effectScope'
 
 export type EffectScheduler = (...args: any[]) => any
 
@@ -66,7 +70,7 @@ export class ReactiveEffect<T = any> {
     public fn: () => T,
     public trigger: () => void,
     public scheduler?: EffectScheduler,
-    scope?: EffectScope
+    scope?: EffectScope,
   ) {
     recordEffectScope(this, scope)
   }
@@ -183,7 +187,7 @@ export interface ReactiveEffectRunner<T = any> {
  */
 export function effect<T = any>(
   fn: () => T,
-  options?: ReactiveEffectOptions
+  options?: ReactiveEffectOptions,
 ): ReactiveEffectRunner {
   if ((fn as ReactiveEffectRunner).effect instanceof ReactiveEffect) {
     fn = (fn as ReactiveEffectRunner).effect.fn
@@ -258,7 +262,7 @@ export function resetScheduling() {
 export function trackEffect(
   effect: ReactiveEffect,
   dep: Dep,
-  debuggerEventExtraInfo?: DebuggerEventExtraInfo
+  debuggerEventExtraInfo?: DebuggerEventExtraInfo,
 ) {
   if (dep.get(effect) !== effect._trackId) {
     dep.set(effect, effect._trackId)
@@ -282,7 +286,7 @@ const queueEffectSchedulers: (() => void)[] = []
 export function triggerEffects(
   dep: Dep,
   dirtyLevel: DirtyLevels,
-  debuggerEventExtraInfo?: DebuggerEventExtraInfo
+  debuggerEventExtraInfo?: DebuggerEventExtraInfo,
 ) {
   pauseScheduling()
   for (const effect of dep.keys()) {
index a65c48d031bd6e4798c417a85af82421ce5e5080..6a3eaec9fd51a1585d9d9edec44512988bee0cbe 100644 (file)
@@ -1,4 +1,4 @@
-import { ReactiveEffect } from './effect'
+import type { ReactiveEffect } from './effect'
 import { warn } from './warning'
 
 let activeEffectScope: EffectScope | undefined
@@ -39,7 +39,7 @@ export class EffectScope {
     if (!detached && activeEffectScope) {
       this.index =
         (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
-          this
+          this,
         ) - 1
     }
   }
@@ -122,7 +122,7 @@ export function effectScope(detached?: boolean) {
 
 export function recordEffectScope(
   effect: ReactiveEffect,
-  scope: EffectScope | undefined = activeEffectScope
+  scope: EffectScope | undefined = activeEffectScope,
 ) {
   if (scope && scope.active) {
     scope.effects.push(effect)
@@ -151,7 +151,7 @@ export function onScopeDispose(fn: () => void) {
   } else if (__DEV__) {
     warn(
       `onScopeDispose() is called when there is no active effect scope` +
-        ` to be associated with.`
+        ` to be associated with.`,
     )
   }
 }
index 2a9615b14b7df7b37ba724b9096666d23476b60b..1c80fbc752b733290296c05fefb7a7c8aed29351 100644 (file)
@@ -18,7 +18,7 @@ export {
   type ShallowRef,
   type ShallowUnwrapRef,
   type RefUnwrapBailTypes,
-  type CustomRefFactory
+  type CustomRefFactory,
 } from './ref'
 export {
   reactive,
@@ -34,7 +34,7 @@ export {
   type Raw,
   type DeepReadonly,
   type ShallowReactive,
-  type UnwrapNestedRefs
+  type UnwrapNestedRefs,
 } from './reactive'
 export {
   computed,
@@ -42,7 +42,7 @@ export {
   type WritableComputedRef,
   type WritableComputedOptions,
   type ComputedGetter,
-  type ComputedSetter
+  type ComputedSetter,
 } from './computed'
 export { deferredComputed } from './deferredComputed'
 export {
@@ -59,13 +59,13 @@ export {
   type EffectScheduler,
   type DebuggerOptions,
   type DebuggerEvent,
-  type DebuggerEventExtraInfo
+  type DebuggerEventExtraInfo,
 } from './effect'
 export { trigger, track, ITERATE_KEY } from './reactiveEffect'
 export {
   effectScope,
   EffectScope,
   getCurrentScope,
-  onScopeDispose
+  onScopeDispose,
 } from './effectScope'
 export { TrackOpTypes, TriggerOpTypes, ReactiveFlags } from './constants'
index 4bb1c198896adf3fa7ec2aead929cd2dd96b4207..6e98fedeaf401bbdf59a4d810db8adfa46e72cf6 100644 (file)
@@ -1,17 +1,17 @@
-import { isObject, toRawType, def } from '@vue/shared'
+import { def, isObject, toRawType } from '@vue/shared'
 import {
   mutableHandlers,
   readonlyHandlers,
   shallowReactiveHandlers,
-  shallowReadonlyHandlers
+  shallowReadonlyHandlers,
 } from './baseHandlers'
 import {
   mutableCollectionHandlers,
   readonlyCollectionHandlers,
   shallowCollectionHandlers,
-  shallowReadonlyCollectionHandlers
+  shallowReadonlyCollectionHandlers,
 } from './collectionHandlers'
-import type { UnwrapRefSimple, Ref, RawSymbol } from './ref'
+import type { RawSymbol, Ref, UnwrapRefSimple } from './ref'
 import { ReactiveFlags } from './constants'
 
 export interface Target {
@@ -30,7 +30,7 @@ export const shallowReadonlyMap = new WeakMap<Target, any>()
 enum TargetType {
   INVALID = 0,
   COMMON = 1,
-  COLLECTION = 2
+  COLLECTION = 2,
 }
 
 function targetTypeMap(rawType: string) {
@@ -83,7 +83,7 @@ export function reactive(target: object) {
     false,
     mutableHandlers,
     mutableCollectionHandlers,
-    reactiveMap
+    reactiveMap,
   )
 }
 
@@ -122,14 +122,14 @@ export type ShallowReactive<T> = T & { [ShallowReactiveMarker]?: true }
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowreactive}
  */
 export function shallowReactive<T extends object>(
-  target: T
+  target: T,
 ): ShallowReactive<T> {
   return createReactiveObject(
     target,
     false,
     shallowReactiveHandlers,
     shallowCollectionHandlers,
-    shallowReactiveMap
+    shallowReactiveMap,
   )
 }
 
@@ -187,14 +187,14 @@ export type DeepReadonly<T> = T extends Builtin
  * @see {@link https://vuejs.org/api/reactivity-core.html#readonly}
  */
 export function readonly<T extends object>(
-  target: T
+  target: T,
 ): DeepReadonly<UnwrapNestedRefs<T>> {
   return createReactiveObject(
     target,
     true,
     readonlyHandlers,
     readonlyCollectionHandlers,
-    readonlyMap
+    readonlyMap,
   )
 }
 
@@ -234,7 +234,7 @@ export function shallowReadonly<T extends object>(target: T): Readonly<T> {
     true,
     shallowReadonlyHandlers,
     shallowReadonlyCollectionHandlers,
-    shallowReadonlyMap
+    shallowReadonlyMap,
   )
 }
 
@@ -243,7 +243,7 @@ function createReactiveObject(
   isReadonly: boolean,
   baseHandlers: ProxyHandler<any>,
   collectionHandlers: ProxyHandler<any>,
-  proxyMap: WeakMap<Target, any>
+  proxyMap: WeakMap<Target, any>,
 ) {
   if (!isObject(target)) {
     if (__DEV__) {
@@ -271,7 +271,7 @@ function createReactiveObject(
   }
   const proxy = new Proxy(
     target,
-    targetType === TargetType.COLLECTION ? collectionHandlers : baseHandlers
+    targetType === TargetType.COLLECTION ? collectionHandlers : baseHandlers,
   )
   proxyMap.set(target, proxy)
   return proxy
index d3474db3da1b1c1ebf9ba98245c3712c941a7e8b..09985e1eac3d09afc17062818178798505f2dbfd 100644 (file)
@@ -1,13 +1,13 @@
 import { isArray, isIntegerKey, isMap, isSymbol } from '@vue/shared'
-import { DirtyLevels, TrackOpTypes, TriggerOpTypes } from './constants'
-import { createDep, Dep } from './dep'
+import { DirtyLevels, type TrackOpTypes, TriggerOpTypes } from './constants'
+import { type Dep, createDep } from './dep'
 import {
   activeEffect,
   pauseScheduling,
   resetScheduling,
   shouldTrack,
   trackEffect,
-  triggerEffects
+  triggerEffects,
 } from './effect'
 
 // The main WeakMap that stores {target -> key -> dep} connections.
@@ -47,9 +47,9 @@ export function track(target: object, type: TrackOpTypes, key: unknown) {
         ? {
             target,
             type,
-            key
+            key,
           }
-        : void 0
+        : void 0,
     )
   }
 }
@@ -68,7 +68,7 @@ export function trigger(
   key?: unknown,
   newValue?: unknown,
   oldValue?: unknown,
-  oldTarget?: Map<unknown, unknown> | Set<unknown>
+  oldTarget?: Map<unknown, unknown> | Set<unknown>,
 ) {
   const depsMap = targetMap.get(target)
   if (!depsMap) {
@@ -136,9 +136,9 @@ export function trigger(
               key,
               newValue,
               oldValue,
-              oldTarget
+              oldTarget,
             }
-          : void 0
+          : void 0,
       )
     }
   }
index 6c8ec96445cd4827ba71978b42c073f78b5dd7a2..6ec3dacc9e7ee82be1b92d122334a3f0d2390794 100644 (file)
@@ -3,20 +3,26 @@ import {
   activeEffect,
   shouldTrack,
   trackEffect,
-  triggerEffects
+  triggerEffects,
 } from './effect'
 import { DirtyLevels, TrackOpTypes, TriggerOpTypes } from './constants'
-import { isArray, hasChanged, IfAny, isFunction, isObject } from '@vue/shared'
+import {
+  type IfAny,
+  hasChanged,
+  isArray,
+  isFunction,
+  isObject,
+} from '@vue/shared'
 import {
   isProxy,
-  toRaw,
   isReactive,
-  toReactive,
   isReadonly,
-  isShallow
+  isShallow,
+  toRaw,
+  toReactive,
 } from './reactive'
 import type { ShallowReactiveMarker } from './reactive'
-import { createDep, Dep } from './dep'
+import { type Dep, createDep } from './dep'
 import { ComputedRefImpl } from './computed'
 import { getDepFromReactive } from './reactiveEffect'
 
@@ -46,15 +52,15 @@ export function trackRefValue(ref: RefBase<any>) {
       ref.dep ||
         (ref.dep = createDep(
           () => (ref.dep = undefined),
-          ref instanceof ComputedRefImpl ? ref : undefined
+          ref instanceof ComputedRefImpl ? ref : undefined,
         )),
       __DEV__
         ? {
             target: ref,
             type: TrackOpTypes.GET,
-            key: 'value'
+            key: 'value',
           }
-        : void 0
+        : void 0,
     )
   }
 }
@@ -62,7 +68,7 @@ export function trackRefValue(ref: RefBase<any>) {
 export function triggerRefValue(
   ref: RefBase<any>,
   dirtyLevel: DirtyLevels = DirtyLevels.Dirty,
-  newVal?: any
+  newVal?: any,
 ) {
   ref = toRaw(ref)
   const dep = ref.dep
@@ -75,9 +81,9 @@ export function triggerRefValue(
             target: ref,
             type: TriggerOpTypes.SET,
             key: 'value',
-            newValue: newVal
+            newValue: newVal,
           }
-        : void 0
+        : void 0,
     )
   }
 }
@@ -128,7 +134,7 @@ export type ShallowRef<T = any> = Ref<T> & { [ShallowRefMarker]?: true }
  * @see {@link https://vuejs.org/api/reactivity-advanced.html#shallowref}
  */
 export function shallowRef<T>(
-  value: T
+  value: T,
 ): Ref extends T
   ? T extends Ref
     ? IfAny<T, ShallowRef<T>, T>
@@ -155,7 +161,7 @@ class RefImpl<T> {
 
   constructor(
     value: T,
-    public readonly __v_isShallow: boolean
+    public readonly __v_isShallow: boolean,
   ) {
     this._rawValue = __v_isShallow ? value : toRaw(value)
     this._value = __v_isShallow ? value : toReactive(value)
@@ -260,7 +266,7 @@ const shallowUnwrapHandlers: ProxyHandler<any> = {
     } else {
       return Reflect.set(target, key, value, receiver)
     }
-  }
+  },
 }
 
 /**
@@ -274,7 +280,7 @@ const shallowUnwrapHandlers: ProxyHandler<any> = {
  * that contains refs.
  */
 export function proxyRefs<T extends object>(
-  objectWithRefs: T
+  objectWithRefs: T,
 ): ShallowUnwrapRef<T> {
   return isReactive(objectWithRefs)
     ? objectWithRefs
@@ -283,7 +289,7 @@ export function proxyRefs<T extends object>(
 
 export type CustomRefFactory<T> = (
   track: () => void,
-  trigger: () => void
+  trigger: () => void,
 ) => {
   get: () => T
   set: (value: T) => void
@@ -300,7 +306,7 @@ class CustomRefImpl<T> {
   constructor(factory: CustomRefFactory<T>) {
     const { get, set } = factory(
       () => trackRefValue(this),
-      () => triggerRefValue(this)
+      () => triggerRefValue(this),
     )
     this._get = get
     this._set = set
@@ -355,7 +361,7 @@ class ObjectRefImpl<T extends object, K extends keyof T> {
   constructor(
     private readonly _object: T,
     private readonly _key: K,
-    private readonly _defaultValue?: T[K]
+    private readonly _defaultValue?: T[K],
   ) {}
 
   get value() {
@@ -427,7 +433,7 @@ export type ToRef<T> = IfAny<T, Ref<T>, [T] extends [Ref] ? T : Ref<T>>
  * @see {@link https://vuejs.org/api/reactivity-utilities.html#toref}
  */
 export function toRef<T>(
-  value: T
+  value: T,
 ): T extends () => infer R
   ? Readonly<Ref<R>>
   : T extends Ref
@@ -435,17 +441,17 @@ export function toRef<T>(
     : Ref<UnwrapRef<T>>
 export function toRef<T extends object, K extends keyof T>(
   object: T,
-  key: K
+  key: K,
 ): ToRef<T[K]>
 export function toRef<T extends object, K extends keyof T>(
   object: T,
   key: K,
-  defaultValue: T[K]
+  defaultValue: T[K],
 ): ToRef<Exclude<T[K], undefined>>
 export function toRef(
   source: Record<string, any> | MaybeRef,
   key?: string,
-  defaultValue?: unknown
+  defaultValue?: unknown,
 ): Ref {
   if (isRef(source)) {
     return source
@@ -461,7 +467,7 @@ export function toRef(
 function propertyToRef(
   source: Record<string, any>,
   key: string,
-  defaultValue?: unknown
+  defaultValue?: unknown,
 ) {
   const val = source[key]
   return isRef(val)
index de9878b1181854a9235e0cd59a2eb39d848cb307..74e24dce65feca90087d5fd6141d3f3049e6acba 100644 (file)
@@ -1,11 +1,11 @@
 import {
+  type Component,
+  KeepAlive,
+  Suspense,
   defineAsyncComponent,
   h,
-  Component,
-  ref,
   nextTick,
-  Suspense,
-  KeepAlive
+  ref,
 } from '../src'
 import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
 import { onActivated } from '../src/components/KeepAlive'
@@ -19,13 +19,13 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise(r => {
           resolve = r as any
-        })
+        }),
     )
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     }).mount(root)
 
     expect(serializeInner(root)).toBe('<!---->')
@@ -54,13 +54,13 @@ describe('api: defineAsyncComponent', () => {
           resolve = r as any
         }),
       loadingComponent: () => 'loading',
-      delay: 1 // defaults to 200
+      delay: 1, // defaults to 200
     })
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     }).mount(root)
 
     // due to the delay, initial mount should be empty
@@ -93,13 +93,13 @@ describe('api: defineAsyncComponent', () => {
           resolve = r as any
         }),
       loadingComponent: () => 'loading',
-      delay: 0
+      delay: 0,
     })
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     }).mount(root)
 
     // with delay: 0, should show loading immediately
@@ -128,13 +128,13 @@ describe('api: defineAsyncComponent', () => {
         new Promise((_resolve, _reject) => {
           resolve = _resolve as any
           reject = _reject
-        })
+        }),
     )
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -173,13 +173,13 @@ describe('api: defineAsyncComponent', () => {
           resolve = _resolve as any
           reject = _reject
         }),
-      errorComponent: (props: { error: Error }) => props.error.message
+      errorComponent: (props: { error: Error }) => props.error.message,
     })
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -218,13 +218,13 @@ describe('api: defineAsyncComponent', () => {
           resolve = _resolve as any
           reject = _reject
         }),
-      errorComponent: (props: { error: Error }) => props.error.message
+      errorComponent: (props: { error: Error }) => props.error.message,
     })
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     })
 
     app.mount(root)
@@ -235,7 +235,7 @@ describe('api: defineAsyncComponent', () => {
     await timeout()
     expect(serializeInner(root)).toBe('errored out')
     expect(
-      'Unhandled error during execution of async component loader'
+      'Unhandled error during execution of async component loader',
     ).toHaveBeenWarned()
 
     toggle.value = false
@@ -264,13 +264,13 @@ describe('api: defineAsyncComponent', () => {
         }),
       errorComponent: (props: { error: Error }) => props.error.message,
       loadingComponent: () => 'loading',
-      delay: 1
+      delay: 1,
     })
 
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => (toggle.value ? h(Foo) : null)
+      render: () => (toggle.value ? h(Foo) : null),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -316,12 +316,12 @@ describe('api: defineAsyncComponent', () => {
         new Promise(_resolve => {
           resolve = _resolve as any
         }),
-      timeout: 1
+      timeout: 1,
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
 
     const handler = vi.fn()
@@ -333,7 +333,7 @@ describe('api: defineAsyncComponent', () => {
     await timeout(1)
     expect(handler).toHaveBeenCalled()
     expect(handler.mock.calls[0][0].message).toMatch(
-      `Async component timed out after 1ms.`
+      `Async component timed out after 1ms.`,
     )
     expect(serializeInner(root)).toBe('<!---->')
 
@@ -351,12 +351,12 @@ describe('api: defineAsyncComponent', () => {
           resolve = _resolve as any
         }),
       timeout: 1,
-      errorComponent: () => 'timed out'
+      errorComponent: () => 'timed out',
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -384,12 +384,12 @@ describe('api: defineAsyncComponent', () => {
       delay: 1,
       timeout: 16,
       errorComponent: () => 'timed out',
-      loadingComponent: () => 'loading'
+      loadingComponent: () => 'loading',
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
     const handler = (app.config.errorHandler = vi.fn())
     app.mount(root)
@@ -415,12 +415,12 @@ describe('api: defineAsyncComponent', () => {
         }),
       delay: 1,
       timeout: 16,
-      loadingComponent: () => 'loading'
+      loadingComponent: () => 'loading',
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
     const handler = vi.fn()
     app.config.errorHandler = handler
@@ -432,7 +432,7 @@ describe('api: defineAsyncComponent', () => {
     await timeout(16)
     expect(handler).toHaveBeenCalled()
     expect(handler.mock.calls[0][0].message).toMatch(
-      `Async component timed out after 16ms.`
+      `Async component timed out after 16ms.`,
     )
     // should still display loading
     expect(serializeInner(root)).toBe('loading')
@@ -448,7 +448,7 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise(_resolve => {
           resolve = _resolve as any
-        })
+        }),
     )
 
     const root = nodeOps.createElement('div')
@@ -456,8 +456,8 @@ describe('api: defineAsyncComponent', () => {
       render: () =>
         h(Suspense, null, {
           default: () => h('div', [h(Foo), ' & ', h(Foo)]),
-          fallback: () => 'loading'
-        })
+          fallback: () => 'loading',
+        }),
     })
 
     app.mount(root)
@@ -475,7 +475,7 @@ describe('api: defineAsyncComponent', () => {
         new Promise(_resolve => {
           resolve = _resolve as any
         }),
-      suspensible: false
+      suspensible: false,
     })
 
     const root = nodeOps.createElement('div')
@@ -483,8 +483,8 @@ describe('api: defineAsyncComponent', () => {
       render: () =>
         h(Suspense, null, {
           default: () => h('div', [h(Foo), ' & ', h(Foo)]),
-          fallback: () => 'loading'
-        })
+          fallback: () => 'loading',
+        }),
     })
 
     app.mount(root)
@@ -502,7 +502,7 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise((_resolve, _reject) => {
           reject = _reject
-        })
+        }),
     )
 
     const root = nodeOps.createElement('div')
@@ -510,8 +510,8 @@ describe('api: defineAsyncComponent', () => {
       render: () =>
         h(Suspense, null, {
           default: () => h('div', [h(Foo), ' & ', h(Foo)]),
-          fallback: () => 'loading'
-        })
+          fallback: () => 'loading',
+        }),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -543,12 +543,12 @@ describe('api: defineAsyncComponent', () => {
         } else {
           fail()
         }
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -587,12 +587,12 @@ describe('api: defineAsyncComponent', () => {
         } else {
           fail()
         }
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -627,12 +627,12 @@ describe('api: defineAsyncComponent', () => {
         } else {
           fail()
         }
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(Foo)
+      render: () => h(Foo),
     })
 
     const handler = (app.config.errorHandler = vi.fn())
@@ -663,14 +663,14 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise(r => {
           resolve = r as any
-        })
+        }),
     )
 
     const fooRef = ref<any>(null)
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     createApp({
-      render: () => (toggle.value ? h(Foo, { ref: fooRef }) : null)
+      render: () => (toggle.value ? h(Foo, { ref: fooRef }) : null),
     }).mount(root)
 
     expect(serializeInner(root)).toBe('<!---->')
@@ -679,10 +679,10 @@ describe('api: defineAsyncComponent', () => {
     resolve!({
       data() {
         return {
-          id: 'foo'
+          id: 'foo',
         }
       },
-      render: () => 'resolved'
+      render: () => 'resolved',
     })
     // first time resolve, wait for macro task since there are multiple
     // microtasks / .then() calls
@@ -709,7 +709,7 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise(r => {
           resolve = r as any
-        })
+        }),
     )
 
     const fooRef = ref<any>(null)
@@ -719,7 +719,7 @@ describe('api: defineAsyncComponent', () => {
     const root = nodeOps.createElement('div')
     createApp({
       render: () =>
-        toggle.value ? [h(Foo, { ref: fooRef }), updater.value] : null
+        toggle.value ? [h(Foo, { ref: fooRef }), updater.value] : null,
     }).mount(root)
 
     expect(serializeInner(root)).toBe('<!---->0')
@@ -728,10 +728,10 @@ describe('api: defineAsyncComponent', () => {
     resolve!({
       data() {
         return {
-          id: 'foo'
+          id: 'foo',
         }
       },
-      render: () => 'resolved'
+      render: () => 'resolved',
     })
 
     await timeout()
@@ -755,7 +755,7 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise(r => {
           resolve = r as any
-        })
+        }),
     )
     const updater = ref(0)
 
@@ -765,14 +765,14 @@ describe('api: defineAsyncComponent', () => {
       onVnodeBeforeUpdate: vi.fn(),
       onVnodeUpdated: vi.fn(),
       onVnodeBeforeUnmount: vi.fn(),
-      onVnodeUnmounted: vi.fn()
+      onVnodeUnmounted: vi.fn(),
     }
 
     const toggle = ref(true)
 
     const root = nodeOps.createElement('div')
     createApp({
-      render: () => (toggle.value ? [h(Foo, vnodeHooks), updater.value] : null)
+      render: () => (toggle.value ? [h(Foo, vnodeHooks), updater.value] : null),
     }).mount(root)
 
     expect(serializeInner(root)).toBe('<!---->0')
@@ -780,10 +780,10 @@ describe('api: defineAsyncComponent', () => {
     resolve!({
       data() {
         return {
-          id: 'foo'
+          id: 'foo',
         }
       },
-      render: () => 'resolved'
+      render: () => 'resolved',
     })
 
     await timeout()
@@ -812,7 +812,7 @@ describe('api: defineAsyncComponent', () => {
       () =>
         new Promise(r => {
           resolve = r as any
-        })
+        }),
     )
 
     const Bar = defineAsyncComponent(() => Promise.resolve(() => 'Bar'))
@@ -820,7 +820,7 @@ describe('api: defineAsyncComponent', () => {
     const toggle = ref(true)
     const root = nodeOps.createElement('div')
     const app = createApp({
-      render: () => h(KeepAlive, [toggle.value ? h(Foo) : h(Bar)])
+      render: () => h(KeepAlive, [toggle.value ? h(Foo) : h(Bar)]),
     })
 
     app.mount(root)
@@ -832,7 +832,7 @@ describe('api: defineAsyncComponent', () => {
           spy()
         })
         return () => 'Foo'
-      }
+      },
     })
 
     await timeout()
index 637167931d2f76a42738206729814b0d7f7ce310..300daaaca8be8d0ef8f565b9804d83946db5421b 100644 (file)
@@ -1,17 +1,17 @@
 import {
+  type Plugin,
   createApp,
+  defineComponent,
+  getCurrentInstance,
   h,
+  inject,
   nodeOps,
-  serializeInner,
   provide,
-  inject,
+  ref,
   resolveComponent,
   resolveDirective,
+  serializeInner,
   withDirectives,
-  Plugin,
-  ref,
-  getCurrentInstance,
-  defineComponent
 } from '@vue/runtime-test'
 
 describe('api: createApp', () => {
@@ -19,12 +19,12 @@ describe('api: createApp', () => {
     const Comp = defineComponent({
       props: {
         count: {
-          default: 0
-        }
+          default: 0,
+        },
       },
       setup(props) {
         return () => props.count
-      }
+      },
     })
 
     const root1 = nodeOps.createElement('div')
@@ -33,7 +33,7 @@ describe('api: createApp', () => {
     //#5571 mount multiple apps to the same host element
     createApp(Comp).mount(root1)
     expect(
-      `There is already an app instance mounted on the host container`
+      `There is already an app instance mounted on the host container`,
     ).toHaveBeenWarned()
 
     // mount with props
@@ -53,12 +53,12 @@ describe('api: createApp', () => {
     const Comp = defineComponent({
       props: {
         count: {
-          default: 0
-        }
+          default: 0,
+        },
       },
       setup(props) {
         return () => props.count
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -80,7 +80,7 @@ describe('api: createApp', () => {
         // test override
         provide('foo', 3)
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -91,7 +91,7 @@ describe('api: createApp', () => {
           inject('__proto__')
         } catch (e: any) {}
         return () => `${foo},${bar}`
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -114,7 +114,7 @@ describe('api: createApp', () => {
       setup() {
         provide('foo', 'should not be seen')
         return () => h('div')
-      }
+      },
     })
     app.provide('foo', 1)
 
@@ -129,7 +129,7 @@ describe('api: createApp', () => {
     const Root = {
       // local override
       components: {
-        BarBaz: () => 'barbaz-local!'
+        BarBaz: () => 'barbaz-local!',
       },
       setup() {
         // resolve in setup
@@ -139,7 +139,7 @@ describe('api: createApp', () => {
           const BarBaz = resolveComponent('bar-baz') as any
           return h('div', [h(FooBar), h(BarBaz)])
         }
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -152,7 +152,7 @@ describe('api: createApp', () => {
 
     app.component('BarBaz', () => 'barbaz!')
     expect(
-      'Component "BarBaz" has already been registered in target app.'
+      'Component "BarBaz" has already been registered in target app.',
     ).toHaveBeenWarnedTimes(1)
 
     const root = nodeOps.createElement('div')
@@ -168,7 +168,7 @@ describe('api: createApp', () => {
     const Root = {
       // local override
       directives: {
-        BarBaz: { mounted: spy3 }
+        BarBaz: { mounted: spy3 },
       },
       setup() {
         // resolve in setup
@@ -178,7 +178,7 @@ describe('api: createApp', () => {
           const BarBaz = resolveDirective('bar-baz')!
           return withDirectives(h('div'), [[FooBar], [BarBaz]])
         }
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -188,14 +188,14 @@ describe('api: createApp', () => {
     expect(app.directive('FooBar')).toBe(FooBar)
 
     app.directive('BarBaz', {
-      mounted: spy2
+      mounted: spy2,
     })
 
     app.directive('BarBaz', {
-      mounted: spy2
+      mounted: spy2,
     })
     expect(
-      'Directive "BarBaz" has already been registered in target app.'
+      'Directive "BarBaz" has already been registered in target app.',
     ).toHaveBeenWarnedTimes(1)
 
     const root = nodeOps.createElement('div')
@@ -206,7 +206,7 @@ describe('api: createApp', () => {
 
     app.directive('bind', FooBar)
     expect(
-      `Do not use built-in directive ids as custom directive id: bind`
+      `Do not use built-in directive ids as custom directive id: bind`,
     ).toHaveBeenWarned()
   })
 
@@ -215,7 +215,7 @@ describe('api: createApp', () => {
     const mixinA = {
       data() {
         return {
-          a: 1
+          a: 1,
         }
       },
       created(this: any) {
@@ -226,13 +226,13 @@ describe('api: createApp', () => {
       },
       mounted() {
         calls.push('mixinA mounted')
-      }
+      },
     }
     const mixinB = {
       name: 'mixinB',
       data() {
         return {
-          b: 2
+          b: 2,
         }
       },
       created(this: any) {
@@ -243,12 +243,12 @@ describe('api: createApp', () => {
       },
       mounted() {
         calls.push('mixinB mounted')
-      }
+      },
     }
     const Comp = {
       data() {
         return {
-          c: 3
+          c: 3,
         }
       },
       created(this: any) {
@@ -262,7 +262,7 @@ describe('api: createApp', () => {
       },
       render(this: any) {
         return `${this.a}${this.b}${this.c}`
-      }
+      },
     }
 
     const app = createApp(Comp)
@@ -272,10 +272,10 @@ describe('api: createApp', () => {
     app.mixin(mixinA)
     app.mixin(mixinB)
     expect(
-      'Mixin has already been applied to target app'
+      'Mixin has already been applied to target app',
     ).toHaveBeenWarnedTimes(2)
     expect(
-      'Mixin has already been applied to target app: mixinB'
+      'Mixin has already been applied to target app: mixinB',
     ).toHaveBeenWarnedTimes(1)
 
     const root = nodeOps.createElement('div')
@@ -288,14 +288,14 @@ describe('api: createApp', () => {
       'comp created',
       'mixinA mounted',
       'mixinB mounted',
-      'comp mounted'
+      'comp mounted',
     ])
   })
 
   test('use', () => {
     const PluginA: Plugin = app => app.provide('foo', 1)
     const PluginB: Plugin = {
-      install: (app, arg1, arg2) => app.provide('bar', arg1 + arg2)
+      install: (app, arg1, arg2) => app.provide('bar', arg1 + arg2),
     }
     class PluginC {
       someProperty = {}
@@ -310,7 +310,7 @@ describe('api: createApp', () => {
         const foo = inject('foo')
         const bar = inject('bar')
         return () => `${foo},${bar}`
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -324,13 +324,13 @@ describe('api: createApp', () => {
 
     app.use(PluginA)
     expect(
-      `Plugin has already been applied to target app`
+      `Plugin has already been applied to target app`,
     ).toHaveBeenWarnedTimes(1)
 
     app.use(PluginD)
     expect(
       `A plugin must either be a function or an object with an "install" ` +
-        `function.`
+        `function.`,
     ).toHaveBeenWarnedTimes(1)
   })
 
@@ -348,12 +348,12 @@ describe('api: createApp', () => {
       setup() {
         const count = ref(0)
         return {
-          count
+          count,
         }
       },
       render() {
         throw error
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -374,7 +374,7 @@ describe('api: createApp', () => {
       name: 'Hello',
       setup() {
         ctx = getCurrentInstance()
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -391,80 +391,80 @@ describe('api: createApp', () => {
         name: 'div',
         render() {
           return null
-        }
+        },
       }
 
       const app = createApp(Root)
 
       Object.defineProperty(app.config, 'isNativeTag', {
         value: isNativeTag,
-        writable: false
+        writable: false,
       })
 
       app.mount(nodeOps.createElement('div'))
       expect(
-        `Do not use built-in or reserved HTML elements as component id: div`
+        `Do not use built-in or reserved HTML elements as component id: div`,
       ).toHaveBeenWarned()
     })
 
     test('Component.components', () => {
       const Root = {
         components: {
-          div: () => 'div'
+          div: () => 'div',
         },
         render() {
           return null
-        }
+        },
       }
 
       const app = createApp(Root)
       Object.defineProperty(app.config, 'isNativeTag', {
         value: isNativeTag,
-        writable: false
+        writable: false,
       })
 
       app.mount(nodeOps.createElement('div'))
       expect(
-        `Do not use built-in or reserved HTML elements as component id: div`
+        `Do not use built-in or reserved HTML elements as component id: div`,
       ).toHaveBeenWarned()
     })
 
     test('Component.directives', () => {
       const Root = {
         directives: {
-          bind: () => {}
+          bind: () => {},
         },
         render() {
           return null
-        }
+        },
       }
 
       const app = createApp(Root)
       Object.defineProperty(app.config, 'isNativeTag', {
         value: isNativeTag,
-        writable: false
+        writable: false,
       })
 
       app.mount(nodeOps.createElement('div'))
       expect(
-        `Do not use built-in directive ids as custom directive id: bind`
+        `Do not use built-in directive ids as custom directive id: bind`,
       ).toHaveBeenWarned()
     })
 
     test('register using app.component', () => {
       const app = createApp({
-        render() {}
+        render() {},
       })
 
       Object.defineProperty(app.config, 'isNativeTag', {
         value: isNativeTag,
-        writable: false
+        writable: false,
       })
 
       app.component('div', () => 'div')
       app.mount(nodeOps.createElement('div'))
       expect(
-        `Do not use built-in or reserved HTML elements as component id: div`
+        `Do not use built-in or reserved HTML elements as component id: div`,
       ).toHaveBeenWarned()
     })
   })
@@ -478,12 +478,12 @@ describe('api: createApp', () => {
       foo: 'local',
       beforeCreate() {
         merged = this.$options.foo
-      }
+      },
     })
 
     const app = createApp(App)
     app.mixin({
-      foo: 'global'
+      foo: 'global',
     })
     app.config.optionMergeStrategies.foo = (a, b) => (a ? `${a},` : ``) + b
 
@@ -495,7 +495,7 @@ describe('api: createApp', () => {
     const app = createApp({
       render() {
         return this.foo
-      }
+      },
     })
     app.config.globalProperties.foo = 'hello'
     const root = nodeOps.createElement('div')
@@ -507,21 +507,21 @@ describe('api: createApp', () => {
     const Comp = defineComponent({
       setup() {
         return {
-          _: ref(0) // return property "_" should not overwrite "ctx._"
+          _: ref(0), // return property "_" should not overwrite "ctx._"
         }
       },
       render() {
         return h('input', {
-          ref: 'input'
+          ref: 'input',
         })
-      }
+      },
     })
 
     const root1 = nodeOps.createElement('div')
     createApp(Comp).mount(root1)
 
     expect(
-      `setup() return property "_" should not start with "$" or "_" which are reserved prefixes for Vue internals.`
+      `setup() return property "_" should not start with "$" or "_" which are reserved prefixes for Vue internals.`,
     ).toHaveBeenWarned()
   })
 
@@ -530,14 +530,14 @@ describe('api: createApp', () => {
       setup() {
         return {
           _: ref(0), // return property "_" should not overwrite "ctx._"
-          __isScriptSetup: true // mock __isScriptSetup = true
+          __isScriptSetup: true, // mock __isScriptSetup = true
         }
       },
       render() {
         return h('input', {
-          ref: 'input'
+          ref: 'input',
         })
-      }
+      },
     })
 
     const root1 = nodeOps.createElement('div')
@@ -547,7 +547,7 @@ describe('api: createApp', () => {
     app.$refs.input
 
     expect(
-      `TypeError: Cannot read property '__isScriptSetup' of undefined`
+      `TypeError: Cannot read property '__isScriptSetup' of undefined`,
     ).not.toHaveBeenWarned()
   })
 
index b912db00521d9e48650ae582cd5eb463fb3a12b8..d2e4250709609ffaf667905c5c8d1a53a80e0377 100644 (file)
@@ -8,20 +8,20 @@ describe('api: expose', () => {
       setup(_, { expose }) {
         expose({
           foo: 1,
-          bar: ref(2)
+          bar: ref(2),
         })
         return {
           bar: ref(3),
-          baz: ref(4)
+          baz: ref(4),
         }
-      }
+      },
     })
 
     const childRef = ref()
     const Parent = {
       setup() {
         return () => h(Child, { ref: childRef })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -36,23 +36,23 @@ describe('api: expose', () => {
       render() {},
       data() {
         return {
-          foo: 1
+          foo: 1,
         }
       },
       setup() {
         return {
           bar: ref(2),
-          baz: ref(3)
+          baz: ref(3),
         }
       },
-      expose: ['foo', 'bar']
+      expose: ['foo', 'bar'],
     })
 
     const childRef = ref()
     const Parent = {
       setup() {
         return () => h(Child, { ref: childRef })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -68,25 +68,25 @@ describe('api: expose', () => {
       expose: ['foo'],
       data() {
         return {
-          foo: 1
+          foo: 1,
         }
       },
       setup(_, { expose }) {
         expose({
-          bar: ref(2)
+          bar: ref(2),
         })
         return {
           bar: ref(3),
-          baz: ref(4)
+          baz: ref(4),
         }
-      }
+      },
     })
 
     const childRef = ref()
     const Parent = {
       setup() {
         return () => h(Child, { ref: childRef })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -102,16 +102,16 @@ describe('api: expose', () => {
       expose: [],
       data() {
         return {
-          foo: 1
+          foo: 1,
         }
-      }
+      },
     })
 
     const childRef = ref()
     const Parent = {
       setup() {
         return () => h(Child, { ref: childRef })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -125,16 +125,16 @@ describe('api: expose', () => {
       expose: [],
       setup(_, { expose }) {
         expose({
-          foo: 1
+          foo: 1,
         })
-      }
+      },
     })
 
     const childRef = ref()
     const Parent = {
       setup() {
         return () => h(Child, { ref: childRef })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -149,22 +149,22 @@ describe('api: expose', () => {
         expect((this.$parent! as any).bar).toBe(undefined)
         expect((this.$root! as any).foo).toBe(1)
         expect((this.$root! as any).bar).toBe(undefined)
-      }
+      },
     })
 
     const Parent = defineComponent({
       expose: [],
       setup(_, { expose }) {
         expose({
-          foo: 1
+          foo: 1,
         })
         return {
-          bar: 2
+          bar: 2,
         }
       },
       render() {
         return h(Child)
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -174,15 +174,15 @@ describe('api: expose', () => {
     const Component = defineComponent({
       setup(_, { expose }) {
         expose({
-          foo: 1
+          foo: 1,
         })
         return {
-          bar: 2
+          bar: 2,
         }
       },
       render() {
         return h('div')
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     const vm = createApp(Component).mount(root) as any
@@ -194,7 +194,7 @@ describe('api: expose', () => {
     const GrandChild = defineComponent({
       render() {
         return h('div')
-      }
+      },
     })
 
     const grandChildRef = ref()
@@ -204,17 +204,17 @@ describe('api: expose', () => {
       },
       setup(_, { expose }) {
         expose({
-          foo: 42
+          foo: 42,
         })
         return () => h(GrandChild, { ref: grandChildRef })
-      }
+      },
     })
 
     const childRef = ref()
     const Parent = {
       setup() {
         return () => h(Child, { ref: childRef })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
@@ -231,11 +231,11 @@ describe('api: expose', () => {
       setup(_, { expose }) {
         expose(ref(1))
         return () => null
-      }
+      },
     })
     render(h(Comp), nodeOps.createElement('div'))
     expect(
-      'expose() should be passed a plain object, received ref'
+      'expose() should be passed a plain object, received ref',
     ).toHaveBeenWarned()
   })
 
@@ -244,11 +244,11 @@ describe('api: expose', () => {
       setup(_, { expose }) {
         expose(['focus'])
         return () => null
-      }
+      },
     })
     render(h(Comp), nodeOps.createElement('div'))
     expect(
-      'expose() should be passed a plain object, received array'
+      'expose() should be passed a plain object, received array',
     ).toHaveBeenWarned()
   })
 
@@ -257,11 +257,11 @@ describe('api: expose', () => {
       setup(_, { expose }) {
         expose(() => null)
         return () => null
-      }
+      },
     })
     render(h(Comp), nodeOps.createElement('div'))
     expect(
-      'expose() should be passed a plain object, received function'
+      'expose() should be passed a plain object, received function',
     ).toHaveBeenWarned()
   })
 })
index a7aae7ebfa9853e4ab767788a509369e048bbb96..485e688b1ae859cd64f50eb73464edcd31a3affd 100644 (file)
@@ -1,17 +1,17 @@
 import {
+  type InjectionKey,
+  type Ref,
+  defineComponent,
   h,
-  provide,
+  hasInjectionContext,
   inject,
-  InjectionKey,
-  ref,
   nextTick,
-  Ref,
-  readonly,
+  provide,
   reactive,
-  defineComponent,
-  hasInjectionContext
+  readonly,
+  ref,
 } from '../src/index'
-import { render, nodeOps, serialize, createApp } from '@vue/runtime-test'
+import { createApp, nodeOps, render, serialize } from '@vue/runtime-test'
 
 // reference: https://vue-composition-api-rfc.netlify.com/api.html#provide-inject
 describe('api: provide/inject', () => {
@@ -20,18 +20,18 @@ describe('api: provide/inject', () => {
       setup() {
         provide('foo', 1)
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
       setup() {
         const foo = inject('foo')
         return () => foo
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -47,18 +47,18 @@ describe('api: provide/inject', () => {
       setup() {
         provide(key, 1)
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
       setup() {
         const foo = inject(key) || 1
         return () => foo + 1
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -71,11 +71,11 @@ describe('api: provide/inject', () => {
       setup() {
         provide('foo', 'foo')
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
@@ -85,7 +85,7 @@ describe('api: provide/inject', () => {
         // default value should be used if value is not provided
         const bar = inject('bar', 'bar')
         return () => foo + bar
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -97,7 +97,7 @@ describe('api: provide/inject', () => {
     const Provider = {
       setup() {
         return () => h(Consumer)
-      }
+      },
     }
 
     const Consumer = defineComponent({
@@ -107,13 +107,12 @@ describe('api: provide/inject', () => {
           from: 'foo',
           default() {
             return this!.$options.name
-          }
-        }
+          },
+        },
       },
       render() {
-        // @ts-ignore
         return this.foo
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -127,7 +126,7 @@ describe('api: provide/inject', () => {
         provide('foo', 'foo')
         provide('bar', 'bar')
         return () => h(ProviderTwo)
-      }
+      },
     }
 
     const ProviderTwo = {
@@ -136,7 +135,7 @@ describe('api: provide/inject', () => {
         provide('foo', 'fooOverride')
         provide('baz', 'baz')
         return () => h(Consumer)
-      }
+      },
     }
 
     const Consumer = {
@@ -145,7 +144,7 @@ describe('api: provide/inject', () => {
         const bar = inject('bar')
         const baz = inject('baz')
         return () => [foo, bar, baz].join(',')
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -160,18 +159,18 @@ describe('api: provide/inject', () => {
       setup() {
         provide('count', count)
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
       setup() {
         const count = inject<Ref<number>>('count')!
         return () => count.value
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -190,11 +189,11 @@ describe('api: provide/inject', () => {
       setup() {
         provide('count', readonly(count))
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
@@ -203,7 +202,7 @@ describe('api: provide/inject', () => {
         // should not work
         count.value++
         return () => count.value
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -211,7 +210,7 @@ describe('api: provide/inject', () => {
     expect(serialize(root)).toBe(`<div>1</div>`)
 
     expect(
-      `Set operation on key "value" failed: target is readonly`
+      `Set operation on key "value" failed: target is readonly`,
     ).toHaveBeenWarned()
 
     // source mutation should still work
@@ -227,18 +226,18 @@ describe('api: provide/inject', () => {
       setup() {
         provide('state', rootState)
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
       setup() {
         const state = inject<typeof rootState>('state')!
         return () => state.count
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -257,11 +256,11 @@ describe('api: provide/inject', () => {
       setup() {
         provide('state', readonly(rootState))
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
@@ -270,7 +269,7 @@ describe('api: provide/inject', () => {
         // should not work
         state.count++
         return () => state.count
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -278,7 +277,7 @@ describe('api: provide/inject', () => {
     expect(serialize(root)).toBe(`<div>1</div>`)
 
     expect(
-      `Set operation on key "count" failed: target is readonly`
+      `Set operation on key "count" failed: target is readonly`,
     ).toHaveBeenWarned()
 
     rootState.count++
@@ -290,11 +289,11 @@ describe('api: provide/inject', () => {
     const Provider = {
       setup() {
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
@@ -302,7 +301,7 @@ describe('api: provide/inject', () => {
         const foo = inject('foo')
         expect(foo).toBeUndefined()
         return () => foo
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -315,18 +314,18 @@ describe('api: provide/inject', () => {
     const Provider = {
       setup() {
         return () => h(Middle)
-      }
+      },
     }
 
     const Middle = {
-      render: () => h(Consumer)
+      render: () => h(Consumer),
     }
 
     const Consumer = {
       setup() {
         const foo = inject('foo', undefined)
         return () => foo
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -341,7 +340,7 @@ describe('api: provide/inject', () => {
         provide('foo', 'foo')
         const injection = inject('foo', null)
         return () => injection
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -360,7 +359,7 @@ describe('api: provide/inject', () => {
         setup() {
           expect(hasInjectionContext()).toBe(true)
           return () => null
-        }
+        },
       }
 
       const root = nodeOps.createElement('div')
index b61632ae3fec4a23feb32e8ab18b22f8463f3ef8..5da57ab32bf9f35baa699f87c3f41c142ea6dd3f 100644 (file)
@@ -1,22 +1,26 @@
 import {
-  onBeforeMount,
+  TrackOpTypes,
   h,
-  nodeOps,
-  render,
-  serializeInner,
-  onMounted,
-  ref,
-  onBeforeUpdate,
   nextTick,
-  onUpdated,
+  nodeOps,
+  onBeforeMount,
   onBeforeUnmount,
-  onUnmounted,
+  onBeforeUpdate,
+  onMounted,
   onRenderTracked,
+  onRenderTriggered,
+  onUnmounted,
+  onUpdated,
   reactive,
-  TrackOpTypes,
-  onRenderTriggered
+  ref,
+  render,
+  serializeInner,
 } from '@vue/runtime-test'
-import { ITERATE_KEY, DebuggerEvent, TriggerOpTypes } from '@vue/reactivity'
+import {
+  type DebuggerEvent,
+  ITERATE_KEY,
+  TriggerOpTypes,
+} from '@vue/reactivity'
 
 // reference: https://vue-composition-api-rfc.netlify.com/api.html#lifecycle-hooks
 
@@ -32,7 +36,7 @@ describe('api: lifecycle hooks', () => {
       setup() {
         onBeforeMount(fn)
         return () => h('div')
-      }
+      },
     }
     render(h(Comp), root)
     expect(fn).toHaveBeenCalledTimes(1)
@@ -49,7 +53,7 @@ describe('api: lifecycle hooks', () => {
       setup() {
         onMounted(fn)
         return () => h('div')
-      }
+      },
     }
     render(h(Comp), root)
     expect(fn).toHaveBeenCalledTimes(1)
@@ -67,7 +71,7 @@ describe('api: lifecycle hooks', () => {
       setup() {
         onBeforeUpdate(fn)
         return () => h('div', count.value)
-      }
+      },
     }
     render(h(Comp), root)
 
@@ -94,7 +98,7 @@ describe('api: lifecycle hooks', () => {
           renderSpy()
           return h('div', count.value)
         }
-      }
+      },
     }
     render(h(Comp), root)
     expect(renderSpy).toHaveBeenCalledTimes(1)
@@ -118,7 +122,7 @@ describe('api: lifecycle hooks', () => {
       setup() {
         onUpdated(fn)
         return () => h('div', count.value)
-      }
+      },
     }
     render(h(Comp), root)
 
@@ -138,14 +142,14 @@ describe('api: lifecycle hooks', () => {
     const Comp = {
       setup() {
         return () => (toggle.value ? h(Child) : null)
-      }
+      },
     }
 
     const Child = {
       setup() {
         onBeforeUnmount(fn)
         return () => h('div')
-      }
+      },
     }
 
     render(h(Comp), root)
@@ -166,14 +170,14 @@ describe('api: lifecycle hooks', () => {
     const Comp = {
       setup() {
         return () => (toggle.value ? h(Child) : null)
-      }
+      },
     }
 
     const Child = {
       setup() {
         onUnmounted(fn)
         return () => h('div')
-      }
+      },
     }
 
     render(h(Comp), root)
@@ -194,7 +198,7 @@ describe('api: lifecycle hooks', () => {
     const Comp = {
       setup() {
         return () => (toggle.value ? h(Child) : null)
-      }
+      },
     }
 
     const Child = {
@@ -203,7 +207,7 @@ describe('api: lifecycle hooks', () => {
           onBeforeUnmount(fn)
         })
         return () => h('div')
-      }
+      },
     }
 
     render(h(Comp), root)
@@ -227,7 +231,7 @@ describe('api: lifecycle hooks', () => {
         onBeforeUnmount(() => calls.push('root onBeforeUnmount'))
         onUnmounted(() => calls.push('root onUnmounted'))
         return () => h(Mid, { count: count.value })
-      }
+      },
     }
 
     const Mid = {
@@ -240,7 +244,7 @@ describe('api: lifecycle hooks', () => {
         onBeforeUnmount(() => calls.push('mid onBeforeUnmount'))
         onUnmounted(() => calls.push('mid onUnmounted'))
         return () => h(Child, { count: props.count })
-      }
+      },
     }
 
     const Child = {
@@ -253,7 +257,7 @@ describe('api: lifecycle hooks', () => {
         onBeforeUnmount(() => calls.push('child onBeforeUnmount'))
         onUnmounted(() => calls.push('child onUnmounted'))
         return () => h('div', props.count)
-      }
+      },
     }
 
     // mount
@@ -264,7 +268,7 @@ describe('api: lifecycle hooks', () => {
       'child onBeforeMount',
       'child onMounted',
       'mid onMounted',
-      'root onMounted'
+      'root onMounted',
     ])
 
     calls.length = 0
@@ -278,7 +282,7 @@ describe('api: lifecycle hooks', () => {
       'child onBeforeUpdate',
       'child onUpdated',
       'mid onUpdated',
-      'root onUpdated'
+      'root onUpdated',
     ])
 
     calls.length = 0
@@ -291,7 +295,7 @@ describe('api: lifecycle hooks', () => {
       'child onBeforeUnmount',
       'child onUnmounted',
       'mid onUnmounted',
-      'root onUnmounted'
+      'root onUnmounted',
     ])
   })
 
@@ -307,7 +311,7 @@ describe('api: lifecycle hooks', () => {
         onRenderTracked(onTrack)
         return () =>
           h('div', [obj.foo, 'bar' in obj, Object.keys(obj).join('')])
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -316,18 +320,18 @@ describe('api: lifecycle hooks', () => {
       {
         target: obj,
         type: TrackOpTypes.GET,
-        key: 'foo'
+        key: 'foo',
       },
       {
         target: obj,
         type: TrackOpTypes.HAS,
-        key: 'bar'
+        key: 'bar',
       },
       {
         target: obj,
         type: TrackOpTypes.ITERATE,
-        key: ITERATE_KEY
-      }
+        key: ITERATE_KEY,
+      },
     ])
   })
 
@@ -346,7 +350,7 @@ describe('api: lifecycle hooks', () => {
         onRenderTriggered(onTrigger)
         return () =>
           h('div', [obj.foo, 'bar' in obj, Object.keys(obj).join('')])
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -358,7 +362,7 @@ describe('api: lifecycle hooks', () => {
       type: TriggerOpTypes.SET,
       key: 'foo',
       oldValue: 1,
-      newValue: 2
+      newValue: 2,
     })
 
     delete obj.bar
@@ -367,7 +371,7 @@ describe('api: lifecycle hooks', () => {
     expect(events[1]).toMatchObject({
       type: TriggerOpTypes.DELETE,
       key: 'bar',
-      oldValue: 2
+      oldValue: 2,
     })
     ;(obj as any).baz = 3
     await nextTick()
@@ -375,7 +379,7 @@ describe('api: lifecycle hooks', () => {
     expect(events[2]).toMatchObject({
       type: TriggerOpTypes.ADD,
       key: 'baz',
-      newValue: 3
+      newValue: 3,
     })
   })
 
@@ -385,14 +389,14 @@ describe('api: lifecycle hooks', () => {
     const Comp = {
       setup() {
         return () => (toggle.value ? [h(Child), h(Child)] : null)
-      }
+      },
     }
     const Child = {
       setup() {
         onMounted(fn)
         onBeforeUnmount(fn)
         return () => h('div')
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
index 94f9db1b028dd1ce045c1c40325b82cc587139f3..521b359e22d67537f7b3d7e0ba68d0c6e1c6c4df 100644 (file)
@@ -1,20 +1,20 @@
 /**
  * @vitest-environment jsdom
  */
-import { type Mock } from 'vitest'
+import type { Mock } from 'vitest'
 import {
+  type TestElement,
+  computed,
+  createApp,
+  defineComponent,
   h,
+  nextTick,
   nodeOps,
+  ref,
   render,
+  renderToString,
   serializeInner,
   triggerEvent,
-  TestElement,
-  nextTick,
-  renderToString,
-  ref,
-  defineComponent,
-  createApp,
-  computed
 } from '@vue/runtime-test'
 import { render as domRender } from 'vue'
 
@@ -23,7 +23,7 @@ describe('api: options', () => {
     const Comp = defineComponent({
       data() {
         return {
-          foo: 1
+          foo: 1,
         }
       },
       render() {
@@ -32,11 +32,11 @@ describe('api: options', () => {
           {
             onClick: () => {
               this.foo++
-            }
+            },
           },
-          this.foo
+          this.foo,
         )
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -51,14 +51,14 @@ describe('api: options', () => {
     const Comp = defineComponent({
       data() {
         return {
-          foo: 1
+          foo: 1,
         }
       },
       computed: {
         bar(): number {
           return this.foo + 1
         },
-        baz: (vm: any): number => vm.bar + 1
+        baz: (vm: any): number => vm.bar + 1,
       },
       render() {
         return h(
@@ -66,11 +66,11 @@ describe('api: options', () => {
           {
             onClick: () => {
               this.foo++
-            }
+            },
           },
-          this.bar + this.baz
+          this.bar + this.baz,
         )
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -87,7 +87,7 @@ describe('api: options', () => {
         // #3300 method on ctx should be overwritable
         this.incBy = this.incBy.bind(this, 2)
         return {
-          foo: 1
+          foo: 1,
         }
       },
       methods: {
@@ -96,18 +96,18 @@ describe('api: options', () => {
         },
         incBy(n = 0) {
           this.foo += n
-        }
+        },
       },
       render() {
         return h(
           'div',
           {
             onClick: this.inc,
-            onFoo: this.incBy
+            onFoo: this.incBy,
           },
-          this.foo
+          this.foo,
         )
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -127,11 +127,11 @@ describe('api: options', () => {
       methods: {
         foo() {
           return 'foo'
-        }
+        },
       },
       render() {
         return this.foo()
-      }
+      },
     })
     app.config.globalProperties.foo = () => 'bar'
 
@@ -157,12 +157,12 @@ describe('api: options', () => {
           foo: 1,
           bar: 2,
           baz: {
-            qux: 3
+            qux: 3,
           },
           qux: 4,
           dot: {
-            path: 5
-          }
+            path: 5,
+          },
         }
       },
       watch: {
@@ -172,20 +172,20 @@ describe('api: options', () => {
         bar: spyB,
         baz: {
           handler: spyC,
-          deep: true
+          deep: true,
         },
         qux: {
-          handler: 'onQuxChange'
+          handler: 'onQuxChange',
         },
-        'dot.path': spyE
+        'dot.path': spyE,
       },
       methods: {
         onFooChange: spyA,
-        onQuxChange: spyD
+        onQuxChange: spyD,
       },
       render() {
         ctx = this
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -237,8 +237,8 @@ describe('api: options', () => {
           foo: 1,
           bar: 2,
           baz: {
-            qux: 3
-          }
+            qux: 3,
+          },
         }
       },
       watch: {
@@ -249,16 +249,16 @@ describe('api: options', () => {
         baz: [
           {
             handler: spyC,
-            deep: true
-          }
-        ]
+            deep: true,
+          },
+        ],
       },
       methods: {
-        onFooChange: spyA
+        onFooChange: spyA,
       },
       render() {
         ctx = this
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -290,32 +290,32 @@ describe('api: options', () => {
     const mixinA = {
       data() {
         return {
-          fromMixinA: ''
+          fromMixinA: '',
         }
       },
       watch: {
         obj: {
           handler(this: any, to: any) {
             this.fromMixinA = to
-          }
-        }
-      }
+          },
+        },
+      },
     }
 
     const mixinB = {
       data() {
         return {
-          fromMixinB: ''
+          fromMixinB: '',
         }
       },
       watch: {
-        obj: 'setMixinB'
+        obj: 'setMixinB',
       },
       methods: {
         setMixinB(this: any, to: any) {
           this.fromMixinB = to
-        }
-      }
+        },
+      },
     }
 
     let vm: any
@@ -324,16 +324,16 @@ describe('api: options', () => {
       mixins: [mixinA, mixinB],
       data: () => ({
         obj: 'foo',
-        fromComp: ''
+        fromComp: '',
       }),
       watch: {
         obj(this: any, to: any) {
           this.fromComp = to
-        }
+        },
       },
       mounted() {
         vm = this
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -351,13 +351,13 @@ describe('api: options', () => {
     const Root = defineComponent({
       data() {
         return {
-          a: 1
+          a: 1,
         }
       },
       provide() {
         return {
           a: this.a,
-          [symbolKey]: 2
+          [symbolKey]: 2,
         }
       },
       render() {
@@ -371,9 +371,9 @@ describe('api: options', () => {
           h(ChildG),
           h(ChildH),
           h(ChildI),
-          h(ChildJ)
+          h(ChildJ),
         ]
-      }
+      },
     })
 
     const defineChild = (injectOptions: any, injectedKey = 'b') =>
@@ -381,53 +381,53 @@ describe('api: options', () => {
         inject: injectOptions,
         render() {
           return this[injectedKey]
-        }
+        },
       }) as any
 
     const ChildA = defineChild(['a'], 'a')
     const ChildB = defineChild({ b: 'a' })
     const ChildC = defineChild({
       b: {
-        from: 'a'
-      }
+        from: 'a',
+      },
     })
     const ChildD = defineChild(
       {
         a: {
-          default: () => 0
-        }
+          default: () => 0,
+        },
       },
-      'a'
+      'a',
     )
     const ChildE = defineChild({
       b: {
         from: 'c',
-        default: 2
-      }
+        default: 2,
+      },
     })
     const ChildF = defineChild({
       b: {
         from: 'c',
-        default: () => 3
-      }
+        default: () => 3,
+      },
     })
     const ChildG = defineChild({
       b: {
-        default: 4
-      }
+        default: 4,
+      },
     })
     const ChildH = defineChild({
       b: {
-        default: () => 5
-      }
+        default: () => 5,
+      },
     })
     const ChildI = defineChild({
-      b: symbolKey
+      b: symbolKey,
     })
     const ChildJ = defineChild({
       b: {
-        from: symbolKey
-      }
+        from: symbolKey,
+      },
     })
     expect(renderToString(h(Root))).toBe(`1111234522`)
   })
@@ -439,16 +439,16 @@ describe('api: options', () => {
       provide() {
         return {
           n,
-          np
+          np,
         }
       },
-      render: () => h(Child)
+      render: () => h(Child),
     })
     const Child = defineComponent({
       inject: ['n', 'np'],
       render(this: any) {
         return this.n + this.np
-      }
+      },
     })
     const app = createApp(Parent)
     const root = nodeOps.createElement('div')
@@ -464,28 +464,28 @@ describe('api: options', () => {
     const Base = defineComponent({
       data() {
         return {
-          a: 1
+          a: 1,
         }
       },
       provide() {
         return {
-          a: this.a
+          a: this.a,
         }
-      }
+      },
     })
 
     const Child = {
       inject: ['a'],
       render() {
         return (this as any).a
-      }
+      },
     }
 
     const Root = defineComponent({
       extends: Base,
       render() {
         return h(Child)
-      }
+      },
     })
     expect(renderToString(h(Root))).toBe(`1`)
   })
@@ -522,7 +522,7 @@ describe('api: options', () => {
       },
       render() {
         return h(Mid, { count: count.value })
-      }
+      },
     }
 
     const Mid = {
@@ -552,7 +552,7 @@ describe('api: options', () => {
       },
       render(this: any) {
         return h(Child, { count: this.$props.count })
-      }
+      },
     }
 
     const Child = {
@@ -582,7 +582,7 @@ describe('api: options', () => {
       },
       render(this: any) {
         return h('div', this.$props.count)
-      }
+      },
     }
 
     // mount
@@ -599,7 +599,7 @@ describe('api: options', () => {
       'child onBeforeMount',
       'child onMounted',
       'mid onMounted',
-      'root onMounted'
+      'root onMounted',
     ])
 
     calls.length = 0
@@ -613,7 +613,7 @@ describe('api: options', () => {
       'child onBeforeUpdate',
       'child onUpdated',
       'mid onUpdated',
-      'root onUpdated'
+      'root onUpdated',
     ])
 
     calls.length = 0
@@ -626,7 +626,7 @@ describe('api: options', () => {
       'child onBeforeUnmount',
       'child onUnmounted',
       'mid onUnmounted',
-      'root onUnmounted'
+      'root onUnmounted',
     ])
   })
 
@@ -635,7 +635,7 @@ describe('api: options', () => {
     const mixinA = defineComponent({
       data() {
         return {
-          a: 1
+          a: 1,
         }
       },
       created(this: any) {
@@ -646,17 +646,17 @@ describe('api: options', () => {
       },
       mounted() {
         calls.push('mixinA mounted')
-      }
+      },
     })
     const mixinB = defineComponent({
       props: {
         bP: {
-          type: String
-        }
+          type: String,
+        },
       },
       data() {
         return {
-          b: 2
+          b: 2,
         }
       },
       created(this: any) {
@@ -669,13 +669,13 @@ describe('api: options', () => {
       },
       mounted() {
         calls.push('mixinB mounted')
-      }
+      },
     })
     const mixinC = defineComponent({
       props: ['cP1', 'cP2'],
       data() {
         return {
-          c: 3
+          c: 3,
         }
       },
       created() {
@@ -686,17 +686,17 @@ describe('api: options', () => {
       },
       mounted() {
         calls.push('mixinC mounted')
-      }
+      },
     })
     const Comp = defineComponent({
       props: {
-        aaa: String
+        aaa: String,
       },
       mixins: [mixinA, mixinB, mixinC],
       data() {
         return {
           c: 4,
-          z: 4
+          z: 4,
         }
       },
       created() {
@@ -713,7 +713,7 @@ describe('api: options', () => {
       },
       render() {
         return `${this.a}${this.b}${this.c}`
-      }
+      },
     })
     expect(renderToString(h(Comp))).toBe(`124`)
     expect(calls).toEqual([
@@ -724,7 +724,7 @@ describe('api: options', () => {
       'mixinA mounted',
       'mixinB mounted',
       'mixinC mounted',
-      'comp mounted'
+      'comp mounted',
     ])
   })
 
@@ -732,9 +732,9 @@ describe('api: options', () => {
     const Comp = {
       mixins: [
         {
-          render: () => 'from mixin'
-        }
-      ]
+          render: () => 'from mixin',
+        },
+      ],
     }
     expect(renderToString(h(Comp))).toBe('from mixin')
   })
@@ -747,7 +747,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('mixinA created')
-      }
+      },
     }
 
     const extendA = {
@@ -757,7 +757,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('extendA created')
-      }
+      },
     }
 
     const Comp = {
@@ -768,7 +768,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('self created')
-      }
+      },
     }
 
     expect(renderToString(h(Comp))).toBe(`123`)
@@ -778,23 +778,23 @@ describe('api: options', () => {
       'self beforeCreate',
       'mixinA created',
       'extendA created',
-      'self created'
+      'self created',
     ])
   })
 
   test('unlikely mixin usage', () => {
     const MixinA = {
-      data() {}
+      data() {},
     }
     const MixinB = {
-      data() {}
+      data() {},
     }
     defineComponent({
       // @ts-expect-error edge case after #7963, unlikely to happen in practice
       // since the user will want to type the mixins themselves.
       mixins: [defineComponent(MixinA), defineComponent(MixinB)],
       // @ts-expect-error
-      data() {}
+      data() {},
     })
   })
 
@@ -807,7 +807,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('extendA created')
-      }
+      },
     }
 
     const mixinA = {
@@ -817,7 +817,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('mixinA created')
-      }
+      },
     }
 
     const Comp = {
@@ -828,7 +828,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('self created')
-      }
+      },
     }
 
     expect(renderToString(h(Comp))).toBe(`123`)
@@ -838,7 +838,7 @@ describe('api: options', () => {
       'self beforeCreate',
       'extendA created',
       'mixinA created',
-      'self created'
+      'self created',
     ])
   })
 
@@ -848,23 +848,23 @@ describe('api: options', () => {
       data() {
         return {
           a: 1,
-          b: 1
+          b: 1,
         }
       },
       methods: {
-        sayA() {}
+        sayA() {},
       },
       mounted(this: any) {
         expect(this.a).toBe(1)
         expect(this.b).toBe(2)
         calls.push('base')
-      }
+      },
     })
     const Comp = defineComponent({
       extends: Base,
       data() {
         return {
-          b: 2
+          b: 2,
         }
       },
       mounted() {
@@ -872,7 +872,7 @@ describe('api: options', () => {
       },
       render() {
         return `${this.a}${this.b}`
-      }
+      },
     })
 
     expect(renderToString(h(Comp))).toBe(`12`)
@@ -885,24 +885,24 @@ describe('api: options', () => {
       data() {
         return {
           a: 1,
-          x: 'base'
+          x: 'base',
         }
       },
       methods: {
-        sayA() {}
+        sayA() {},
       },
       mounted(this: any) {
         expect(this.a).toBe(1)
         expect(this.b).toBeTruthy()
         expect(this.c).toBe(2)
         calls.push('base')
-      }
+      },
     })
     const Mixin = defineComponent({
       data() {
         return {
           b: true,
-          x: 'mixin'
+          x: 'mixin',
         }
       },
       mounted(this: any) {
@@ -910,14 +910,14 @@ describe('api: options', () => {
         expect(this.b).toBeTruthy()
         expect(this.c).toBe(2)
         calls.push('mixin')
-      }
+      },
     })
     const Comp = defineComponent({
       extends: Base,
       mixins: [Mixin],
       data() {
         return {
-          c: 2
+          c: 2,
         }
       },
       mounted() {
@@ -925,7 +925,7 @@ describe('api: options', () => {
       },
       render() {
         return `${this.a}${this.b}${this.c}${this.x}`
-      }
+      },
     })
 
     expect(renderToString(h(Comp))).toBe(`1true2mixin`)
@@ -940,7 +940,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('createdA')
-      }
+      },
     }
     const BaseB = {
       extends: BaseA,
@@ -949,7 +949,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('createdB')
-      }
+      },
     }
 
     const MixinA = {
@@ -958,7 +958,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('createdC')
-      }
+      },
     }
     const MixinB = {
       mixins: [MixinA],
@@ -967,7 +967,7 @@ describe('api: options', () => {
       },
       created() {
         calls.push('createdD')
-      }
+      },
     }
 
     const Comp = {
@@ -979,7 +979,7 @@ describe('api: options', () => {
       created() {
         calls.push('selfCreated')
       },
-      render() {}
+      render() {},
     }
 
     renderToString(h(Comp))
@@ -993,29 +993,29 @@ describe('api: options', () => {
       'createdB',
       'createdC',
       'createdD',
-      'selfCreated'
+      'selfCreated',
     ])
   })
 
   test('flatten merged options', async () => {
     const MixinBase = {
-      msg1: 'base'
+      msg1: 'base',
     }
     const ExtendsBase = {
-      msg2: 'base'
+      msg2: 'base',
     }
     const Mixin = {
-      mixins: [MixinBase]
+      mixins: [MixinBase],
     }
     const Extends = {
-      extends: ExtendsBase
+      extends: ExtendsBase,
     }
     const Comp = defineComponent({
       extends: defineComponent(Extends),
       mixins: [defineComponent(Mixin)],
       render() {
         return `${this.$options.msg1},${this.$options.msg2}`
-      }
+      },
     })
 
     expect(renderToString(h(Comp))).toBe('base,base')
@@ -1024,8 +1024,8 @@ describe('api: options', () => {
   test('extends template', () => {
     const Comp = {
       extends: {
-        template: `<h1>Foo</h1>`
-      }
+        template: `<h1>Foo</h1>`,
+      },
     }
 
     const root = document.createElement('div') as any
@@ -1035,10 +1035,10 @@ describe('api: options', () => {
 
   test('options defined in component have higher priority', async () => {
     const Mixin = {
-      msg1: 'base'
+      msg1: 'base',
     }
     const Extends = {
-      msg2: 'base'
+      msg2: 'base',
     }
     const Comp = defineComponent({
       msg1: 'local',
@@ -1047,7 +1047,7 @@ describe('api: options', () => {
       mixins: [defineComponent(Mixin)],
       render() {
         return `${this.$options.msg1},${this.$options.msg2}`
-      }
+      },
     })
 
     expect(renderToString(h(Comp))).toBe('local,local')
@@ -1057,33 +1057,33 @@ describe('api: options', () => {
     const Comp = defineComponent({
       setup() {
         return {
-          count: ref(0)
+          count: ref(0),
         }
       },
       data() {
         return {
-          plusOne: (this as any).count + 1
+          plusOne: (this as any).count + 1,
         }
       },
       computed: {
         plusTwo(): number {
           return this.count + 2
-        }
+        },
       },
       methods: {
         inc() {
           this.count++
-        }
+        },
       },
       render() {
         return h(
           'div',
           {
-            onClick: this.inc
+            onClick: this.inc,
           },
-          `${this.count},${this.plusOne},${this.plusTwo}`
+          `${this.count},${this.plusOne},${this.plusTwo}`,
         )
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -1099,26 +1099,26 @@ describe('api: options', () => {
     const mixin1 = {
       data() {
         return {
-          mixin1Data: 'mixin1'
+          mixin1Data: 'mixin1',
         }
       },
-      methods: {}
+      methods: {},
     }
 
     const watchSpy = vi.fn()
     const mixin2 = {
       watch: {
-        mixin3Data: watchSpy
-      }
+        mixin3Data: watchSpy,
+      },
     }
 
     const mixin3 = {
       data() {
         return {
-          mixin3Data: 'mixin3'
+          mixin3Data: 'mixin3',
         }
       },
-      methods: {}
+      methods: {},
     }
 
     let vm: any
@@ -1127,7 +1127,7 @@ describe('api: options', () => {
       render() {},
       created() {
         vm = this
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -1142,50 +1142,50 @@ describe('api: options', () => {
   test('injection from closest ancestor', () => {
     const Root = defineComponent({
       provide: {
-        a: 'root'
+        a: 'root',
       },
       render() {
         return [h(Mid), ' ', h(MidWithProvide), ' ', h(MidWithMixinProvide)]
-      }
+      },
     })
 
     const Mid = {
       render() {
         return h(Child)
-      }
+      },
     } as any
 
     const MidWithProvide = {
       provide: {
-        a: 'midWithProvide'
+        a: 'midWithProvide',
       },
       render() {
         return h(Child)
-      }
+      },
     } as any
 
     const mixin = {
       provide: {
-        a: 'midWithMixinProvide'
-      }
+        a: 'midWithMixinProvide',
+      },
     }
 
     const MidWithMixinProvide = {
       mixins: [mixin],
       render() {
         return h(Child)
-      }
+      },
     } as any
 
     const Child = {
       inject: ['a'],
       render() {
         return this.a
-      }
+      },
     } as any
 
     expect(renderToString(h(Root))).toBe(
-      'root midWithProvide midWithMixinProvide'
+      'root midWithProvide midWithMixinProvide',
     )
   })
 
@@ -1194,14 +1194,14 @@ describe('api: options', () => {
       const mixin = {
         data() {
           return { foo: 1, bar: 2 }
-        }
+        },
       }
       createApp({
         mixins: [mixin],
         data() {
           return {
             foo: 3,
-            baz: 4
+            baz: 4,
           }
         },
         created() {
@@ -1209,16 +1209,16 @@ describe('api: options', () => {
           expect(this.$options.data()).toEqual({
             foo: 3,
             bar: 2,
-            baz: 4
+            baz: 4,
           })
         },
-        render: () => null
+        render: () => null,
       }).mount(nodeOps.createElement('div'))
     })
 
     test('this.$options.inject', () => {
       const mixin = {
-        inject: ['a']
+        inject: ['a'],
       }
       const app = createApp({
         mixins: [mixin],
@@ -1231,7 +1231,7 @@ describe('api: options', () => {
           expect(this.b).toBe(2)
           expect(this.c).toBe(3)
         },
-        render: () => null
+        render: () => null,
       })
 
       app.provide('a', 1)
@@ -1243,21 +1243,21 @@ describe('api: options', () => {
     test('this.$options.provide', () => {
       const mixin = {
         provide: {
-          a: 1
-        }
+          a: 1,
+        },
       }
       createApp({
         mixins: [mixin],
         provide() {
           return {
-            b: 2
+            b: 2,
           }
         },
         created() {
           expect(this.$options.provide).toBeInstanceOf(Function)
           expect(this.$options.provide()).toEqual({ a: 1, b: 2 })
         },
-        render: () => null
+        render: () => null,
       }).mount(nodeOps.createElement('div'))
     })
 
@@ -1265,7 +1265,7 @@ describe('api: options', () => {
       const mixin = {
         mounted() {},
         beforeUnmount() {},
-        unmounted() {}
+        unmounted() {},
       }
       createApp({
         mixins: [mixin],
@@ -1280,26 +1280,26 @@ describe('api: options', () => {
           expect(this.$options.unmounted).toBeInstanceOf(Array)
           expect(this.$options.unmounted.length).toBe(2)
         },
-        render: () => null
+        render: () => null,
       }).mount(nodeOps.createElement('div'))
     })
 
     test('this.$options[asset-name]', () => {
       const mixin = {
         components: {
-          a: {}
+          a: {},
         },
         directives: {
-          d1: {}
-        }
+          d1: {},
+        },
       }
       createApp({
         mixins: [mixin],
         components: {
-          b: {}
+          b: {},
         },
         directives: {
-          d2: {}
+          d2: {},
         },
         created() {
           expect('a' in this.$options.components).toBe(true)
@@ -1307,45 +1307,45 @@ describe('api: options', () => {
           expect('d1' in this.$options.directives).toBe(true)
           expect('d2' in this.$options.directives).toBe(true)
         },
-        render: () => null
+        render: () => null,
       }).mount(nodeOps.createElement('div'))
     })
 
     test('this.$options.methods', () => {
       const mixin = {
         methods: {
-          fn1() {}
-        }
+          fn1() {},
+        },
       }
       createApp({
         mixins: [mixin],
         methods: {
-          fn2() {}
+          fn2() {},
         },
         created() {
           expect(this.$options.methods.fn1).toBeInstanceOf(Function)
           expect(this.$options.methods.fn2).toBeInstanceOf(Function)
         },
-        render: () => null
+        render: () => null,
       }).mount(nodeOps.createElement('div'))
     })
 
     test('this.$options.computed', () => {
       const mixin = {
         computed: {
-          c1() {}
-        }
+          c1() {},
+        },
       }
       createApp({
         mixins: [mixin],
         computed: {
-          c2() {}
+          c2() {},
         },
         created() {
           expect(this.$options.computed.c1).toBeInstanceOf(Function)
           expect(this.$options.computed.c2).toBeInstanceOf(Function)
         },
-        render: () => null
+        render: () => null,
       }).mount(nodeOps.createElement('div'))
     })
 
@@ -1361,14 +1361,14 @@ describe('api: options', () => {
             this.$options.computed = {}
           }
           this.$options.computed.value = () => count.value
-        }
+        },
       }
       const root = nodeOps.createElement('div')
       createApp({
         mixins: [mixin],
         render(this: any) {
           return this.value
-        }
+        },
       }).mount(root)
 
       expect(serializeInner(root)).toBe('0')
@@ -1385,27 +1385,27 @@ describe('api: options', () => {
         watch: {
           foo: 'notExistingMethod',
           foo2: {
-            handler: 'notExistingMethod2'
-          }
+            handler: 'notExistingMethod2',
+          },
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
 
       expect(
-        'Invalid watch handler specified by key "notExistingMethod"'
+        'Invalid watch handler specified by key "notExistingMethod"',
       ).toHaveBeenWarned()
       expect(
-        'Invalid watch handler specified by key "notExistingMethod2"'
+        'Invalid watch handler specified by key "notExistingMethod2"',
       ).toHaveBeenWarned()
     })
 
     test('Invalid watch option', () => {
       const Comp = {
         watch: { foo: true },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
@@ -1419,10 +1419,10 @@ describe('api: options', () => {
       const Comp = {
         computed: {
           foo: {
-            set() {}
-          }
+            set() {},
+          },
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
@@ -1435,20 +1435,20 @@ describe('api: options', () => {
       const Comp = {
         computed: {
           foo: {
-            get() {}
-          }
+            get() {},
+          },
         },
         mounted() {
           instance = this
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       instance.foo = 1
       expect(
-        'Write operation failed: computed property "foo" is readonly'
+        'Write operation failed: computed property "foo" is readonly',
       ).toHaveBeenWarned()
     })
 
@@ -1456,64 +1456,64 @@ describe('api: options', () => {
       const Comp = {
         data() {
           return {
-            a: 1
+            a: 1,
           }
         },
         provide() {
           return {
-            a: this.a
+            a: this.a,
           }
         },
         render() {
           return [h(ChildA)]
-        }
+        },
       } as any
       const ChildA = {
         props: { a: Number },
         inject: ['a'],
         render() {
           return this.a
-        }
+        },
       } as any
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Inject property "a" is already defined in Props.`
+        `Inject property "a" is already defined in Props.`,
       ).toHaveBeenWarned()
     })
 
     test('methods property is not a function', () => {
       const Comp = {
         methods: {
-          foo: 1
+          foo: 1,
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
         `Method "foo" has type "number" in the component definition. ` +
-          `Did you reference the function correctly?`
+          `Did you reference the function correctly?`,
       ).toHaveBeenWarned()
     })
 
     test('methods property is already declared in props', () => {
       const Comp = {
         props: {
-          foo: Number
+          foo: Number,
         },
         methods: {
-          foo() {}
+          foo() {},
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Methods property "foo" is already defined in Props.`
+        `Methods property "foo" is already defined in Props.`,
       ).toHaveBeenWarned()
     })
 
@@ -1521,32 +1521,32 @@ describe('api: options', () => {
       const Comp = {
         data() {
           return {
-            a: 1
+            a: 1,
           }
         },
         provide() {
           return {
-            a: this.a
+            a: this.a,
           }
         },
         render() {
           return [h(ChildA)]
-        }
+        },
       } as any
       const ChildA = {
         methods: {
-          a: () => null
+          a: () => null,
         },
         inject: ['a'],
         render() {
           return this.a
-        }
+        },
       } as any
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Methods property "a" is already defined in Inject.`
+        `Methods property "a" is already defined in Inject.`,
       ).toHaveBeenWarned()
     })
 
@@ -1554,15 +1554,15 @@ describe('api: options', () => {
       const Comp = {
         props: { foo: Number },
         data: () => ({
-          foo: 1
+          foo: 1,
         }),
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Data property "foo" is already defined in Props.`
+        `Data property "foo" is already defined in Props.`,
       ).toHaveBeenWarned()
     })
 
@@ -1570,52 +1570,52 @@ describe('api: options', () => {
       const Comp = {
         data() {
           return {
-            a: 1
+            a: 1,
           }
         },
         provide() {
           return {
-            a: this.a
+            a: this.a,
           }
         },
         render() {
           return [h(ChildA)]
-        }
+        },
       } as any
       const ChildA = {
         data() {
           return {
-            a: 1
+            a: 1,
           }
         },
         inject: ['a'],
         render() {
           return this.a
-        }
+        },
       } as any
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Data property "a" is already defined in Inject.`
+        `Data property "a" is already defined in Inject.`,
       ).toHaveBeenWarned()
     })
 
     test('data property is already declared in methods', () => {
       const Comp = {
         data: () => ({
-          foo: 1
+          foo: 1,
         }),
         methods: {
-          foo() {}
+          foo() {},
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Data property "foo" is already defined in Methods.`
+        `Data property "foo" is already defined in Methods.`,
       ).toHaveBeenWarned()
     })
 
@@ -1623,15 +1623,15 @@ describe('api: options', () => {
       const Comp = {
         props: { foo: Number },
         computed: {
-          foo() {}
+          foo() {},
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Computed property "foo" is already defined in Props.`
+        `Computed property "foo" is already defined in Props.`,
       ).toHaveBeenWarned()
     })
 
@@ -1639,71 +1639,71 @@ describe('api: options', () => {
       const Comp = {
         data() {
           return {
-            a: 1
+            a: 1,
           }
         },
         provide() {
           return {
-            a: this.a
+            a: this.a,
           }
         },
         render() {
           return [h(ChildA)]
-        }
+        },
       } as any
       const ChildA = {
         computed: {
           a: {
             get() {},
-            set() {}
-          }
+            set() {},
+          },
         },
         inject: ['a'],
         render() {
           return this.a
-        }
+        },
       } as any
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Computed property "a" is already defined in Inject.`
+        `Computed property "a" is already defined in Inject.`,
       ).toHaveBeenWarned()
     })
 
     test('computed property is already declared in methods', () => {
       const Comp = {
         computed: {
-          foo() {}
+          foo() {},
         },
         methods: {
-          foo() {}
+          foo() {},
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Computed property "foo" is already defined in Methods.`
+        `Computed property "foo" is already defined in Methods.`,
       ).toHaveBeenWarned()
     })
 
     test('computed property is already declared in data', () => {
       const Comp = {
         data: () => ({
-          foo: 1
+          foo: 1,
         }),
         computed: {
-          foo() {}
+          foo() {},
         },
-        render() {}
+        render() {},
       }
 
       const root = nodeOps.createElement('div')
       render(h(Comp), root)
       expect(
-        `Computed property "foo" is already defined in Data.`
+        `Computed property "foo" is already defined in Data.`,
       ).toHaveBeenWarned()
     })
   })
index e0ddd9c4da33cc74a58c9c7ac7353cf0a232576c..c4a32a067c016016bfa58d82b17d5ead7923efd9 100644 (file)
@@ -1,15 +1,15 @@
-import { ref, reactive } from '@vue/reactivity'
+import { reactive, ref } from '@vue/reactivity'
 import {
-  renderToString,
+  type TestElement,
+  defineComponent,
   h,
+  nextTick,
   nodeOps,
   render,
+  renderToString,
   serializeInner,
-  nextTick,
-  watchEffect,
-  defineComponent,
   triggerEvent,
-  TestElement
+  watchEffect,
 } from '@vue/runtime-test'
 
 // reference: https://vue-composition-api-rfc.netlify.com/api.html#setup
@@ -24,12 +24,12 @@ describe('api: setup context', () => {
           // object exposed as-is
           object: reactive({ msg: 'bar' }),
           // primitive value exposed as-is
-          value: 'baz'
+          value: 'baz',
         }
       },
       render() {
         return `${this.ref} ${this.object.msg} ${this.value}`
-      }
+      },
     })
     expect(renderToString(h(Comp))).toMatch(`foo bar baz`)
   })
@@ -40,7 +40,7 @@ describe('api: setup context', () => {
         return () => {
           return h('div', 'hello')
         }
-      }
+      },
     }
     expect(renderToString(h(Comp))).toMatch(`hello`)
   })
@@ -50,7 +50,7 @@ describe('api: setup context', () => {
     let dummy
 
     const Parent = {
-      render: () => h(Child, { count: count.value })
+      render: () => h(Child, { count: count.value }),
     }
 
     const Child = defineComponent({
@@ -60,7 +60,7 @@ describe('api: setup context', () => {
           dummy = props.count
         })
         return () => h('div', props.count)
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -79,7 +79,7 @@ describe('api: setup context', () => {
     const toggle = ref(true)
 
     const Parent = {
-      render: () => h(Child, toggle.value ? { id: 'foo' } : { class: 'baz' })
+      render: () => h(Child, toggle.value ? { id: 'foo' } : { class: 'baz' }),
     }
 
     const Child = {
@@ -89,7 +89,7 @@ describe('api: setup context', () => {
       inheritAttrs: false,
       setup(props: any, { attrs }: any) {
         return () => h('div', attrs)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -107,13 +107,13 @@ describe('api: setup context', () => {
     const toggle = ref(true)
 
     const Parent = {
-      render: () => h(Child, toggle.value ? { id: 'foo' } : { class: 'baz' })
+      render: () => h(Child, toggle.value ? { id: 'foo' } : { class: 'baz' }),
     }
 
     const Wrapper = {
       render(this: any) {
         return this.$slots.default()
-      }
+      },
     }
 
     const Child = {
@@ -122,12 +122,12 @@ describe('api: setup context', () => {
         return () => {
           const vnode = h(Wrapper, null, {
             default: () => [h('div', attrs)],
-            _: 1 // mark stable slots
+            _: 1, // mark stable slots
           })
           vnode.dynamicChildren = [] // force optimized mode
           return vnode
         }
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -147,14 +147,14 @@ describe('api: setup context', () => {
       render: () =>
         h(Child, null, {
           foo: () => id.value,
-          bar: () => 'bar'
-        })
+          bar: () => 'bar',
+        }),
     }
 
     const Child = {
       setup(props: any, { slots }: any) {
         return () => h('div', [...slots.foo(), ...slots.bar()])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -178,27 +178,27 @@ describe('api: setup context', () => {
           onInc: (newVal: number) => {
             spy()
             count.value = newVal
-          }
-        })
+          },
+        }),
     }
 
     const Child = defineComponent({
       props: {
         count: {
           type: Number,
-          default: 1
-        }
+          default: 1,
+        },
       },
       setup(props, { emit }) {
         return () =>
           h(
             'div',
             {
-              onClick: () => emit('inc', props.count + 1)
+              onClick: () => emit('inc', props.count + 1),
             },
-            props.count
+            props.count,
           )
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
index 846806e8f42a85e9a4c0fcb13c4c702f995d7763..ef4fcd09e271c7fe8cf397204e96d07c76806f37 100644 (file)
@@ -1,41 +1,41 @@
 import {
-  ComponentInternalInstance,
+  type ComponentInternalInstance,
+  type ComputedRef,
+  Fragment,
+  type Ref,
+  type SetupContext,
+  Suspense,
+  computed,
   createApp,
+  createBlock,
+  createElementBlock,
+  createElementVNode,
+  createVNode,
   defineComponent,
   getCurrentInstance,
   h,
+  nextTick,
   nodeOps,
   onMounted,
+  openBlock,
+  ref,
   render,
   serializeInner,
-  SetupContext,
-  Suspense,
-  computed,
-  ComputedRef,
   shallowReactive,
-  nextTick,
-  ref,
-  Ref,
   watch,
-  openBlock,
-  createVNode,
-  createElementVNode,
-  createBlock,
-  createElementBlock,
-  Fragment
 } from '@vue/runtime-test'
 import {
+  createPropsRestProxy,
   defineEmits,
-  defineProps,
   defineExpose,
-  withDefaults,
+  defineProps,
+  mergeDefaults,
+  mergeModels,
   useAttrs,
+  useModel,
   useSlots,
-  mergeDefaults,
   withAsyncContext,
-  createPropsRestProxy,
-  mergeModels,
-  useModel
+  withDefaults,
 } from '../src/apiSetupHelpers'
 
 describe('SFC <script setup> helpers', () => {
@@ -61,12 +61,12 @@ describe('SFC <script setup> helpers', () => {
         slots = useSlots()
         attrs = useAttrs()
         return () => {}
-      }
+      },
     }
     const passedAttrs = { id: 'foo' }
     const passedSlots = {
       default: () => {},
-      x: () => {}
+      x: () => {},
     }
     render(h(Comp, passedAttrs, passedSlots), nodeOps.createElement('div'))
     expect(typeof slots!.default).toBe('function')
@@ -84,7 +84,7 @@ describe('SFC <script setup> helpers', () => {
         attrs = useAttrs()
         ctx = _ctx
         return () => {}
-      }
+      },
     })
     render(h(Comp), nodeOps.createElement('div'))
     expect(slots).toBe(ctx!.slots)
@@ -97,18 +97,18 @@ describe('SFC <script setup> helpers', () => {
         {
           foo: null,
           bar: { type: String, required: false },
-          baz: String
+          baz: String,
         },
         {
           foo: 1,
           bar: 'baz',
-          baz: 'qux'
-        }
+          baz: 'qux',
+        },
       )
       expect(merged).toMatchObject({
         foo: { default: 1 },
         bar: { type: String, required: false, default: 'baz' },
-        baz: { type: String, default: 'qux' }
+        baz: { type: String, default: 'qux' },
       })
     })
 
@@ -116,12 +116,12 @@ describe('SFC <script setup> helpers', () => {
       const merged = mergeDefaults(['foo', 'bar', 'baz'], {
         foo: 1,
         bar: 'baz',
-        baz: 'qux'
+        baz: 'qux',
       })
       expect(merged).toMatchObject({
         foo: { default: 1 },
         bar: { default: 'baz' },
-        baz: { default: 'qux' }
+        baz: { default: 'qux' },
       })
     })
 
@@ -129,17 +129,17 @@ describe('SFC <script setup> helpers', () => {
       const fn = () => {}
       const merged = mergeDefaults(['foo', 'bar', 'baz'], {
         foo: fn,
-        __skip_foo: true
+        __skip_foo: true,
       })
       expect(merged).toMatchObject({
-        foo: { default: fn, skipFactory: true }
+        foo: { default: fn, skipFactory: true },
       })
     })
 
     test('should warn missing', () => {
       mergeDefaults({}, { foo: 1 })
       expect(
-        `props default key "foo" has no corresponding declaration`
+        `props default key "foo" has no corresponding declaration`,
       ).toHaveBeenWarned()
     })
   })
@@ -149,25 +149,25 @@ describe('SFC <script setup> helpers', () => {
       expect(mergeModels(['foo', 'bar'], ['baz'])).toMatchObject([
         'foo',
         'bar',
-        'baz'
+        'baz',
       ])
     })
 
     test('object syntax', () => {
       expect(
-        mergeModels({ foo: null, bar: { required: true } }, ['baz'])
+        mergeModels({ foo: null, bar: { required: true } }, ['baz']),
       ).toMatchObject({
         foo: null,
         bar: { required: true },
-        baz: {}
+        baz: {},
       })
 
       expect(
-        mergeModels(['baz'], { foo: null, bar: { required: true } })
+        mergeModels(['baz'], { foo: null, bar: { required: true } }),
       ).toMatchObject({
         foo: null,
         bar: { required: true },
-        baz: {}
+        baz: {},
       })
     })
 
@@ -175,12 +175,12 @@ describe('SFC <script setup> helpers', () => {
       expect(
         mergeModels(
           { foo: null, bar: { required: true } },
-          { bar: {}, baz: {} }
-        )
+          { bar: {}, baz: {} },
+        ),
       ).toMatchObject({
         foo: null,
         bar: {},
-        baz: {}
+        baz: {},
       })
     })
   })
@@ -202,7 +202,7 @@ describe('SFC <script setup> helpers', () => {
             compRender()
             return foo.value
           }
-        }
+        },
       })
 
       const msg = ref('')
@@ -211,8 +211,8 @@ describe('SFC <script setup> helpers', () => {
       createApp(() =>
         h(Comp, {
           modelValue: msg.value,
-          'onUpdate:modelValue': setValue
-        })
+          'onUpdate:modelValue': setValue,
+        }),
       ).mount(root)
 
       expect(foo.value).toBe('')
@@ -259,7 +259,7 @@ describe('SFC <script setup> helpers', () => {
             compRender()
             return foo.value
           }
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
@@ -295,7 +295,7 @@ describe('SFC <script setup> helpers', () => {
             compRender()
             return count.value
           }
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
@@ -330,7 +330,7 @@ describe('SFC <script setup> helpers', () => {
             compRender()
             return childCount.value
           }
-        }
+        },
       })
 
       const Parent = defineComponent({
@@ -346,9 +346,9 @@ describe('SFC <script setup> helpers', () => {
               count: count.value,
               'onUpdate:count': val => {
                 count.value = val
-              }
+              },
             })
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
@@ -388,7 +388,7 @@ describe('SFC <script setup> helpers', () => {
             compRender()
             return childCount.value
           }
-        }
+        },
       })
 
       const toggle = ref(true)
@@ -401,10 +401,10 @@ describe('SFC <script setup> helpers', () => {
                   count: count.value,
                   'onUpdate:count': val => {
                     count.value = val
-                  }
+                  },
                 })
               : h(Comp)
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
@@ -446,7 +446,7 @@ describe('SFC <script setup> helpers', () => {
       const Comp = {
         render(this: any) {
           return this.$slots.default()
-        }
+        },
       }
 
       const childRender = vi.fn()
@@ -466,12 +466,12 @@ describe('SFC <script setup> helpers', () => {
                     slotRender()
                     return createElementVNode('div', null, foo.value)
                   },
-                  _: 1 /* STABLE */
-                })
+                  _: 1 /* STABLE */,
+                }),
               ])
             )
           }
-        }
+        },
       })
 
       const msg = ref('')
@@ -485,14 +485,14 @@ describe('SFC <script setup> helpers', () => {
               Child,
               {
                 modelValue: msg.value,
-                'onUpdate:modelValue': setValue
+                'onUpdate:modelValue': setValue,
               },
               null,
               8 /* PROPS */,
-              ['modelValue']
+              ['modelValue'],
             )
           )
-        }
+        },
       }).mount(root)
 
       expect(foo.value).toBe('')
@@ -519,7 +519,7 @@ describe('SFC <script setup> helpers', () => {
     const original = shallowReactive({
       foo: 1,
       bar: 2,
-      baz: 3
+      baz: 3,
     })
     const rest = createPropsRestProxy(original, ['foo', 'bar'])
     expect('foo' in rest).toBe(false)
@@ -560,7 +560,7 @@ describe('SFC <script setup> helpers', () => {
               () =>
                 new Promise(r => {
                   resolve = r
-                })
+                }),
             )),
             (__temp = await __temp),
             __restore(),
@@ -570,13 +570,13 @@ describe('SFC <script setup> helpers', () => {
           onMounted(spy)
           afterInstance = getCurrentInstance()
           return () => msg
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
       render(
         h(() => h(Suspense, () => h(Comp))),
-        root
+        root,
       )
 
       expect(spy).not.toHaveBeenCalled()
@@ -607,7 +607,7 @@ describe('SFC <script setup> helpers', () => {
               () =>
                 new Promise((_, rj) => {
                   reject = rj
-                })
+                }),
             )
             __temp = await __temp
             __restore()
@@ -618,13 +618,13 @@ describe('SFC <script setup> helpers', () => {
           onMounted(spy)
           afterInstance = getCurrentInstance()
           return () => ''
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
       render(
         h(() => h(Suspense, () => h(Comp))),
-        root
+        root,
       )
 
       expect(spy).not.toHaveBeenCalled()
@@ -677,13 +677,13 @@ describe('SFC <script setup> helpers', () => {
             resolve()
             return ''
           }
-        }
+        },
       })
 
       const root = nodeOps.createElement('div')
       render(
         h(() => h(Suspense, () => h(Comp))),
-        root
+        root,
       )
 
       await ready
@@ -709,7 +709,7 @@ describe('SFC <script setup> helpers', () => {
           __temp = await __temp
           __restore()
         },
-        render() {}
+        render() {},
       })
 
       const app = createApp(() => h(Suspense, () => h(Comp)))
@@ -729,7 +729,7 @@ describe('SFC <script setup> helpers', () => {
     test('race conditions', async () => {
       const uids = {
         one: { before: NaN, after: NaN },
-        two: { before: NaN, after: NaN }
+        two: { before: NaN, after: NaN },
       }
 
       const Comp = defineComponent({
@@ -744,13 +744,13 @@ describe('SFC <script setup> helpers', () => {
 
           uids[props.name].after = getCurrentInstance()!.uid
           return () => ''
-        }
+        },
       })
 
       const app = createApp(() =>
         h(Suspense, () =>
-          h('div', [h(Comp, { name: 'one' }), h(Comp, { name: 'two' })])
-        )
+          h('div', [h(Comp, { name: 'one' }), h(Comp, { name: 'two' })]),
+        ),
       )
       const root = nodeOps.createElement('div')
       app.mount(root)
@@ -780,7 +780,7 @@ describe('SFC <script setup> helpers', () => {
           // register the lifecycle after an await statement
           onMounted(resolve)
           return () => ''
-        }
+        },
       })
 
       const app = createApp(() => h(Suspense, () => h(Comp)))
index 89693a446ac3aa86db598c1272fa4f2436f8d353..58e6b1b514c75b996a1e7dc92e1cb80e84cdfb2f 100644 (file)
@@ -41,7 +41,7 @@ bench('create watcher', () => {
     'update ref to trigger watchEffect (scheduled but not executed)',
     () => {
       v.value = i++
-    }
+    },
   )
 }
 
index 0f5782e300912fd17e3f4d188025518a714a2baf..3bc614ef9b7aeecc293af08980b67af527da000b 100644 (file)
@@ -1,36 +1,36 @@
 import {
-  watch,
-  watchEffect,
-  reactive,
+  type ComponentInternalInstance,
+  type ComponentPublicInstance,
   computed,
-  nextTick,
-  ref,
   defineComponent,
   getCurrentInstance,
-  ComponentInternalInstance,
-  ComponentPublicInstance
+  nextTick,
+  reactive,
+  ref,
+  watch,
+  watchEffect,
 } from '../src/index'
 import {
-  render,
+  type TestElement,
+  createApp,
+  h,
   nodeOps,
+  onMounted,
+  render,
   serializeInner,
-  TestElement,
-  h,
-  createApp,
   watchPostEffect,
   watchSyncEffect,
-  onMounted
 } from '@vue/runtime-test'
 import {
+  type DebuggerEvent,
   ITERATE_KEY,
-  DebuggerEvent,
+  type Ref,
   TrackOpTypes,
   TriggerOpTypes,
-  triggerRef,
-  shallowRef,
-  Ref,
   effectScope,
-  toRef
+  shallowRef,
+  toRef,
+  triggerRef,
 } from '@vue/reactivity'
 
 // reference: https://vue-composition-api-rfc.netlify.com/api.html#watch
@@ -61,7 +61,7 @@ describe('api: watch', () => {
         if (prevCount) {
           prevCount + 1
         }
-      }
+      },
     )
     state.count++
     await nextTick()
@@ -135,8 +135,8 @@ describe('api: watch', () => {
         dummy = [c, prevCount]
       },
       {
-        deep: true
-      }
+        deep: true,
+      },
     )
     count.value++
     await nextTick()
@@ -145,7 +145,7 @@ describe('api: watch', () => {
 
   it('directly watching reactive object (with automatic deep: true)', async () => {
     const src = reactive({
-      count: 0
+      count: 0,
     })
     let dummy
     watch(src, ({ count }) => {
@@ -174,7 +174,7 @@ describe('api: watch', () => {
     await nextTick()
     expect(dummy).toMatchObject([
       [2, 2, 3],
-      [1, 1, 2]
+      [1, 1, 2],
     ])
   })
 
@@ -189,7 +189,7 @@ describe('api: watch', () => {
         expect([newA, newB]).toMatchObject([undefined, undefined])
         expect([oldA, oldB]).toMatchObject([undefined, undefined])
       },
-      { immediate: true }
+      { immediate: true },
     )
     await nextTick()
     expect(called).toBe(true)
@@ -214,7 +214,7 @@ describe('api: watch', () => {
     await nextTick()
     expect(dummy).toMatchObject([
       [2, true],
-      [1, false]
+      [1, false],
     ])
   })
 
@@ -264,7 +264,7 @@ describe('api: watch', () => {
       () => state.count,
       count => {
         dummy = count
-      }
+      },
     )
 
     state.count++
@@ -345,7 +345,7 @@ describe('api: watch', () => {
           assertion(count.value, count2.value)
         })
         return () => count.value
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -375,10 +375,10 @@ describe('api: watch', () => {
           () => {
             assertion(count.value)
           },
-          { flush: 'post' }
+          { flush: 'post' },
         )
         return () => count.value
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -404,7 +404,7 @@ describe('api: watch', () => {
           assertion(count.value)
         })
         return () => count.value
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -444,11 +444,11 @@ describe('api: watch', () => {
             assertion(count.value)
           },
           {
-            flush: 'sync'
-          }
+            flush: 'sync',
+          },
         )
         return () => count.value
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -490,7 +490,7 @@ describe('api: watch', () => {
           assertion(count.value)
         })
         return () => count.value
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -513,12 +513,12 @@ describe('api: watch', () => {
       setup() {
         watch(toggle, cb, { flush: 'post' })
       },
-      render() {}
+      render() {},
     }
     const App = {
       render() {
         return toggle.value ? h(Comp) : null
-      }
+      },
     }
     render(h(App), nodeOps.createElement('div'))
     expect(cb).not.toHaveBeenCalled()
@@ -535,12 +535,12 @@ describe('api: watch', () => {
       setup() {
         watch(toggle, cb, { flush: 'pre' })
       },
-      render() {}
+      render() {},
     }
     const App = {
       render() {
         return toggle.value ? h(Comp) : null
-      }
+      },
     }
     render(h(App), nodeOps.createElement('div'))
     expect(cb).not.toHaveBeenCalled()
@@ -557,20 +557,20 @@ describe('api: watch', () => {
       props: ['visible'],
       render() {
         return visible.value ? h(Comp) : null
-      }
+      },
     })
     const Comp = {
       setup() {
         watch(visible, cb, { flush: 'pre' })
       },
-      render() {}
+      render() {},
     }
     const App = {
       render() {
         return h(Parent, {
-          visible: visible.value
+          visible: visible.value,
         })
-      }
+      },
     }
     render(h(App), nodeOps.createElement('div'))
     expect(cb).not.toHaveBeenCalled()
@@ -591,13 +591,13 @@ describe('api: watch', () => {
           val => {
             calls.push('watcher child')
           },
-          { flush: 'pre' }
+          { flush: 'pre' },
         )
         return () => {
           b.value
           calls.push('render child')
         }
-      }
+      },
     }
 
     const Parent = {
@@ -608,22 +608,22 @@ describe('api: watch', () => {
           val => {
             calls.push('watcher parent')
           },
-          { flush: 'pre' }
+          { flush: 'pre' },
         )
         return () => {
           b.value
           calls.push('render parent')
           return h(Comp)
         }
-      }
+      },
     }
 
     const App = {
       render() {
         return h(Parent, {
-          a: b.value
+          a: b.value,
         })
-      }
+      },
     }
 
     render(h(App), nodeOps.createElement('div'))
@@ -637,7 +637,7 @@ describe('api: watch', () => {
       'watcher parent',
       'render parent',
       'watcher child',
-      'render child'
+      'render child',
     ])
   })
 
@@ -657,7 +657,7 @@ describe('api: watch', () => {
             calls.push('watcher 1')
             c.value++
           },
-          { flush: 'pre' }
+          { flush: 'pre' },
         )
 
         // #1777 chained pre-watcher
@@ -666,19 +666,19 @@ describe('api: watch', () => {
           () => {
             calls.push('watcher 2')
           },
-          { flush: 'pre' }
+          { flush: 'pre' },
         )
         return () => {
           c.value
           calls.push('render')
         }
-      }
+      },
     }
 
     const App = {
       render() {
         return h(Comp, { a: a.value, b: b.value })
-      }
+      },
     }
 
     render(h(App), nodeOps.createElement('div'))
@@ -705,7 +705,7 @@ describe('api: watch', () => {
           () => {
             calls.push('watch ' + count.value)
           },
-          { flush: 'pre' }
+          { flush: 'pre' },
         )
         onMounted(() => {
           calls.push('mounted')
@@ -714,7 +714,7 @@ describe('api: watch', () => {
         count.value++
         count.value++
         count.value++
-      }
+      },
     }
     render(h(App), nodeOps.createElement('div'))
     expect(calls).toMatchObject(['watch 3', 'mounted'])
@@ -734,13 +734,13 @@ describe('api: watch', () => {
           () => {
             dom = domRef.value
           },
-          { flush: 'post' }
+          { flush: 'post' },
         )
 
         return () => {
           return toggle.value ? h('p', { ref: domRef }) : null
         }
-      }
+      },
     }
 
     render(h(App), nodeOps.createElement('div'))
@@ -754,14 +754,14 @@ describe('api: watch', () => {
   it('deep', async () => {
     const state = reactive({
       nested: {
-        count: ref(0)
+        count: ref(0),
       },
       array: [1, 2, 3],
       map: new Map([
         ['a', 1],
-        ['b', 2]
+        ['b', 2],
       ]),
-      set: new Set([1, 2, 3])
+      set: new Set([1, 2, 3]),
     })
 
     let dummy
@@ -772,10 +772,10 @@ describe('api: watch', () => {
           state.nested.count,
           state.array[0],
           state.map.get('a'),
-          state.set.has(1)
+          state.set.has(1),
         ]
       },
-      { deep: true }
+      { deep: true },
     )
 
     state.nested.count++
@@ -809,7 +809,7 @@ describe('api: watch', () => {
       state => {
         dummy = [state[0].value, state[1].value]
       },
-      { deep: true }
+      { deep: true },
     )
 
     count.value++
@@ -860,7 +860,7 @@ describe('api: watch', () => {
         dummy = count.value
       },
       // @ts-expect-error
-      { immediate: false }
+      { immediate: false },
     )
     expect(dummy).toBe(0)
     expect(`"immediate" option is only respected`).toHaveBeenWarned()
@@ -879,7 +879,7 @@ describe('api: watch', () => {
         return arr
       },
       // @ts-expect-error
-      { deep: true }
+      { deep: true },
     )
     expect(spy).toHaveBeenCalledTimes(1)
     ;(arr.value[1] as Array<number>)[0] = 3
@@ -899,7 +899,7 @@ describe('api: watch', () => {
       () => {
         dummy = [obj.foo, 'bar' in obj, Object.keys(obj)]
       },
-      { onTrack }
+      { onTrack },
     )
     await nextTick()
     expect(dummy).toEqual([1, true, ['foo', 'bar']])
@@ -908,18 +908,18 @@ describe('api: watch', () => {
       {
         target: obj,
         type: TrackOpTypes.GET,
-        key: 'foo'
+        key: 'foo',
       },
       {
         target: obj,
         type: TrackOpTypes.HAS,
-        key: 'bar'
+        key: 'bar',
       },
       {
         target: obj,
         type: TrackOpTypes.ITERATE,
-        key: ITERATE_KEY
-      }
+        key: ITERATE_KEY,
+      },
     ])
   })
 
@@ -934,7 +934,7 @@ describe('api: watch', () => {
       () => {
         dummy = obj.foo
       },
-      { onTrigger }
+      { onTrigger },
     )
     await nextTick()
     expect(dummy).toBe(1)
@@ -947,7 +947,7 @@ describe('api: watch', () => {
       type: TriggerOpTypes.SET,
       key: 'foo',
       oldValue: 1,
-      newValue: 2
+      newValue: 2,
     })
 
     delete obj.foo
@@ -957,7 +957,7 @@ describe('api: watch', () => {
     expect(events[1]).toMatchObject({
       type: TriggerOpTypes.DELETE,
       key: 'foo',
-      oldValue: 2
+      oldValue: 2,
     })
   })
 
@@ -971,8 +971,8 @@ describe('api: watch', () => {
         ++calls
       },
       {
-        flush: 'sync'
-      }
+        flush: 'sync',
+      },
     )
 
     expect(calls).toBe(0)
@@ -1073,7 +1073,7 @@ describe('api: watch', () => {
       mounted() {
         instance = getCurrentInstance()
       },
-      unmounted() {}
+      unmounted() {},
     })
 
     const Comp = defineComponent({
@@ -1086,7 +1086,7 @@ describe('api: watch', () => {
       render() {
         return this.show
           ? h(Child, {
-              ref: vm => void (this.comp = vm as ComponentPublicInstance)
+              ref: vm => void (this.comp = vm as ComponentPublicInstance),
             })
           : null
       },
@@ -1095,9 +1095,9 @@ describe('api: watch', () => {
         // the effect for this `$watch` should nonetheless be registered with Child
         this.comp!.$watch(
           () => this.show,
-          () => void 0
+          () => void 0,
         )
-      }
+      },
     })
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -1124,7 +1124,7 @@ describe('api: watch', () => {
       created(this: any) {
         instance = this
         this.$watch(source, function () {})
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -1141,7 +1141,7 @@ describe('api: watch', () => {
       render() {},
       setup() {
         watch(source, () => {})
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -1162,17 +1162,17 @@ describe('api: watch', () => {
       watch: {
         a() {
           b.value
-        }
+        },
       },
       render() {
         return h('div', this.a)
-      }
+      },
     })
 
     const Parent = defineComponent({
       render() {
         return h(Child, { a: a.value })
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -1195,19 +1195,19 @@ describe('api: watch', () => {
       data() {
         return {
           a: {
-            b: 1
-          }
+            b: 1,
+          },
         }
       },
       watch: {
-        'a.b': spy
+        'a.b': spy,
       },
       created(this: any) {
         this.$watch('a.b', spy)
       },
       mounted(this: any) {
         this.a.b++
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -1250,11 +1250,11 @@ describe('api: watch', () => {
         effectScope(true).run(() => {
           watch(
             () => 1,
-            () => {}
+            () => {},
           )
         })
         return () => ''
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     createApp(Comp).mount(root)
@@ -1277,7 +1277,7 @@ describe('api: watch', () => {
           watch(trigger, () => countW++)
         })
         return () => ''
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
@@ -1302,20 +1302,20 @@ describe('api: watch', () => {
     { name: 'only trigger once watch' },
     {
       deep: true,
-      name: 'only trigger once watch with deep'
+      name: 'only trigger once watch with deep',
     },
     {
       flush: 'sync',
-      name: 'only trigger once watch with flush: sync'
+      name: 'only trigger once watch with flush: sync',
     },
     {
       flush: 'pre',
-      name: 'only trigger once watch with flush: pre'
+      name: 'only trigger once watch with flush: pre',
     },
     {
       immediate: true,
-      name: 'only trigger once watch with immediate'
-    }
+      name: 'only trigger once watch with immediate',
+    },
   ] as const
   test.each(options)('$name', async option => {
     const count = ref(0)
index 0019dd9eb979c1fd5e7ce8703a7cb837d6503f7c..86307275bf8e4dc26b7e92f34c1b98a2e5c177d2 100644 (file)
@@ -2,13 +2,13 @@
 // ./rendererAttrsFallthrough.spec.ts.
 
 import {
-  render,
+  type ComponentPublicInstance,
   defineComponent,
   h,
+  nextTick,
   nodeOps,
+  render,
   toHandlers,
-  nextTick,
-  ComponentPublicInstance
 } from '@vue/runtime-test'
 import { isEmitListener } from '../src/componentEmits'
 
@@ -21,7 +21,7 @@ describe('component: emit', () => {
         this.$emit('foo')
         this.$emit('bar')
         this.$emit('!baz')
-      }
+      },
     })
 
     const onfoo = vi.fn()
@@ -41,13 +41,13 @@ describe('component: emit', () => {
       render() {},
       created() {
         this.$emit('test-event')
-      }
+      },
     })
 
     const fooSpy = vi.fn()
     const Comp = () =>
       h(Foo, {
-        onTestEvent: fooSpy
+        onTestEvent: fooSpy,
       })
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -59,13 +59,13 @@ describe('component: emit', () => {
       render() {},
       created() {
         this.$emit('test-event')
-      }
+      },
     })
 
     const fooSpy = vi.fn()
     const Comp = () =>
       h(Foo, {
-        'onTest-event': fooSpy
+        'onTest-event': fooSpy,
       })
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -79,7 +79,7 @@ describe('component: emit', () => {
       created() {
         this.$emit('test-event')
         this.$emit('testEvent')
-      }
+      },
     })
 
     const fooSpy = vi.fn()
@@ -90,8 +90,8 @@ describe('component: emit', () => {
         Foo,
         toHandlers({
           'test-event': fooSpy,
-          testEvent: barSpy
-        })
+          testEvent: barSpy,
+        }),
       )
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -106,7 +106,7 @@ describe('component: emit', () => {
       created() {
         this.$emit('update:fooProp')
         this.$emit('update:barProp')
-      }
+      },
     })
 
     const fooSpy = vi.fn()
@@ -114,7 +114,7 @@ describe('component: emit', () => {
     const Comp = () =>
       h(Foo, {
         'onUpdate:fooProp': fooSpy,
-        'onUpdate:bar-prop': barSpy
+        'onUpdate:bar-prop': barSpy,
       })
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -127,7 +127,7 @@ describe('component: emit', () => {
       setup(_, { emit }) {
         emit('foo', 1)
         return () => h('div')
-      }
+      },
     })
 
     const fn1 = vi.fn()
@@ -137,9 +137,9 @@ describe('component: emit', () => {
       setup() {
         return () =>
           h(Child, {
-            onFoo: [fn1, fn2]
+            onFoo: [fn1, fn2],
           })
-      }
+      },
     }
 
     render(h(App), nodeOps.createElement('div'))
@@ -156,28 +156,28 @@ describe('component: emit', () => {
       created() {
         // @ts-expect-error
         this.$emit('bar')
-      }
+      },
     })
     render(h(Foo), nodeOps.createElement('div'))
     expect(
-      `Component emitted event "bar" but it is neither declared`
+      `Component emitted event "bar" but it is neither declared`,
     ).toHaveBeenWarned()
   })
 
   test('warning for undeclared event (object)', () => {
     const Foo = defineComponent({
       emits: {
-        foo: null
+        foo: null,
       },
       render() {},
       created() {
         // @ts-expect-error
         this.$emit('bar')
-      }
+      },
     })
     render(h(Foo), nodeOps.createElement('div'))
     expect(
-      `Component emitted event "bar" but it is neither declared`
+      `Component emitted event "bar" but it is neither declared`,
     ).toHaveBeenWarned()
   })
 
@@ -189,23 +189,23 @@ describe('component: emit', () => {
       created() {
         // @ts-expect-error
         this.$emit('foo')
-      }
+      },
     })
     render(h(Foo), nodeOps.createElement('div'))
     expect(
-      `Component emitted event "foo" but it is neither declared`
+      `Component emitted event "foo" but it is neither declared`,
     ).not.toHaveBeenWarned()
   })
 
   test('validator warning', () => {
     const Foo = defineComponent({
       emits: {
-        foo: (arg: number) => arg > 0
+        foo: (arg: number) => arg > 0,
       },
       render() {},
       created() {
         this.$emit('foo', -1)
-      }
+      },
     })
     render(h(Foo), nodeOps.createElement('div'))
     expect(`event validation failed for event "foo"`).toHaveBeenWarned()
@@ -214,15 +214,15 @@ describe('component: emit', () => {
   test('merging from mixins', () => {
     const mixin = {
       emits: {
-        foo: (arg: number) => arg > 0
-      }
+        foo: (arg: number) => arg > 0,
+      },
     }
     const Foo = defineComponent({
       mixins: [mixin],
       render() {},
       created() {
         this.$emit('foo', -1)
-      }
+      },
     })
     render(h(Foo), nodeOps.createElement('div'))
     expect(`event validation failed for event "foo"`).toHaveBeenWarned()
@@ -235,11 +235,11 @@ describe('component: emit', () => {
       render() {},
       created() {
         this.$emit('foo')
-      }
+      },
     })
     render(h(Foo), nodeOps.createElement('div'))
     expect(
-      `Component emitted event "foo" but it is neither declared`
+      `Component emitted event "foo" but it is neither declared`,
     ).not.toHaveBeenWarned()
   })
 
@@ -248,23 +248,23 @@ describe('component: emit', () => {
       render() {},
       emits: {
         foo: null,
-        bar: null
+        bar: null,
       },
       created() {
         this.$emit('foo')
         this.$emit('foo')
         this.$emit('bar')
         this.$emit('bar')
-      }
+      },
     })
     const fn = vi.fn()
     const barFn = vi.fn()
     render(
       h(Foo, {
         onFooOnce: fn,
-        onBarOnce: barFn
+        onBarOnce: barFn,
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
     expect(fn).toHaveBeenCalledTimes(1)
     expect(barFn).toHaveBeenCalledTimes(1)
@@ -274,21 +274,21 @@ describe('component: emit', () => {
     const Foo = defineComponent({
       render() {},
       emits: {
-        foo: null
+        foo: null,
       },
       created() {
         this.$emit('foo')
         this.$emit('foo')
-      }
+      },
     })
     const onFoo = vi.fn()
     const onFooOnce = vi.fn()
     render(
       h(Foo, {
         onFoo,
-        onFooOnce
+        onFooOnce,
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
     expect(onFoo).toHaveBeenCalledTimes(2)
     expect(onFooOnce).toHaveBeenCalledTimes(1)
@@ -300,7 +300,7 @@ describe('component: emit', () => {
       created() {
         this.$emit('update:modelValue', '1')
         this.$emit('update:foo', '2')
-      }
+      },
     })
 
     const fn1 = vi.fn()
@@ -314,7 +314,7 @@ describe('component: emit', () => {
 
         foo: null,
         fooModifiers: { number: true },
-        'onUpdate:foo': fn2
+        'onUpdate:foo': fn2,
       })
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -331,7 +331,7 @@ describe('component: emit', () => {
       created() {
         this.$emit('update:modelValue', ' one ')
         this.$emit('update:foo', '  two  ')
-      }
+      },
     })
 
     const fn1 = vi.fn()
@@ -345,7 +345,7 @@ describe('component: emit', () => {
 
         foo: null,
         fooModifiers: { trim: true },
-        'onUpdate:foo': fn2
+        'onUpdate:foo': fn2,
       })
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -362,7 +362,7 @@ describe('component: emit', () => {
       created() {
         this.$emit('update:modelValue', '    +01.2    ')
         this.$emit('update:foo', '    1    ')
-      }
+      },
     })
 
     const fn1 = vi.fn()
@@ -376,7 +376,7 @@ describe('component: emit', () => {
 
         foo: null,
         fooModifiers: { trim: true, number: true },
-        'onUpdate:foo': fn2
+        'onUpdate:foo': fn2,
       })
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -392,7 +392,7 @@ describe('component: emit', () => {
       render() {},
       created() {
         this.$emit('update:modelValue', ' foo ', { bar: ' bar ' })
-      }
+      },
     })
 
     const fn = vi.fn()
@@ -400,7 +400,7 @@ describe('component: emit', () => {
       h(Foo, {
         modelValue: null,
         modelModifiers: { trim: true },
-        'onUpdate:modelValue': fn
+        'onUpdate:modelValue': fn,
       })
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -414,7 +414,7 @@ describe('component: emit', () => {
       click: null,
       'test-event': null,
       fooBar: null,
-      FooBaz: null
+      FooBaz: null,
     }
     expect(isEmitListener(options, 'onClick')).toBe(true)
     expect(isEmitListener(options, 'onclick')).toBe(false)
@@ -440,11 +440,11 @@ describe('component: emit', () => {
       },
       render() {
         return h('div')
-      }
+      },
     })
     const Comp = () =>
       h(Foo, {
-        onClosing: fn
+        onClosing: fn,
       })
 
     const el = nodeOps.createElement('div')
@@ -457,10 +457,10 @@ describe('component: emit', () => {
 
   test('merge string array emits', async () => {
     const ComponentA = defineComponent({
-      emits: ['one', 'two']
+      emits: ['one', 'two'],
     })
     const ComponentB = defineComponent({
-      emits: ['three']
+      emits: ['three'],
     })
     const renderFn = vi.fn(function (this: ComponentPublicInstance) {
       expect(this.$options.emits).toEqual(['one', 'two', 'three'])
@@ -468,7 +468,7 @@ describe('component: emit', () => {
     })
     const ComponentC = defineComponent({
       render: renderFn,
-      mixins: [ComponentA, ComponentB]
+      mixins: [ComponentA, ComponentB],
     })
     const el = nodeOps.createElement('div')
     expect(renderFn).toHaveBeenCalledTimes(0)
@@ -481,24 +481,24 @@ describe('component: emit', () => {
     const ComponentA = defineComponent({
       emits: {
         one: null,
-        two: twoFn
-      }
+        two: twoFn,
+      },
     })
     const ComponentB = defineComponent({
-      emits: ['three']
+      emits: ['three'],
     })
     const renderFn = vi.fn(function (this: ComponentPublicInstance) {
       expect(this.$options.emits).toEqual({
         one: null,
         two: twoFn,
-        three: null
+        three: null,
       })
       expect(this.$options.emits.two).toBe(twoFn)
       return h('div')
     })
     const ComponentC = defineComponent({
       render: renderFn,
-      mixins: [ComponentA, ComponentB]
+      mixins: [ComponentA, ComponentB],
     })
     const el = nodeOps.createElement('div')
     expect(renderFn).toHaveBeenCalledTimes(0)
index 3a16840b4f32f3218bcff1067689bb18b64968de..6760a957f120d5ef77a469490dff8fe412a5d056 100644 (file)
@@ -3,21 +3,21 @@
  */
 
 import {
-  ComponentInternalInstance,
+  type ComponentInternalInstance,
+  type FunctionalComponent,
+  type SetupContext,
+  createApp,
+  defineComponent,
   getCurrentInstance,
-  render,
   h,
+  inject,
   nodeOps,
-  FunctionalComponent,
-  defineComponent,
+  provide,
   ref,
+  render,
   serializeInner,
-  createApp,
-  provide,
-  inject,
-  watch,
   toRefs,
-  SetupContext
+  watch,
 } from '@vue/runtime-test'
 import { render as domRender, nextTick } from 'vue'
 
@@ -33,7 +33,7 @@ describe('component props', () => {
         props = this.$props
         attrs = this.$attrs
         proxy = this
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -74,7 +74,7 @@ describe('component props', () => {
           props = _props
           attrs = _attrs
         }
-      }
+      },
     })
 
     const root = nodeOps.createElement('div')
@@ -142,20 +142,20 @@ describe('component props', () => {
         foo: Boolean,
         bar: Boolean,
         baz: Boolean,
-        qux: Boolean
+        qux: Boolean,
       },
       render() {
         proxy = this
-      }
+      },
     }
     render(
       h(Comp, {
         // absent should cast to false
         bar: '', // empty string should cast to true
         baz: 'baz', // same string should cast to true
-        qux: 'ok' // other values should be left in-tact (but raise warning)
+        qux: 'ok', // other values should be left in-tact (but raise warning)
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
 
     expect(proxy.foo).toBe(false)
@@ -173,19 +173,19 @@ describe('component props', () => {
     const Comp = {
       props: {
         foo: {
-          default: 1
+          default: 1,
         },
         bar: {
-          default: defaultFn
+          default: defaultFn,
         },
         baz: {
           type: Function,
-          default: defaultBaz
-        }
+          default: defaultBaz,
+        },
       },
       render() {
         proxy = this
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -225,21 +225,21 @@ describe('component props', () => {
     const Child = defineComponent({
       props: {
         test: {
-          default: () => inject('test', 'default')
-        }
+          default: () => inject('test', 'default'),
+        },
       },
       setup(props) {
         return () => {
           return h('div', props.test)
         }
-      }
+      },
     })
 
     const Comp = {
       setup() {
         provide('test', 'injected')
         return () => h(Child)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -250,7 +250,7 @@ describe('component props', () => {
   test('optimized props updates', async () => {
     const Child = defineComponent({
       props: ['foo'],
-      template: `<div>{{ foo }}</div>`
+      template: `<div>{{ foo }}</div>`,
     })
 
     const foo = ref(1)
@@ -260,11 +260,11 @@ describe('component props', () => {
       setup() {
         return {
           foo,
-          id
+          id,
         }
       },
       components: { Child },
-      template: `<Child :foo="foo" :id="id"/>`
+      template: `<Child :foo="foo" :id="id"/>`,
     })
 
     // Note this one is using the main Vue render so it can compile template
@@ -289,13 +289,13 @@ describe('component props', () => {
         props: {
           foo: {
             type: Number,
-            validator: (value, props) => mockFn(value, props)
+            validator: (value, props) => mockFn(value, props),
           },
           bar: {
-            type: Number
-          }
+            type: Number,
+          },
         },
-        template: `<div />`
+        template: `<div />`,
       })
 
       // Note this one is using the main Vue render so it can compile template
@@ -311,14 +311,14 @@ describe('component props', () => {
         props: {
           foo: {
             type: Number,
-            validator: (value, props) => !!(props.bar = 1)
+            validator: (value, props) => !!(props.bar = 1),
           },
           bar: {
             type: Number,
-            validator: value => mockFn(value)
-          }
+            validator: value => mockFn(value),
+          },
         },
-        template: `<div />`
+        template: `<div />`,
       })
 
       // Note this one is using the main Vue render so it can compile template
@@ -326,7 +326,7 @@ describe('component props', () => {
       const root = document.createElement('div')
       domRender(h(Comp, { foo: 1, bar: 2 }), root)
       expect(
-        `Set operation on key "bar" failed: target is readonly.`
+        `Set operation on key "bar" failed: target is readonly.`,
       ).toHaveBeenWarnedLast()
       expect(mockFn).toHaveBeenCalledWith(2)
     })
@@ -341,7 +341,7 @@ describe('component props', () => {
         instance = getCurrentInstance()!
         setupProps = props
         return () => null
-      }
+      },
     }
     render(h(Comp, { foo: 1 }), nodeOps.createElement('div'))
     expect(setupProps.foo).toBe(1)
@@ -363,11 +363,11 @@ describe('component props', () => {
       props: {
         bool: { type: Boolean, required: true },
         str: { type: String, required: true },
-        num: { type: Number, required: true }
+        num: { type: Number, required: true },
       },
       setup() {
         return () => null
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     expect(`Missing required prop: "bool"`).toHaveBeenWarned()
@@ -387,11 +387,11 @@ describe('component props', () => {
         cls: { type: MyClass },
         fn: { type: Function },
         skipCheck: { type: [Boolean, Function], skipCheck: true },
-        empty: { type: [] }
+        empty: { type: [] },
       },
       setup() {
         return () => null
-      }
+      },
     }
     render(
       h(Comp, {
@@ -403,36 +403,36 @@ describe('component props', () => {
         cls: {},
         fn: true,
         skipCheck: 'foo',
-        empty: [1, 2, 3]
+        empty: [1, 2, 3],
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
     expect(
-      `Invalid prop: type check failed for prop "bool". Expected Boolean, got String`
+      `Invalid prop: type check failed for prop "bool". Expected Boolean, got String`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "str". Expected String with value "100", got Number with value 100.`
+      `Invalid prop: type check failed for prop "str". Expected String with value "100", got Number with value 100.`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "num". Expected Number with value 100, got String with value "100".`
+      `Invalid prop: type check failed for prop "num". Expected Number with value 100, got String with value "100".`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "arr". Expected Array, got Object`
+      `Invalid prop: type check failed for prop "arr". Expected Array, got Object`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "obj". Expected Object, got String with value "false"`
+      `Invalid prop: type check failed for prop "obj". Expected Object, got String with value "false"`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "fn". Expected Function, got Boolean with value true.`
+      `Invalid prop: type check failed for prop "fn". Expected Function, got Boolean with value true.`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "cls". Expected MyClass, got Object`
+      `Invalid prop: type check failed for prop "cls". Expected MyClass, got Object`,
     ).toHaveBeenWarned()
     expect(
-      `Invalid prop: type check failed for prop "skipCheck". Expected Boolean | Function, got String with value "foo".`
+      `Invalid prop: type check failed for prop "skipCheck". Expected Boolean | Function, got String with value "foo".`,
     ).not.toHaveBeenWarned()
     expect(
-      `Prop type [] for prop "empty" won't match anything. Did you mean to use type Array instead?`
+      `Prop type [] for prop "empty" won't match anything. Did you mean to use type Array instead?`,
     ).toHaveBeenWarned()
   })
 
@@ -440,17 +440,17 @@ describe('component props', () => {
   test('should not warn required props using kebab-case', async () => {
     const Comp = {
       props: {
-        fooBar: { type: String, required: true }
+        fooBar: { type: String, required: true },
       },
       setup() {
         return () => null
-      }
+      },
     }
     render(
       h(Comp, {
-        'foo-bar': 'hello'
+        'foo-bar': 'hello',
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
     expect(`Missing required prop: "fooBar"`).not.toHaveBeenWarned()
   })
@@ -460,13 +460,13 @@ describe('component props', () => {
     let renderProxy: any
 
     const E = {
-      props: ['base']
+      props: ['base'],
     }
     const M1 = {
-      props: ['m1']
+      props: ['m1'],
     }
     const M2 = {
-      props: { m2: null }
+      props: { m2: null },
     }
     const Comp = {
       props: ['self'],
@@ -478,7 +478,7 @@ describe('component props', () => {
       render(this: any) {
         renderProxy = this
         return h('div', [this.self, this.base, this.m1, this.m2])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -486,12 +486,12 @@ describe('component props', () => {
       self: 'from self, ',
       base: 'from base, ',
       m1: 'from mixin 1, ',
-      m2: 'from mixin 2'
+      m2: 'from mixin 2',
     }
     render(h(Comp, props), root)
 
     expect(serializeInner(root)).toMatch(
-      `from self, from base, from mixin 1, from mixin 2`
+      `from self, from base, from mixin 1, from mixin 2`,
     )
     expect(setupProps).toMatchObject(props)
     expect(renderProxy.$props).toMatchObject(props)
@@ -502,10 +502,10 @@ describe('component props', () => {
     let renderProxy: any
 
     const M1 = {
-      props: ['m1']
+      props: ['m1'],
     }
     const M2 = {
-      props: { m2: null }
+      props: { m2: null },
     }
     const Comp = {
       props: ['self'],
@@ -515,13 +515,13 @@ describe('component props', () => {
       render(this: any) {
         renderProxy = this
         return h('div', [this.self, this.m1, this.m2])
-      }
+      },
     }
 
     const props = {
       self: 'from self, ',
       m1: 'from mixin 1, ',
-      m2: 'from mixin 2'
+      m2: 'from mixin 2',
     }
     const app = createApp(Comp, props)
     app.mixin(M1)
@@ -531,7 +531,7 @@ describe('component props', () => {
     app.mount(root)
 
     expect(serializeInner(root)).toMatch(
-      `from self, from mixin 1, from mixin 2`
+      `from self, from mixin 1, from mixin 2`,
     )
     expect(setupProps).toMatchObject(props)
     expect(renderProxy.$props).toMatchObject(props)
@@ -540,19 +540,19 @@ describe('component props', () => {
   test('props type support BigInt', () => {
     const Comp = {
       props: {
-        foo: BigInt
+        foo: BigInt,
       },
       render(this: any) {
         return h('div', [this.foo])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
     render(
       h(Comp, {
-        foo: BigInt(BigInt(100000111)) + BigInt(2000000000) * BigInt(30000000)
+        foo: BigInt(BigInt(100000111)) + BigInt(2000000000) * BigInt(30000000),
       }),
-      root
+      root,
     )
 
     expect(serializeInner(root)).toMatch('<div>60000000100000111</div>')
@@ -565,25 +565,25 @@ describe('component props', () => {
       props: {
         foo: {
           type: Object,
-          default: () => ({ val: 1 })
+          default: () => ({ val: 1 }),
         },
-        bar: Number
+        bar: Number,
       },
       setup(props: any) {
         watch(
           () => props.foo,
           () => {
             count++
-          }
+          },
         )
         return () => h('h1', [props.foo.val, props.bar])
-      }
+      },
     }
 
     const foo = ref()
     const bar = ref(0)
     const app = createApp({
-      render: () => h(Comp, { foo: foo.value, bar: bar.value })
+      render: () => h(Comp, { foo: foo.value, bar: bar.value }),
     })
 
     const root = nodeOps.createElement('div')
@@ -606,13 +606,13 @@ describe('component props', () => {
     const Comp = {
       render() {},
       props: {
-        foo: String
+        foo: String,
       },
       setup(props: any) {
         initialKeys = Object.keys(props)
         const { foo } = toRefs(props)
         watch(foo, changeSpy)
-      }
+      },
     }
 
     const Parent = () => (passFoo.value ? h(Comp, { foo: 'ok' }) : h(Comp))
@@ -640,15 +640,15 @@ describe('component props', () => {
           childProps.value && childProps.value.foo
           return slots.default!()
         }
-      }
+      },
     }
 
     const Child = {
       props: {
         foo: {
           type: Boolean,
-          required: false
-        }
+          required: false,
+        },
       },
       setup(props: { foo: boolean }) {
         const register = inject('register') as any
@@ -657,13 +657,13 @@ describe('component props', () => {
         register(props)
 
         return () => 'foo'
-      }
+      },
     }
 
     const App = {
       setup() {
         return () => h(Parent, () => h(Child as any, { foo: '' }, () => null))
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -675,9 +675,9 @@ describe('component props', () => {
   test('support null in required + multiple-type declarations', () => {
     const Comp = {
       props: {
-        foo: { type: [Function, null], required: true }
+        foo: { type: [Function, null], required: true },
       },
-      render() {}
+      render() {},
     }
     const root = nodeOps.createElement('div')
     expect(() => {
@@ -694,7 +694,7 @@ describe('component props', () => {
     const Comp = {
       render(this: any) {
         return JSON.stringify(this.$attrs) + Object.keys(this.$attrs)
-      }
+      },
     }
     const root = nodeOps.createElement('div')
 
@@ -702,12 +702,12 @@ describe('component props', () => {
 
     render(h(Comp, attrs), root)
     expect(serializeInner(root)).toBe(
-      JSON.stringify(attrs) + Object.keys(attrs)
+      JSON.stringify(attrs) + Object.keys(attrs),
     )
 
     render(h(Comp, (attrs = { foo: 'bar' })), root)
     expect(serializeInner(root)).toBe(
-      JSON.stringify(attrs) + Object.keys(attrs)
+      JSON.stringify(attrs) + Object.keys(attrs),
     )
   })
 
@@ -715,12 +715,12 @@ describe('component props', () => {
   test('should not mutate original props long-form definition object', () => {
     const props = {
       msg: {
-        type: String
-      }
+        type: String,
+      },
     }
     const Comp = defineComponent({
       props,
-      render() {}
+      render() {},
     })
 
     const root = nodeOps.createElement('div')
index 4fe63861a7af283cca70f15d571e728c14a0b4d5..37c228a5104ffb42dafebfa944c2029bdbe29f06 100644 (file)
@@ -1,13 +1,16 @@
 import {
-  h,
-  render,
+  createApp,
+  defineComponent,
   getCurrentInstance,
+  h,
   nodeOps,
-  createApp,
+  render,
   shallowReadonly,
-  defineComponent
 } from '@vue/runtime-test'
-import { ComponentInternalInstance, ComponentOptions } from '../src/component'
+import type {
+  ComponentInternalInstance,
+  ComponentOptions,
+} from '../src/component'
 
 describe('component: proxy', () => {
   test('data', () => {
@@ -16,7 +19,7 @@ describe('component: proxy', () => {
     const Comp = {
       data() {
         return {
-          foo: 1
+          foo: 1,
         }
       },
       mounted() {
@@ -25,7 +28,7 @@ describe('component: proxy', () => {
       },
       render() {
         return null
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     expect(instanceProxy.foo).toBe(1)
@@ -39,7 +42,7 @@ describe('component: proxy', () => {
     const Comp = {
       setup() {
         return {
-          foo: 1
+          foo: 1,
         }
       },
       mounted() {
@@ -48,7 +51,7 @@ describe('component: proxy', () => {
       },
       render() {
         return null
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     expect(instanceProxy.foo).toBe(1)
@@ -64,7 +67,7 @@ describe('component: proxy', () => {
       },
       mounted() {
         instanceProxy = this
-      }
+      },
     }
     render(h(Comp, { count: 1 }), nodeOps.createElement('div'))
     expect('count' in instanceProxy).toBe(false)
@@ -80,7 +83,7 @@ describe('component: proxy', () => {
       mounted() {
         instance = getCurrentInstance()!
         instanceProxy = this
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     expect(instanceProxy.$data).toBe(instance!.data)
@@ -89,7 +92,7 @@ describe('component: proxy', () => {
     expect(instanceProxy.$slots).toBe(shallowReadonly(instance!.slots))
     expect(instanceProxy.$refs).toBe(shallowReadonly(instance!.refs))
     expect(instanceProxy.$parent).toBe(
-      instance!.parent && instance!.parent.proxy
+      instance!.parent && instance!.parent.proxy,
     )
     expect(instanceProxy.$root).toBe(instance!.root.proxy)
     expect(instanceProxy.$emit).toBe(instance!.emit)
@@ -114,7 +117,7 @@ describe('component: proxy', () => {
       mounted() {
         instance = getCurrentInstance()!
         instanceProxy = this
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     instanceProxy.foo = 1
@@ -137,7 +140,7 @@ describe('component: proxy', () => {
       mounted() {
         instance = getCurrentInstance()!
         instanceProxy = this
-      }
+      },
     }
 
     const app = createApp(Comp)
@@ -159,21 +162,21 @@ describe('component: proxy', () => {
     const Comp = {
       render() {},
       props: {
-        msg: String
+        msg: String,
       },
       data() {
         return {
-          foo: 0
+          foo: 0,
         }
       },
       setup() {
         return {
-          bar: 1
+          bar: 1,
         }
       },
       mounted() {
         instanceProxy = this
-      }
+      },
     }
 
     const app = createApp(Comp, { msg: 'hello' })
@@ -211,7 +214,7 @@ describe('component: proxy', () => {
       'msg',
       'bar',
       'foo',
-      'baz'
+      'baz',
     ])
   })
 
@@ -221,12 +224,12 @@ describe('component: proxy', () => {
       render() {},
       setup() {
         return {
-          isDisplayed: true
+          isDisplayed: true,
         }
       },
       mounted() {
         instanceProxy = this
-      }
+      },
     }
 
     const app = createApp(Comp)
@@ -244,7 +247,7 @@ describe('component: proxy', () => {
     Object.defineProperty(instanceProxy, 'isDisplayed', {
       get() {
         return false
-      }
+      },
     })
 
     expect(instanceProxy.isDisplayed).toBe(false)
@@ -252,7 +255,7 @@ describe('component: proxy', () => {
     Object.defineProperty(instanceProxy, 'isDisplayed', {
       get() {
         return true
-      }
+      },
     })
 
     expect(instanceProxy.isDisplayed).toBe(true)
@@ -267,12 +270,12 @@ describe('component: proxy', () => {
         return {
           toggle() {
             return 'a'
-          }
+          },
         }
       },
       mounted() {
         instanceProxy = this
-      }
+      },
     }
 
     const app = createApp(Comp)
@@ -289,7 +292,7 @@ describe('component: proxy', () => {
       get() {
         getCalledTimes++
         return () => 'b'
-      }
+      },
     })
 
     // getter should not be evaluated on initial definition
@@ -323,12 +326,12 @@ describe('component: proxy', () => {
       render() {},
       setup() {
         return {
-          toggle: 'a'
+          toggle: 'a',
         }
       },
       mounted() {
         instanceProxy = this
-      }
+      },
     }
 
     const app = createApp(Comp)
@@ -339,14 +342,14 @@ describe('component: proxy', () => {
     expect(v1).toEqual('a')
 
     Object.defineProperty(instanceProxy, 'toggle', {
-      value: 'b'
+      value: 'b',
     })
     const v2 = instanceProxy.toggle
     expect(v2).toEqual('b')
 
     // expect null to be a settable value
     Object.defineProperty(instanceProxy, 'toggle', {
-      value: null
+      value: null,
     })
     const v3 = instanceProxy.toggle
     expect(v3).toBeNull()
@@ -363,21 +366,21 @@ describe('component: proxy', () => {
       computed: {
         greet() {
           return 'Hi ' + (this as any).name
-        }
+        },
       },
       render() {},
       setup() {
         return {
-          fromSetup: true
+          fromSetup: true,
         }
       },
       mounted() {
         instanceProxy = this
-      }
+      },
     }
 
     const app = createApp(Comp, {
-      fromProp: true
+      fromProp: true,
     })
 
     app.mount(nodeOps.createElement('div'))
@@ -387,7 +390,7 @@ describe('component: proxy', () => {
     Object.defineProperty(instanceProxy, 'name', {
       get() {
         return 'getter.name'
-      }
+      },
     })
 
     // computed is same still cached
@@ -403,7 +406,7 @@ describe('component: proxy', () => {
     Object.defineProperty(instanceProxy, 'greet', {
       get() {
         return 'Hi greet.getter.computed'
-      }
+      },
     })
     expect(instanceProxy.greet).toEqual('Hi greet.getter.computed')
 
@@ -412,7 +415,7 @@ describe('component: proxy', () => {
     Object.defineProperty(instanceProxy, 'fromSetup', {
       get() {
         return false
-      }
+      },
     })
     expect(instanceProxy.fromSetup).toBe(false)
 
@@ -421,7 +424,7 @@ describe('component: proxy', () => {
     Object.defineProperty(instanceProxy, 'fromProp', {
       get() {
         return false
-      }
+      },
     })
     expect(instanceProxy.fromProp).toBe(false)
   })
@@ -432,11 +435,11 @@ describe('component: proxy', () => {
       props: ['test'],
       render(this: any) {
         return this.test
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     expect(
-      `was accessed during render but is not defined`
+      `was accessed during render but is not defined`,
     ).not.toHaveBeenWarned()
   })
 
@@ -447,7 +450,7 @@ describe('component: proxy', () => {
           return '1'
         }
         return '2'
-      }
+      },
     }
 
     const app = createApp(Comp)
@@ -455,8 +458,8 @@ describe('component: proxy', () => {
 
     expect(
       `Property ${JSON.stringify(
-        Symbol.unscopables
-      )} was accessed during render ` + `but is not defined on instance.`
+        Symbol.unscopables,
+      )} was accessed during render ` + `but is not defined on instance.`,
     ).toHaveBeenWarned()
   })
 
@@ -466,7 +469,7 @@ describe('component: proxy', () => {
       setup() {
         return {
           __isScriptSetup: true,
-          foo: 1
+          foo: 1,
         }
       },
       mounted() {
@@ -474,7 +477,7 @@ describe('component: proxy', () => {
         try {
           this.foo = 123
         } catch (e) {}
-      }
+      },
     })
     render(h(Comp), nodeOps.createElement('div'))
     expect(`Cannot mutate <script setup> binding "foo"`).toHaveBeenWarned()
index 708fb20c423c048f396be8c19e2a2733bb197194..dde505b48e116414a83c448529bc031c1e6609de 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  ref,
-  render,
+  getCurrentInstance,
   h,
-  nodeOps,
   nextTick,
-  getCurrentInstance
+  nodeOps,
+  ref,
+  render,
 } from '@vue/runtime-test'
 import { normalizeVNode } from '../src/vnode'
 import { createSlots } from '../src/helpers/createSlots'
@@ -16,7 +16,7 @@ describe('component: slots', () => {
       render() {
         instance = getCurrentInstance()
         return h('div')
-      }
+      },
     }
 
     render(h(Comp, null, slots), nodeOps.createElement('div'))
@@ -33,15 +33,15 @@ describe('component: slots', () => {
       _inner: '_inner',
       foo: null,
       header: 'header',
-      footer: ['f1', 'f2']
+      footer: ['f1', 'f2'],
     })
 
     expect(
-      '[Vue warn]: Non-function value encountered for slot "header". Prefer function slots for better performance.'
+      '[Vue warn]: Non-function value encountered for slot "header". Prefer function slots for better performance.',
     ).toHaveBeenWarned()
 
     expect(
-      '[Vue warn]: Non-function value encountered for slot "footer". Prefer function slots for better performance.'
+      '[Vue warn]: Non-function value encountered for slot "footer". Prefer function slots for better performance.',
     ).toHaveBeenWarned()
 
     expect(slots).not.toHaveProperty('_inner')
@@ -49,7 +49,7 @@ describe('component: slots', () => {
     expect(slots.header()).toMatchObject([normalizeVNode('header')])
     expect(slots.footer()).toMatchObject([
       normalizeVNode('f1'),
-      normalizeVNode('f2')
+      normalizeVNode('f2'),
     ])
   })
 
@@ -59,14 +59,14 @@ describe('component: slots', () => {
       render() {
         proxy = getCurrentInstance()
         return h('div')
-      }
+      },
     }
 
     render(
       h(Comp, null, {
-        header: () => 'header'
+        header: () => 'header',
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
 
     expect(proxy.slots.header()).toMatchObject([normalizeVNode('header')])
@@ -76,7 +76,7 @@ describe('component: slots', () => {
     const { slots } = renderWithSlots([h('span')])
 
     expect(
-      '[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.'
+      '[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.',
     ).toHaveBeenWarned()
 
     expect(slots.default()).toMatchObject([normalizeVNode(h('span'))])
@@ -101,16 +101,16 @@ describe('component: slots', () => {
               flag1.value
                 ? {
                     name: 'one',
-                    fn: () => [h('span')]
+                    fn: () => [h('span')],
                   }
                 : {
                     name: 'two',
-                    fn: () => [h('div')]
-                  }
-            ])
-          )
+                    fn: () => [h('div')],
+                  },
+            ]),
+          ),
         ]
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -135,19 +135,19 @@ describe('component: slots', () => {
 
     const oldSlots = {
       header: 'header',
-      footer: undefined
+      footer: undefined,
     }
     const newSlots = {
       header: undefined,
-      footer: 'footer'
+      footer: 'footer',
     }
 
     const Comp = {
       setup() {
         return () => [
-          h(Child, { n: flag1.value }, flag1.value ? oldSlots : newSlots)
+          h(Child, { n: flag1.value }, flag1.value ? oldSlots : newSlots),
         ]
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -158,11 +158,11 @@ describe('component: slots', () => {
     await nextTick()
 
     expect(
-      '[Vue warn]: Non-function value encountered for slot "header". Prefer function slots for better performance.'
+      '[Vue warn]: Non-function value encountered for slot "header". Prefer function slots for better performance.',
     ).toHaveBeenWarned()
 
     expect(
-      '[Vue warn]: Non-function value encountered for slot "footer". Prefer function slots for better performance.'
+      '[Vue warn]: Non-function value encountered for slot "footer". Prefer function slots for better performance.',
     ).toHaveBeenWarned()
 
     expect(instance.slots).not.toHaveProperty('header')
@@ -181,9 +181,9 @@ describe('component: slots', () => {
     const Comp = {
       setup() {
         return () => [
-          h(Child, { n: flag1.value }, flag1.value ? ['header'] : ['footer'])
+          h(Child, { n: flag1.value }, flag1.value ? ['header'] : ['footer']),
         ]
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
 
@@ -193,7 +193,7 @@ describe('component: slots', () => {
     await nextTick()
 
     expect(
-      '[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.'
+      '[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.',
     ).toHaveBeenWarned()
 
     expect(instance.slots.default()).toMatchObject([normalizeVNode('footer')])
@@ -218,11 +218,11 @@ describe('component: slots', () => {
             { n: flag2.value },
             {
               foo: () => 'foo',
-              $stable: true
-            }
-          )
+              $stable: true,
+            },
+          ),
         ]
-      }
+      },
     }
 
     render(h(App), nodeOps.createElement('div'))
index f704025550bfaf8b0224816c15af2709f0148a62..7c389fe1ededdf0e7b1fd9351912bcbe8ccae958 100644 (file)
@@ -1,22 +1,22 @@
 import {
-  nodeOps,
-  render,
-  h,
   BaseTransition,
-  BaseTransitionProps,
-  ref,
+  type BaseTransitionProps,
+  KeepAlive,
+  type TestElement,
+  type VNodeProps,
+  h,
   nextTick,
-  serializeInner,
+  nodeOps,
+  ref,
+  render,
   serialize,
-  VNodeProps,
-  KeepAlive,
-  TestElement
+  serializeInner,
 } from '@vue/runtime-test'
 
 function mount(
   props: BaseTransitionProps,
   slot: () => any,
-  withKeepAlive = false
+  withKeepAlive = false,
 ) {
   const root = nodeOps.createElement('div')
   const show = ref(true)
@@ -28,7 +28,7 @@ function mount(
             return withKeepAlive ? h(KeepAlive, null, slot()) : slot()
           })
         : null
-    }
+    },
   }
   render(h(App), root)
 
@@ -41,7 +41,7 @@ function mockProps(extra: BaseTransitionProps = {}, withKeepAlive = false) {
     doneLeave: Record<string, () => void>
   } = {
     doneEnter: {},
-    doneLeave: {}
+    doneLeave: {},
   }
   const props: BaseTransitionProps = {
     onBeforeEnter: vi.fn(el => {
@@ -66,21 +66,21 @@ function mockProps(extra: BaseTransitionProps = {}, withKeepAlive = false) {
     }),
     onAfterAppear: vi.fn(),
     onAppearCancelled: vi.fn(),
-    ...extra
+    ...extra,
   }
   return {
     props,
-    cbs
+    cbs,
   }
 }
 
 function assertCalls(
   props: BaseTransitionProps,
-  calls: Record<string, number>
+  calls: Record<string, number>,
 ) {
   Object.keys(calls).forEach(key => {
     expect(props[key as keyof BaseTransitionProps]).toHaveBeenCalledTimes(
-      calls[key]
+      calls[key],
     )
   })
 }
@@ -103,7 +103,7 @@ function runTestWithElements(tester: TestFn) {
     trueBranch: () => h('div'),
     falseBranch: () => h('span'),
     trueSerialized: `<div></div>`,
-    falseSerialized: `<span></span>`
+    falseSerialized: `<span></span>`,
   })
 }
 
@@ -116,7 +116,7 @@ function runTestWithComponents(tester: TestFn) {
     trueBranch: () => h(CompA, { msg: 'foo' }),
     falseBranch: () => h(CompB, { msg: 'bar' }),
     trueSerialized: `<div>foo</div>`,
-    falseSerialized: `<span>bar</span>`
+    falseSerialized: `<span>bar</span>`,
   })
 }
 
@@ -125,29 +125,29 @@ function runTestWithKeepAlive(tester: TestFn) {
     setup() {
       const count = ref(0)
       return () => h('div', count.value)
-    }
+    },
   }
   const falseComp = {
     setup() {
       const count = ref(0)
       return () => h('span', count.value)
-    }
+    },
   }
   return tester(
     {
       trueBranch: () => h(trueComp),
       falseBranch: () => h(falseComp),
       trueSerialized: `<div>0</div>`,
-      falseSerialized: `<span>0</span>`
+      falseSerialized: `<span>0</span>`,
     },
-    true /* withKeepAlive: true */
+    true /* withKeepAlive: true */,
   )
 }
 
 describe('BaseTransition', () => {
   test('appear: true w/ appear hooks', () => {
     const { props, cbs } = mockProps({
-      appear: true
+      appear: true,
     })
     mount(props, () => h('div'))
     expect(props.onBeforeAppear).toHaveBeenCalledTimes(1)
@@ -170,7 +170,7 @@ describe('BaseTransition', () => {
       onBeforeAppear: undefined,
       onAppear: undefined,
       onAfterAppear: undefined,
-      onAppearCancelled: undefined
+      onAppearCancelled: undefined,
     })
     mount(props, () => h('div'))
     expect(props.onBeforeEnter).toHaveBeenCalledTimes(1)
@@ -205,7 +205,7 @@ describe('BaseTransition', () => {
               })
             }
           }
-        }
+        },
       }
       return { state, toggle, hooks }
     }
@@ -259,14 +259,14 @@ describe('BaseTransition', () => {
         trueBranch,
         trueSerialized,
         falseBranch,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      mode?: BaseTransitionProps['mode']
+      mode?: BaseTransitionProps['mode'],
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode })
       const { root } = mount(props, () =>
-        toggle.value ? trueBranch() : falseBranch()
+        toggle.value ? trueBranch() : falseBranch(),
       )
 
       // without appear: true, enter hooks should not be called on mount
@@ -309,7 +309,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 1,
         onLeave: 1,
         onAfterLeave: 1,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -318,7 +318,7 @@ describe('BaseTransition', () => {
         trueBranch: () => h('div'),
         trueSerialized: `<div></div>`,
         falseBranch: () => null,
-        falseSerialized: `<!---->`
+        falseSerialized: `<!---->`,
       })
     })
 
@@ -328,7 +328,7 @@ describe('BaseTransition', () => {
         trueBranch: () => h(Comp, { msg: 'hello' }),
         trueSerialized: `<div>hello</div>`,
         falseBranch: () => null,
-        falseSerialized: `<!---->`
+        falseSerialized: `<!---->`,
       })
     })
 
@@ -338,9 +338,9 @@ describe('BaseTransition', () => {
           trueBranch: () => h('div'),
           trueSerialized: `<div></div>`,
           falseBranch: () => null,
-          falseSerialized: `<!---->`
+          falseSerialized: `<!---->`,
         },
-        'in-out'
+        'in-out',
       )
     })
   })
@@ -350,12 +350,12 @@ describe('BaseTransition', () => {
       trueBranch,
       trueSerialized,
       falseBranch = () => null,
-      falseSerialized = `<!---->`
+      falseSerialized = `<!---->`,
     }: ToggleOptions) {
       const toggle = ref(false)
       const { props, cbs } = mockProps()
       const { root } = mount(props, () =>
-        toggle.value ? trueBranch() : falseBranch()
+        toggle.value ? trueBranch() : falseBranch(),
       )
 
       // start enter
@@ -402,7 +402,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 1,
         onLeave: 1,
         onAfterLeave: 1,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -411,7 +411,7 @@ describe('BaseTransition', () => {
         trueBranch: () => h('div'),
         trueSerialized: `<div></div>`,
         falseBranch: () => null,
-        falseSerialized: `<!---->`
+        falseSerialized: `<!---->`,
       })
     })
 
@@ -421,7 +421,7 @@ describe('BaseTransition', () => {
         trueBranch: () => h(Comp, { msg: 'hello' }),
         trueSerialized: `<div>hello</div>`,
         falseBranch: () => null,
-        falseSerialized: `<!---->`
+        falseSerialized: `<!---->`,
       })
     })
   })
@@ -432,16 +432,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({}, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       // without appear: true, enter hooks should not be called on mount
@@ -515,7 +515,7 @@ describe('BaseTransition', () => {
         onLeave: 2,
         onAfterLeave: 2,
         onEnterCancelled: 0,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -538,16 +538,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({}, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       // start toggle
@@ -648,7 +648,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 3,
         onLeave: 3,
         onAfterLeave: withKeepAlive ? 1 : 3,
-        onLeaveCancelled: withKeepAlive ? 2 : 0
+        onLeaveCancelled: withKeepAlive ? 2 : 0,
       })
     }
 
@@ -671,16 +671,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode: 'out-in' }, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       // trigger toggle
@@ -753,7 +753,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 2,
         onLeave: 2,
         onAfterLeave: 2,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -777,16 +777,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode: 'out-in' }, withKeepAlive)
       const { root, unmount } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       // trigger toggle
@@ -835,7 +835,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 1,
         onLeave: 1,
         onAfterLeave: 1,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -855,14 +855,14 @@ describe('BaseTransition', () => {
   describe('mode: "out-in" toggle before finish', () => {
     async function testOutInBeforeFinish(
       { trueBranch, falseBranch, trueSerialized }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode: 'out-in' }, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       // trigger toggle
@@ -907,7 +907,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 1,
         onLeave: 1,
         onAfterLeave: 1,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -930,16 +930,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode: 'out-in' }, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       // double quick toggle
@@ -985,7 +985,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 1,
         onLeave: 1,
         onAfterLeave: 1,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -1008,16 +1008,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode: 'in-out' }, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       toggle.value = false
@@ -1089,7 +1089,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 2,
         onLeave: 2,
         onAfterLeave: 2,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
@@ -1112,16 +1112,16 @@ describe('BaseTransition', () => {
         trueBranch,
         falseBranch,
         trueSerialized,
-        falseSerialized
+        falseSerialized,
       }: ToggleOptions,
-      withKeepAlive = false
+      withKeepAlive = false,
     ) {
       const toggle = ref(true)
       const { props, cbs } = mockProps({ mode: 'in-out' }, withKeepAlive)
       const { root } = mount(
         props,
         () => (toggle.value ? trueBranch() : falseBranch()),
-        withKeepAlive
+        withKeepAlive,
       )
 
       toggle.value = false
@@ -1177,7 +1177,7 @@ describe('BaseTransition', () => {
         onBeforeLeave: 1,
         onLeave: 1,
         onAfterLeave: 1,
-        onLeaveCancelled: 0
+        onLeaveCancelled: 0,
       })
     }
 
index ff8ea74b6228b8062e0603063125ad2b4352ba62..6d3f6a9b8b67f267cb8660a9b08b7ab7c7afd740 100644 (file)
@@ -1,31 +1,31 @@
 import {
-  h,
-  TestElement,
-  nodeOps,
-  render,
-  ref,
+  type Component,
+  type ComponentOptions,
+  type ComponentPublicInstance,
   KeepAlive,
-  serializeInner,
-  nextTick,
-  ComponentOptions,
-  markRaw,
-  inject,
-  defineComponent,
-  ComponentPublicInstance,
-  Ref,
+  type Ref,
+  type TestElement,
   cloneVNode,
-  provide,
-  defineAsyncComponent,
-  Component,
   createApp,
+  defineAsyncComponent,
+  defineComponent,
+  h,
+  inject,
+  markRaw,
+  nextTick,
+  nodeOps,
   onActivated,
-  onUnmounted,
+  onDeactivated,
   onMounted,
+  onUnmounted,
+  provide,
   reactive,
+  ref,
+  render,
+  serializeInner,
   shallowRef,
-  onDeactivated
 } from '@vue/runtime-test'
-import { KeepAliveProps } from '../../src/components/KeepAlive'
+import type { KeepAliveProps } from '../../src/components/KeepAlive'
 
 const timeout = (n: number = 0) => new Promise(r => setTimeout(r, n))
 
@@ -47,7 +47,7 @@ describe('KeepAlive', () => {
       mounted: vi.fn(),
       activated: vi.fn(),
       deactivated: vi.fn(),
-      unmounted: vi.fn()
+      unmounted: vi.fn(),
     }
     two = {
       name: 'two',
@@ -59,11 +59,11 @@ describe('KeepAlive', () => {
       mounted: vi.fn(),
       activated: vi.fn(),
       deactivated: vi.fn(),
-      unmounted: vi.fn()
+      unmounted: vi.fn(),
     }
     views = {
       one,
-      two
+      two,
     }
   })
 
@@ -73,7 +73,7 @@ describe('KeepAlive', () => {
       component.mounted.mock.calls.length,
       component.activated.mock.calls.length,
       component.deactivated.mock.calls.length,
-      component.unmounted.mock.calls.length
+      component.unmounted.mock.calls.length,
     ]).toEqual(callCounts)
   }
 
@@ -83,9 +83,9 @@ describe('KeepAlive', () => {
     const App = {
       render() {
         return h(KeepAlive, null, {
-          default: () => h(views[viewRef.value], { ref: instanceRef })
+          default: () => h(views[viewRef.value], { ref: instanceRef }),
         })
-      }
+      },
     }
     render(h(App), root)
     expect(serializeInner(root)).toBe(`<div>one</div>`)
@@ -106,7 +106,7 @@ describe('KeepAlive', () => {
     const App = {
       render() {
         return toggle.value ? h(KeepAlive, () => h(views[viewRef.value])) : null
-      }
+      },
     }
     render(h(App), root)
 
@@ -147,7 +147,7 @@ describe('KeepAlive', () => {
     const App = {
       render() {
         return toggle.value ? h(KeepAlive, () => h(views[viewRef.value])) : null
-      }
+      },
     }
     render(h(App), root)
 
@@ -190,7 +190,7 @@ describe('KeepAlive', () => {
     const App = {
       render() {
         return h(KeepAlive, () => (toggle.value ? h(one) : null))
-      }
+      },
     }
     render(h(App), root)
 
@@ -225,21 +225,21 @@ describe('KeepAlive', () => {
       render(this: any) {
         return h('div', this.msg)
       },
-      activated: vi.fn()
+      activated: vi.fn(),
     }
     const one = {
       name: 'one',
       data: () => ({ msg: 'one' }),
       render(this: any) {
         return h(two)
-      }
+      },
     }
 
     const toggle = ref(true)
     const App = {
       render() {
         return h(KeepAlive, () => (toggle.value ? h(one) : null))
-      }
+      },
     }
     render(h(App), root)
 
@@ -255,7 +255,7 @@ describe('KeepAlive', () => {
     const App = {
       render() {
         return h(KeepAlive, () => (toggle1.value ? h(one) : null))
-      }
+      },
     }
     render(h(App), root)
 
@@ -335,7 +335,7 @@ describe('KeepAlive', () => {
         return outerRef.value
           ? h(KeepAlive, props, () => h(views[viewRef.value]))
           : null
-      }
+      },
     }
     render(h(App), root)
 
@@ -425,7 +425,7 @@ describe('KeepAlive', () => {
           spyCC.mock.calls.length,
           spyCA.mock.calls.length,
           spyCDA.mock.calls.length,
-          spyCUM.mock.calls.length
+          spyCUM.mock.calls.length,
         ]).toEqual(calls)
       }
 
@@ -436,22 +436,22 @@ describe('KeepAlive', () => {
           created: spyAC,
           activated: spyAA,
           deactivated: spyADA,
-          unmounted: spyAUM
+          unmounted: spyAUM,
         },
         b: {
           render: () => `two`,
           created: spyBC,
           activated: spyBA,
           deactivated: spyBDA,
-          unmounted: spyBUM
+          unmounted: spyBUM,
         },
         c: {
           render: () => `three`,
           created: spyCC,
           activated: spyCA,
           deactivated: spyCDA,
-          unmounted: spyCUM
-        }
+          unmounted: spyCUM,
+        },
       }
 
       const App = {
@@ -459,7 +459,7 @@ describe('KeepAlive', () => {
           return h(KeepAlive, { max: 2 }, () => {
             return h(views[viewRef.value])
           })
-        }
+        },
       }
       render(h(App), root)
       assertCount([1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
@@ -494,11 +494,11 @@ describe('KeepAlive', () => {
           return h(
             KeepAlive,
             {
-              include: includeRef.value
+              include: includeRef.value,
             },
-            () => h(views[viewRef.value])
+            () => h(views[viewRef.value]),
           )
-        }
+        },
       }
       render(h(App), root)
       return { viewRef, includeRef }
@@ -512,11 +512,11 @@ describe('KeepAlive', () => {
           return h(
             KeepAlive,
             {
-              exclude: excludeRef.value
+              exclude: excludeRef.value,
             },
-            () => h(views[viewRef.value])
+            () => h(views[viewRef.value]),
           )
-        }
+        },
       }
       render(h(App), root)
       return { viewRef, excludeRef }
@@ -610,13 +610,13 @@ describe('KeepAlive', () => {
       const one = {
         name: 'one',
         created: vi.fn(),
-        render: () => 'one'
+        render: () => 'one',
       }
 
       const two = {
         // anonymous
         created: vi.fn(),
-        render: () => 'two'
+        render: () => 'two',
       }
 
       const views: any = { one, two }
@@ -627,11 +627,11 @@ describe('KeepAlive', () => {
           return h(
             KeepAlive,
             {
-              include: include ? 'one' : undefined
+              include: include ? 'one' : undefined,
             },
-            () => h(views[viewRef.value])
+            () => h(views[viewRef.value]),
           )
-        }
+        },
       }
       render(h(App), root)
 
@@ -670,7 +670,7 @@ describe('KeepAlive', () => {
     test('should not destroy active instance when pruning cache', async () => {
       const Foo = {
         render: () => 'foo',
-        unmounted: vi.fn()
+        unmounted: vi.fn(),
       }
       const includeRef = ref(['foo'])
       const App = {
@@ -678,11 +678,11 @@ describe('KeepAlive', () => {
           return h(
             KeepAlive,
             {
-              include: includeRef.value
+              include: includeRef.value,
             },
-            () => h(Foo)
+            () => h(Foo),
           )
-        }
+        },
       }
       render(h(App), root)
       // condition: a render where a previous component is reused
@@ -703,7 +703,7 @@ describe('KeepAlive', () => {
         setup() {
           return () =>
             h(KeepAlive, () => (toggle.value ? h(Foo, { n: n.value }) : null))
-        }
+        },
       }
 
       render(h(App), root)
@@ -726,13 +726,13 @@ describe('KeepAlive', () => {
       name: 'Foo',
       render() {
         return h('Foo')
-      }
+      },
     })
     const Bar = markRaw({
       name: 'Bar',
       render() {
         return h('Bar')
-      }
+      },
     })
 
     const spyMounted = vi.fn()
@@ -750,19 +750,19 @@ describe('KeepAlive', () => {
           },
           onVnodeUnmounted() {
             spyUnmounted()
-          }
+          },
         }
 
         return () => {
           const child: any = slots.default!({
-            Component: Component!.value
+            Component: Component!.value,
           })[0]
 
           const innerChild = child.children[0]
           child.children[0] = cloneVNode(innerChild, componentProps)
           return child
         }
-      }
+      },
     })
 
     let toggle: () => void = () => {}
@@ -778,14 +778,14 @@ describe('KeepAlive', () => {
         }
         return {
           component,
-          toggle
+          toggle,
         }
       },
       render() {
         return h(RouterView, null, {
-          default: ({ Component }: any) => h(KeepAlive, null, [h(Component)])
+          default: ({ Component }: any) => h(KeepAlive, null, [h(Component)]),
         })
-      }
+      },
     })
 
     render(h(App), root)
@@ -818,9 +818,9 @@ describe('KeepAlive', () => {
       __scopeId: 'foo',
       render: () => {
         return h(KeepAlive, null, {
-          default: () => h(views[viewRef.value], { ref: instanceRef })
+          default: () => h(views[viewRef.value], { ref: instanceRef }),
         })
-      }
+      },
     }
     render(h(App), root)
     expect(serializeInner(root)).toBe(`<div foo>one</div>`)
@@ -841,7 +841,7 @@ describe('KeepAlive', () => {
       () =>
         new Promise(r => {
           resolve = r as any
-        })
+        }),
     )
 
     const toggle = ref(true)
@@ -849,9 +849,9 @@ describe('KeepAlive', () => {
     const App = {
       render: () => {
         return h(KeepAlive, { include: 'Foo' }, () =>
-          toggle.value ? h(AsyncComp, { ref: instanceRef }) : null
+          toggle.value ? h(AsyncComp, { ref: instanceRef }) : null,
         )
-      }
+      },
     }
 
     render(h(App), root)
@@ -863,7 +863,7 @@ describe('KeepAlive', () => {
       data: () => ({ count: 0 }),
       render() {
         return h('p', this.count)
-      }
+      },
     })
 
     await timeout()
@@ -890,7 +890,7 @@ describe('KeepAlive', () => {
     const app = createApp({
       setup() {
         return () => h(KeepAlive, null, () => h(Child))
-      }
+      },
     })
 
     const Child = {
@@ -899,7 +899,7 @@ describe('KeepAlive', () => {
           throw err
         })
       },
-      render() {}
+      render() {},
     }
 
     app.config.errorHandler = handler
@@ -926,7 +926,7 @@ describe('KeepAlive', () => {
         onActivated(activatedA)
         onDeactivated(deactivatedA)
         return () => 'A'
-      }
+      },
     }
     const B = {
       name: 'B',
@@ -934,7 +934,7 @@ describe('KeepAlive', () => {
         onMounted(mountedB)
         onUnmounted(unmountedB)
         return () => 'B'
-      }
+      },
     }
 
     const include = reactive<string[]>([])
@@ -946,13 +946,13 @@ describe('KeepAlive', () => {
             h(
               KeepAlive,
               {
-                include
+                include,
               },
-              h(current.value)
-            )
+              h(current.value),
+            ),
           ]
         }
-      }
+      },
     })
 
     app.mount(root)
index c986ffdd796a706e56e30607af1adb78ab9e144a..f8f2064ebbddcc5aa630e5022d18b031dc384e2e 100644 (file)
@@ -3,27 +3,27 @@
  */
 
 import {
+  type ComponentOptions,
+  Fragment,
+  KeepAlive,
+  Suspense,
+  type SuspenseProps,
   h,
+  nextTick,
+  nodeOps,
+  onErrorCaptured,
+  onMounted,
+  onUnmounted,
   ref,
-  Suspense,
-  ComponentOptions,
   render,
-  nodeOps,
+  resolveDynamicComponent,
   serializeInner,
-  nextTick,
-  onMounted,
+  shallowRef,
   watch,
   watchEffect,
-  onUnmounted,
-  onErrorCaptured,
-  shallowRef,
-  SuspenseProps,
-  resolveDynamicComponent,
-  Fragment,
-  KeepAlive
 } from '@vue/runtime-test'
 import { createApp, defineComponent } from 'vue'
-import { type RawSlots } from 'packages/runtime-core/src/componentSlots'
+import type { RawSlots } from 'packages/runtime-core/src/componentSlots'
 
 describe('Suspense', () => {
   const deps: Promise<any>[] = []
@@ -35,7 +35,7 @@ describe('Suspense', () => {
   // a simple async factory for testing purposes only.
   function defineAsyncComponent<T extends ComponentOptions>(
     comp: T,
-    delay: number = 0
+    delay: number = 0,
   ) {
     return {
       setup(props: any, { slots }: any) {
@@ -48,7 +48,7 @@ describe('Suspense', () => {
         // an extra tick to avoid race conditions
         deps.push(p.then(() => Promise.resolve()))
         return p
-      }
+      },
     }
   }
 
@@ -56,7 +56,7 @@ describe('Suspense', () => {
     const Async = defineAsyncComponent({
       render() {
         return h('div', 'async')
-      }
+      },
     })
 
     const Comp = {
@@ -64,9 +64,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(Async),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -82,7 +82,7 @@ describe('Suspense', () => {
     const Async = defineAsyncComponent({
       render() {
         return h('div', 'async')
-      }
+      },
     })
 
     const onFallback = vi.fn()
@@ -100,14 +100,14 @@ describe('Suspense', () => {
               onResolve,
               onPending,
               // force displaying the fallback right away
-              timeout: 0
+              timeout: 0,
             },
             {
               default: () => (show.value ? h(Async) : null),
-              fallback: h('div', 'fallback')
-            }
+              fallback: h('div', 'fallback'),
+            },
           )
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -151,7 +151,7 @@ describe('Suspense', () => {
           calls.push('outer mounted')
         })
         return () => h(AsyncInner)
-      }
+      },
     })
 
     const AsyncInner = defineAsyncComponent(
@@ -161,9 +161,9 @@ describe('Suspense', () => {
             calls.push('inner mounted')
           })
           return () => h('div', 'inner')
-        }
+        },
       },
-      10
+      10,
     )
 
     const Comp = {
@@ -171,9 +171,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(AsyncOuter),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -196,7 +196,7 @@ describe('Suspense', () => {
     const Async = defineAsyncComponent({
       render() {
         return h('div', 'async')
-      }
+      },
     })
 
     const onResolve = vi.fn()
@@ -207,14 +207,14 @@ describe('Suspense', () => {
           h(
             Suspense,
             {
-              onResolve
+              onResolve,
             },
             {
               default: h(Async),
-              fallback: h('div', 'fallback')
-            }
+              fallback: h('div', 'fallback'),
+            },
           )
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -243,7 +243,7 @@ describe('Suspense', () => {
           () => {
             calls.push('watch effect')
           },
-          { flush: 'post' }
+          { flush: 'post' },
         )
 
         const count = ref(0)
@@ -252,7 +252,7 @@ describe('Suspense', () => {
           () => {
             calls.push('watch callback')
           },
-          { flush: 'post' }
+          { flush: 'post' },
         )
         count.value++ // trigger the watcher now
 
@@ -266,7 +266,7 @@ describe('Suspense', () => {
 
         await p
         return () => h('div', 'async')
-      }
+      },
     }
 
     const Comp = {
@@ -274,9 +274,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: toggle.value ? h(Async) : null,
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -298,7 +298,7 @@ describe('Suspense', () => {
       `watch effect`,
       `watch callback`,
       `mounted`,
-      'unmounted'
+      'unmounted',
     ])
   })
 
@@ -316,7 +316,7 @@ describe('Suspense', () => {
 
         await p
         return () => h('div', 'async')
-      }
+      },
     }
 
     const Fallback = {
@@ -329,7 +329,7 @@ describe('Suspense', () => {
           calls.push('unmounted')
         })
         return () => h('div', 'fallback')
-      }
+      },
     }
 
     const Comp = {
@@ -337,9 +337,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: toggle.value ? h(Async) : null,
-            fallback: h(Fallback)
+            fallback: h(Fallback),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -358,7 +358,7 @@ describe('Suspense', () => {
       props: { msg: String },
       setup(props: any) {
         return () => h('div', props.msg)
-      }
+      },
     })
 
     const msg = ref('foo')
@@ -368,9 +368,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(Async, { msg: msg.value }),
-            fallback: h('div', `fallback ${msg.value}`)
+            fallback: h('div', `fallback ${msg.value}`),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -404,7 +404,7 @@ describe('Suspense', () => {
           () => {
             calls.push('watch effect')
           },
-          { flush: 'post' }
+          { flush: 'post' },
         )
 
         const count = ref(0)
@@ -413,7 +413,7 @@ describe('Suspense', () => {
           () => {
             calls.push('watch callback')
           },
-          { flush: 'post' }
+          { flush: 'post' },
         )
         count.value++ // trigger the watcher now
 
@@ -427,7 +427,7 @@ describe('Suspense', () => {
 
         await p
         return () => h('div', 'async')
-      }
+      },
     }
 
     const Comp = {
@@ -435,9 +435,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: toggle.value ? h(Async) : null,
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -466,7 +466,7 @@ describe('Suspense', () => {
       setup() {
         onUnmounted(unmounted)
         return () => h('div', 'async')
-      }
+      },
     })
 
     const Comp = {
@@ -475,10 +475,10 @@ describe('Suspense', () => {
           toggle.value
             ? h(Suspense, null, {
                 default: h(Async),
-                fallback: h('div', 'fallback')
+                fallback: h('div', 'fallback'),
               })
             : null
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -506,7 +506,7 @@ describe('Suspense', () => {
         onMounted(mounted)
         onUnmounted(unmounted)
         return () => h('div', 'async')
-      }
+      },
     })
 
     const Comp = {
@@ -515,10 +515,10 @@ describe('Suspense', () => {
           toggle.value
             ? h(Suspense, null, {
                 default: h(Async),
-                fallback: h('div', 'fallback')
+                fallback: h('div', 'fallback'),
               })
             : null
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -552,14 +552,14 @@ describe('Suspense', () => {
         const p = new Promise(r => setTimeout(r, 1))
         await p
         return () => h('div', 'async')
-      }
+      },
     }
 
     const Comp: ComponentOptions<{ data: string }> = {
       props: ['data'],
       setup(props) {
         return () => h(Async, { 'data-test': props.data })
-      }
+      },
     }
 
     const Root = {
@@ -571,9 +571,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(Comp, { data: data.value }),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -593,9 +593,9 @@ describe('Suspense', () => {
             calls.push('outer mounted')
           })
           return () => h('div', 'async outer')
-        }
+        },
       },
-      1
+      1,
     )
 
     const AsyncInner = defineAsyncComponent(
@@ -605,9 +605,9 @@ describe('Suspense', () => {
             calls.push('inner mounted')
           })
           return () => h('div', 'async inner')
-        }
+        },
       },
-      10
+      10,
     )
 
     const Inner = {
@@ -615,9 +615,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(AsyncInner),
-            fallback: h('div', 'fallback inner')
+            fallback: h('div', 'fallback inner'),
           })
-      }
+      },
     }
 
     const Comp = {
@@ -625,9 +625,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h('div', [h(AsyncOuter), h(Inner)]),
-            fallback: h('div', 'fallback outer')
+            fallback: h('div', 'fallback outer'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -637,14 +637,14 @@ describe('Suspense', () => {
     await deps[0]
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>async outer</div><div>fallback inner</div></div>`
+      `<div><div>async outer</div><div>fallback inner</div></div>`,
     )
     expect(calls).toEqual([`outer mounted`])
 
     await Promise.all(deps)
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>async outer</div><div>async inner</div></div>`
+      `<div><div>async outer</div><div>async inner</div></div>`,
     )
     expect(calls).toEqual([`outer mounted`, `inner mounted`])
   })
@@ -659,9 +659,9 @@ describe('Suspense', () => {
             calls.push('outer mounted')
           })
           return () => h('div', 'async outer')
-        }
+        },
       },
-      10
+      10,
     )
 
     const AsyncInner = defineAsyncComponent(
@@ -671,9 +671,9 @@ describe('Suspense', () => {
             calls.push('inner mounted')
           })
           return () => h('div', 'async inner')
-        }
+        },
       },
-      1
+      1,
     )
 
     const Inner = {
@@ -681,9 +681,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(AsyncInner),
-            fallback: h('div', 'fallback inner')
+            fallback: h('div', 'fallback inner'),
           })
-      }
+      },
     }
 
     const Comp = {
@@ -691,9 +691,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h('div', [h(AsyncOuter), h(Inner)]),
-            fallback: h('div', 'fallback outer')
+            fallback: h('div', 'fallback outer'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -708,7 +708,7 @@ describe('Suspense', () => {
     await Promise.all(deps)
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>async outer</div><div>async inner</div></div>`
+      `<div><div>async outer</div><div>async inner</div></div>`,
     )
     expect(calls).toEqual([`inner mounted`, `outer mounted`])
   })
@@ -717,7 +717,7 @@ describe('Suspense', () => {
     const Async = {
       async setup() {
         throw new Error('oops')
-      }
+      },
     }
 
     const Comp = {
@@ -736,9 +736,9 @@ describe('Suspense', () => {
             ? h('div', errorMessage.value)
             : h(Suspense, null, {
                 default: h(Async),
-                fallback: h('div', 'fallback')
+                fallback: h('div', 'fallback'),
               })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -755,7 +755,7 @@ describe('Suspense', () => {
     const Async = {
       async setup() {
         throw new Error('oops')
-      }
+      },
     }
 
     const Comp = {
@@ -781,7 +781,7 @@ describe('Suspense', () => {
           return false
         })
         return { errorMessage }
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -806,9 +806,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(AsyncInsideNestedSuspense, { msg: props.msg }),
-            fallback: h('div', 'nested fallback')
+            fallback: h('div', 'nested fallback'),
           })
-      }
+      },
     })
 
     const AsyncInsideNestedSuspense = defineAsyncComponent(
@@ -819,9 +819,9 @@ describe('Suspense', () => {
             calls.push(2)
           })
           return () => h('div', props.msg)
-        }
+        },
       },
-      20
+      20,
     )
 
     const AsyncChildParent = defineAsyncComponent({
@@ -831,7 +831,7 @@ describe('Suspense', () => {
           calls.push(1)
         })
         return () => h(NestedAsyncChild, { msg: props.msg })
-      }
+      },
     })
 
     const NestedAsyncChild = defineAsyncComponent(
@@ -842,18 +842,18 @@ describe('Suspense', () => {
             calls.push(3)
           })
           return () => h('div', props.msg)
-        }
+        },
       },
-      10
+      10,
     )
 
     const MiddleComponent = {
       setup() {
         return () =>
           h(AsyncChildWithSuspense, {
-            msg: msg.value
+            msg: msg.value,
           })
-      }
+      },
     }
 
     const Comp = {
@@ -863,12 +863,12 @@ describe('Suspense', () => {
             default: h('div', [
               h(MiddleComponent),
               h(AsyncChildParent, {
-                msg: 'root async'
-              })
+                msg: 'root async',
+              }),
             ]),
-            fallback: h('div', 'root fallback')
+            fallback: h('div', 'root fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -899,7 +899,7 @@ describe('Suspense', () => {
     await deps[3]
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>nested fallback</div><div>root async</div></div>`
+      `<div><div>nested fallback</div><div>root async</div></div>`,
     )
     expect(calls).toEqual([0, 1, 3])
 
@@ -910,7 +910,7 @@ describe('Suspense', () => {
     await Promise.all(deps)
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>nested changed</div><div>root async</div></div>`
+      `<div><div>nested changed</div><div>root async</div></div>`,
     )
     expect(calls).toEqual([0, 1, 3, 2])
 
@@ -918,7 +918,7 @@ describe('Suspense', () => {
     msg.value = 'nested changed again'
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>nested changed again</div><div>root async</div></div>`
+      `<div><div>nested changed again</div><div>root async</div></div>`,
     )
   })
 
@@ -935,7 +935,7 @@ describe('Suspense', () => {
           calls.push('foo unmounted')
         })
         return () => h('div', ['foo', h(FooNested)])
-      }
+      },
     })
 
     const FooNested = defineAsyncComponent(
@@ -948,9 +948,9 @@ describe('Suspense', () => {
             calls.push('foo nested unmounted')
           })
           return () => h('div', 'foo nested')
-        }
+        },
       },
-      10
+      10,
     )
 
     const Bar = defineAsyncComponent(
@@ -963,9 +963,9 @@ describe('Suspense', () => {
             calls.push('bar unmounted')
           })
           return () => h('div', 'bar')
-        }
+        },
       },
-      10
+      10,
     )
 
     const Comp = {
@@ -973,9 +973,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: toggle.value ? h(Foo) : h(Bar),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -1008,7 +1008,7 @@ describe('Suspense', () => {
       `foo nested mounted`,
       `bar mounted`,
       `foo nested unmounted`,
-      `foo unmounted`
+      `foo unmounted`,
     ]
     expect(calls).toEqual(tempCalls)
     expect(serializeInner(root)).toBe(`<div>bar</div>`)
@@ -1032,7 +1032,7 @@ describe('Suspense', () => {
       ...tempCalls,
       `foo mounted`,
       `foo nested mounted`,
-      `bar unmounted`
+      `bar unmounted`,
     ])
     expect(serializeInner(root)).toBe(`<div>foo<div>foo nested</div></div>`)
   })
@@ -1051,9 +1051,9 @@ describe('Suspense', () => {
               calls.push(`${name} unmounted`)
             })
             return () => h('div', [name])
-          }
+          },
         },
-        delay
+        delay,
       )
 
     const One = makeComp('one')
@@ -1067,9 +1067,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(view.value),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -1118,9 +1118,9 @@ describe('Suspense', () => {
               calls.push(`${name} unmounted`)
             })
             return () => h('div', [name])
-          }
+          },
         },
-        delay
+        delay,
       )
 
     const One = makeComp('one')
@@ -1133,9 +1133,9 @@ describe('Suspense', () => {
         return () =>
           h(Suspense, null, {
             default: h(view.value),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -1179,9 +1179,9 @@ describe('Suspense', () => {
               calls.push(`${name} unmounted`)
             })
             return () => h('div', [name])
-          }
+          },
         },
-        delay
+        delay,
       )
 
     const One = makeComp('one')
@@ -1195,14 +1195,14 @@ describe('Suspense', () => {
           h(
             Suspense,
             {
-              timeout: 10
+              timeout: 10,
             },
             {
               default: h(view.value),
-              fallback: h('div', 'fallback')
-            }
+              fallback: h('div', 'fallback'),
+            },
           )
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -1237,9 +1237,9 @@ describe('Suspense', () => {
         {
           setup() {
             return () => h('div', [name])
-          }
+          },
         },
-        delay
+        delay,
       )
 
     const One = makeComp('one')
@@ -1254,46 +1254,46 @@ describe('Suspense', () => {
             h(
               Suspense,
               {
-                timeout: 10
+                timeout: 10,
               },
               {
                 default: h(view.value),
-                fallback: h('div', 'fallback')
-              }
+                fallback: h('div', 'fallback'),
+              },
             ),
-            h('div', 'three')
+            h('div', 'three'),
           ])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
     render(h(Comp), root)
     expect(serializeInner(root)).toBe(
-      `<div><div>fallback</div><div>three</div></div>`
+      `<div><div>fallback</div><div>three</div></div>`,
     )
 
     await deps[0]
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>one</div><div>three</div></div>`
+      `<div><div>one</div><div>three</div></div>`,
     )
 
     view.value = Two
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>one</div><div>three</div></div>`
+      `<div><div>one</div><div>three</div></div>`,
     )
 
     await new Promise(r => setTimeout(r, 10))
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>fallback</div><div>three</div></div>`
+      `<div><div>fallback</div><div>three</div></div>`,
     )
 
     await deps[1]
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>two</div><div>three</div></div>`
+      `<div><div>two</div><div>three</div></div>`,
     )
   })
 
@@ -1310,7 +1310,7 @@ describe('Suspense', () => {
       <Suspense>
         <div><span>{{ n }}</span></div>
       </Suspense>
-      `
+      `,
     }
     const root = document.createElement('div')
     createApp(Comp).mount(root)
@@ -1327,13 +1327,13 @@ describe('Suspense', () => {
     const Child = {
       async setup() {
         return () => h('div', 'child')
-      }
+      },
     }
     const Parent = () => h('div', ['parent', toggle.value ? h(Child) : null])
     const Comp = {
       setup() {
         return () => h(Suspense, () => h(Parent))
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -1358,19 +1358,19 @@ describe('Suspense', () => {
       name: 'Child',
       async setup() {
         return () => h('div', 'child')
-      }
+      },
     }
     const Parent = {
       setup() {
         return () => h('div', [h(Child)])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
     render(h(Parent), root)
 
     expect(
-      `A component with async setup() must be nested in a <Suspense>`
+      `A component with async setup() must be nested in a <Suspense>`,
     ).toHaveBeenWarned()
   })
 
@@ -1386,9 +1386,9 @@ describe('Suspense', () => {
             calls.push('innerA mounted')
           })
           return () => h('div', 'innerA')
-        }
+        },
       },
-      10
+      10,
     )
 
     const InnerB = defineAsyncComponent(
@@ -1399,9 +1399,9 @@ describe('Suspense', () => {
             calls.push('innerB mounted')
           })
           return () => h('div', 'innerB')
-        }
+        },
       },
-      10
+      10,
     )
 
     const OuterA = defineAsyncComponent(
@@ -1413,9 +1413,9 @@ describe('Suspense', () => {
           })
           return () =>
             h(Fragment, null, [h('div', 'outerA'), slots.default?.()])
-        }
+        },
       },
-      5
+      5,
     )
 
     const OuterB = defineAsyncComponent(
@@ -1427,9 +1427,9 @@ describe('Suspense', () => {
           })
           return () =>
             h(Fragment, null, [h('div', 'outerB'), slots.default?.()])
-        }
+        },
       },
-      5
+      5,
     )
 
     const outerToggle = ref(false)
@@ -1455,14 +1455,14 @@ describe('Suspense', () => {
                     Suspense,
                     { suspensible: true },
                     {
-                      default: h(innerToggle.value ? InnerB : InnerA)
-                    }
-                  )
-              })
+                      default: h(innerToggle.value ? InnerB : InnerA),
+                    },
+                  ),
+              }),
             ],
-            fallback: h('div', 'fallback outer')
+            fallback: h('div', 'fallback outer'),
           })
-      }
+      },
     }
 
     expected = `<div>fallback outer</div>`
@@ -1487,7 +1487,7 @@ describe('Suspense', () => {
       'outerA created',
       'innerA created',
       'outerA mounted',
-      'innerA mounted'
+      'innerA mounted',
     ])
 
     // toggle outer component
@@ -1533,7 +1533,7 @@ describe('Suspense', () => {
           calls.push('innerA mounted')
         })
         return () => h('div', 'innerA')
-      }
+      },
     })
 
     const InnerB = defineComponent({
@@ -1543,7 +1543,7 @@ describe('Suspense', () => {
           calls.push('innerB mounted')
         })
         return () => h('div', 'innerB')
-      }
+      },
     })
 
     const OuterA = defineComponent({
@@ -1553,7 +1553,7 @@ describe('Suspense', () => {
           calls.push('outerA mounted')
         })
         return () => h(Fragment, null, [h('div', 'outerA'), slots.default?.()])
-      }
+      },
     })
 
     const OuterB = defineComponent({
@@ -1563,7 +1563,7 @@ describe('Suspense', () => {
           calls.push('outerB mounted')
         })
         return () => h(Fragment, null, [h('div', 'outerB'), slots.default?.()])
-      }
+      },
     })
 
     const outerToggle = ref(false)
@@ -1589,14 +1589,14 @@ describe('Suspense', () => {
                     Suspense,
                     { suspensible: true },
                     {
-                      default: h(innerToggle.value ? InnerB : InnerA)
-                    }
-                  )
-              })
+                      default: h(innerToggle.value ? InnerB : InnerA),
+                    },
+                  ),
+              }),
             ],
-            fallback: h('div', 'fallback outer')
+            fallback: h('div', 'fallback outer'),
           })
-      }
+      },
     })
 
     expected = `<div>outerA</div><div>innerA</div>`
@@ -1613,7 +1613,7 @@ describe('Suspense', () => {
       'outerA created',
       'innerA created',
       'innerA mounted',
-      'outerA mounted'
+      'outerA mounted',
     ])
 
     // toggle outer component
@@ -1644,12 +1644,12 @@ describe('Suspense', () => {
     const Async = defineAsyncComponent({
       render() {
         return h('div', 'async')
-      }
+      },
     })
     const Sync = {
       render() {
         return h('div', 'sync')
-      }
+      },
     }
     const components = [Async, Sync]
     const viewRef = ref(0)
@@ -1660,11 +1660,11 @@ describe('Suspense', () => {
           default: () => {
             return h(Suspense, null, {
               default: h(components[viewRef.value]),
-              fallback: h('div', 'Loading-dynamic-components')
+              fallback: h('div', 'Loading-dynamic-components'),
             })
-          }
+          },
         })
-      }
+      },
     }
     render(h(App), root)
     expect(serializeInner(root)).toBe(`<div>Loading-dynamic-components</div>`)
@@ -1698,22 +1698,22 @@ describe('Suspense', () => {
     const Async = defineAsyncComponent({
       render() {
         return h('div', 'async')
-      }
+      },
     })
 
     const Comp = {
       render() {
         return h(Async, { key: key.value })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
     const App = {
       render() {
         return h(Suspense, null, {
-          default: h(Comp, { data: data.value })
+          default: h(Comp, { data: data.value }),
         })
-      }
+      },
     }
     render(h(App), root)
     expect(serializeInner(root)).toBe(`<!---->`)
@@ -1735,12 +1735,12 @@ describe('Suspense', () => {
     function baseCheckWarn(
       shouldWarn: boolean,
       children: RawSlots,
-      props: SuspenseProps | null = null
+      props: SuspenseProps | null = null,
     ) {
       const Comp = {
         setup() {
           return () => h(Suspense, props, children)
-        }
+        },
       }
 
       const root = nodeOps.createElement('div')
@@ -1750,7 +1750,7 @@ describe('Suspense', () => {
         expect(`<Suspense> slots expect a single root node.`).toHaveBeenWarned()
       } else {
         expect(
-          `<Suspense> slots expect a single root node.`
+          `<Suspense> slots expect a single root node.`,
         ).not.toHaveBeenWarned()
       }
     }
@@ -1762,41 +1762,41 @@ describe('Suspense', () => {
     test('does not warn on single child', async () => {
       checkNoWarn({
         default: h('div'),
-        fallback: h('div')
+        fallback: h('div'),
       })
     })
 
     test('does not warn on null', async () => {
       checkNoWarn({
         default: null,
-        fallback: null
+        fallback: null,
       })
     })
 
     test('does not warn on <component :is="null" />', async () => {
       checkNoWarn({
         default: () => [resolveDynamicComponent(null)],
-        fallback: () => null
+        fallback: () => null,
       })
     })
 
     test('does not warn on empty array', async () => {
       checkNoWarn({
         default: [],
-        fallback: () => []
+        fallback: () => [],
       })
     })
 
     test('warns on multiple children in default', async () => {
       checkWarn({
-        default: [h('div'), h('div')]
+        default: [h('div'), h('div')],
       })
     })
 
     test('warns on multiple children in fallback', async () => {
       checkWarn({
         default: h('div'),
-        fallback: [h('div'), h('div')]
+        fallback: [h('div'), h('div')],
       })
     })
   })
index c0dbd4cae9c6f03386d747f67cf66a13e674b90c..9c85cd8beb656c94f6109072758ff5408d294fa1 100644 (file)
@@ -3,20 +3,20 @@
  */
 
 import {
-  nodeOps,
-  serializeInner,
-  render,
-  h,
   Teleport,
   Text,
-  ref,
-  nextTick,
-  markRaw,
+  createApp,
   defineComponent,
+  h,
+  markRaw,
+  nextTick,
+  nodeOps,
+  ref,
+  render,
+  serializeInner,
   withDirectives,
-  createApp
 } from '@vue/runtime-test'
-import { createVNode, Fragment } from '../../src/vnode'
+import { Fragment, createVNode } from '../../src/vnode'
 import { compile, render as domRender } from 'vue'
 
 describe('renderer: teleport', () => {
@@ -27,16 +27,16 @@ describe('renderer: teleport', () => {
     render(
       h(() => [
         h(Teleport, { to: target }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ]),
-      root
+      root,
     )
 
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
   })
 
@@ -49,14 +49,14 @@ describe('renderer: teleport', () => {
       setup() {
         return {
           svg,
-          circle
+          circle,
         }
       },
       template: `
       <svg ref="svg"></svg>
       <teleport :to="svg" v-if="svg">
       <circle ref="circle"></circle>
-      </teleport>`
+      </teleport>`,
     })
 
     domRender(h(Comp), root)
@@ -64,7 +64,7 @@ describe('renderer: teleport', () => {
     await nextTick()
 
     expect(root.innerHTML).toMatchInlineSnapshot(
-      `"<svg><circle></circle></svg><!--teleport start--><!--teleport end-->"`
+      `"<svg><circle></circle></svg><!--teleport start--><!--teleport end-->"`,
     )
 
     expect(svg.value.namespaceURI).toBe('http://www.w3.org/2000/svg')
@@ -80,16 +80,16 @@ describe('renderer: teleport', () => {
     render(
       h(() => [
         h(Teleport, { to: target.value }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ]),
-      root
+      root,
     )
 
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(targetA)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
     expect(serializeInner(targetB)).toMatchInlineSnapshot(`""`)
 
@@ -97,11 +97,11 @@ describe('renderer: teleport', () => {
     await nextTick()
 
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(targetA)).toMatchInlineSnapshot(`""`)
     expect(serializeInner(targetB)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
   })
 
@@ -112,10 +112,10 @@ describe('renderer: teleport', () => {
 
     render(
       h(() => h(Teleport, { to: target }, children.value)),
-      root
+      root,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
 
     children.value = []
@@ -136,10 +136,10 @@ describe('renderer: teleport', () => {
     function testUnmount(props: any) {
       render(
         h(() => [h(Teleport, props, h('div', 'teleported')), h('div', 'root')]),
-        root
+        root,
       )
       expect(serializeInner(target)).toMatchInlineSnapshot(
-        props.disabled ? `""` : `"<div>teleported</div>"`
+        props.disabled ? `""` : `"<div>teleported</div>"`,
       )
 
       render(null, root)
@@ -159,12 +159,12 @@ describe('renderer: teleport', () => {
     const Comp = {
       render() {
         return [h('p'), h('p')]
-      }
+      },
     }
 
     render(
       h(() => [h(Teleport, { to: target }, h(Comp)), h('div', 'root')]),
-      root
+      root,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(`"<p></p><p></p>"`)
 
@@ -181,12 +181,12 @@ describe('renderer: teleport', () => {
         return [h('p'), h('p')]
       },
       beforeUnmount: vi.fn(),
-      unmounted: vi.fn()
+      unmounted: vi.fn(),
     }
 
     render(
       h(() => [h(Teleport, { to: null, disabled: true }, h(CompWithHook))]),
-      root
+      root,
     )
     expect(CompWithHook.beforeUnmount).toBeCalledTimes(0)
     expect(CompWithHook.unmounted).toBeCalledTimes(0)
@@ -204,13 +204,13 @@ describe('renderer: teleport', () => {
     render(
       h('div', [
         h(Teleport, { to: target }, h('div', 'one')),
-        h(Teleport, { to: target }, 'two')
+        h(Teleport, { to: target }, 'two'),
       ]),
-      root
+      root,
     )
 
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--></div>"`
+      `"<div><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--></div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(`"<div>one</div>two"`)
 
@@ -218,18 +218,18 @@ describe('renderer: teleport', () => {
     render(
       h('div', [
         h(Teleport, { to: target }, [h('div', 'one'), h('div', 'two')]),
-        h(Teleport, { to: target }, 'three')
+        h(Teleport, { to: target }, 'three'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>one</div><div>two</div>three"`
+      `"<div>one</div><div>two</div>three"`,
     )
 
     // toggling
     render(h('div', [null, h(Teleport, { to: target }, 'three')]), root)
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div><!----><!--teleport start--><!--teleport end--></div>"`
+      `"<div><!----><!--teleport start--><!--teleport end--></div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(`"three"`)
 
@@ -237,31 +237,31 @@ describe('renderer: teleport', () => {
     render(
       h('div', [
         h(Teleport, { to: target }, [h('div', 'one'), h('div', 'two')]),
-        h(Teleport, { to: target }, 'three')
+        h(Teleport, { to: target }, 'three'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--></div>"`
+      `"<div><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--></div>"`,
     )
     // should append
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"three<div>one</div><div>two</div>"`
+      `"three<div>one</div><div>two</div>"`,
     )
 
     // toggle the other teleport
     render(
       h('div', [
         h(Teleport, { to: target }, [h('div', 'one'), h('div', 'two')]),
-        null
+        null,
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div><!--teleport start--><!--teleport end--><!----></div>"`
+      `"<div><!--teleport start--><!--teleport end--><!----></div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>one</div><div>two</div>"`
+      `"<div>one</div><div>two</div>"`,
     )
   })
 
@@ -278,20 +278,20 @@ describe('renderer: teleport', () => {
             h(
               Teleport,
               { to: target.value, disabled: disabled.value },
-              h('div', 'teleported')
-            )
+              h('div', 'teleported'),
+            ),
           ])
-      }
+      },
     }
     render(h(App), root)
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div></div><!--teleport start--><div>teleported</div><!--teleport end-->"`
+      `"<div></div><!--teleport start--><div>teleported</div><!--teleport end-->"`,
     )
 
     disabled.value = false
     await nextTick()
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div><div>teleported</div></div><!--teleport start--><!--teleport end-->"`
+      `"<div><div>teleported</div></div><!--teleport start--><!--teleport end-->"`,
     )
   })
 
@@ -302,31 +302,31 @@ describe('renderer: teleport', () => {
     const renderWithDisabled = (disabled: boolean) => {
       return h(Fragment, [
         h(Teleport, { to: target, disabled }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ])
     }
 
     render(renderWithDisabled(false), root)
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
 
     render(renderWithDisabled(true), root)
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><div>teleported</div><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><div>teleported</div><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toBe(``)
 
     // toggle back
     render(renderWithDisabled(false), root)
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
   })
 
@@ -337,43 +337,43 @@ describe('renderer: teleport', () => {
     render(
       h(Fragment, [
         h(Teleport, { to: target }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
 
     render(
       h(Fragment, [
         h('div', 'root'),
-        h(Teleport, { to: target }, h('div', 'teleported'))
+        h(Teleport, { to: target }, h('div', 'teleported')),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div>root</div><!--teleport start--><!--teleport end-->"`
+      `"<div>root</div><!--teleport start--><!--teleport end-->"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
 
     render(
       h(Fragment, [
         h(Teleport, { to: target }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
   })
 
@@ -384,36 +384,36 @@ describe('renderer: teleport', () => {
     render(
       h(Fragment, [
         h(Teleport, { to: target, disabled: true }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><div>teleported</div><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><div>teleported</div><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toBe('')
 
     render(
       h(Fragment, [
         h('div', 'root'),
-        h(Teleport, { to: target, disabled: true }, h('div', 'teleported'))
+        h(Teleport, { to: target, disabled: true }, h('div', 'teleported')),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<div>root</div><!--teleport start--><div>teleported</div><!--teleport end-->"`
+      `"<div>root</div><!--teleport start--><div>teleported</div><!--teleport end-->"`,
     )
     expect(serializeInner(target)).toBe('')
 
     render(
       h(Fragment, [
         h(Teleport, { to: target, disabled: true }, h('div', 'teleported')),
-        h('div', 'root')
+        h('div', 'root'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><div>teleported</div><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><div>teleported</div><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toBe('')
   })
@@ -427,7 +427,7 @@ describe('renderer: teleport', () => {
       setup() {
         return {
           target: markRaw(target),
-          disabled
+          disabled,
         }
       },
       render: compile(`
@@ -435,20 +435,20 @@ describe('renderer: teleport', () => {
         <div>teleported</div><span>{{ disabled }}</span><span v-if="disabled"/>
       </teleport>
       <div>root</div>
-      `)
+      `),
     }
     render(h(App), root)
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div><span>false</span><!--v-if-->"`
+      `"<div>teleported</div><span>false</span><!--v-if-->"`,
     )
 
     disabled.value = true
     await nextTick()
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><div>teleported</div><span>true</span><span></span><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><div>teleported</div><span>true</span><span></span><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toBe(``)
 
@@ -456,10 +456,10 @@ describe('renderer: teleport', () => {
     disabled.value = false
     await nextTick()
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end--><div>root</div>"`
+      `"<!--teleport start--><!--teleport end--><div>root</div>"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(
-      `"<div>teleported</div><span>false</span><!--v-if-->"`
+      `"<div>teleported</div><span>false</span><!--v-if-->"`,
     )
   })
 
@@ -470,7 +470,7 @@ describe('renderer: teleport', () => {
     const toggle = ref(true)
     const dir = {
       mounted: vi.fn(),
-      unmounted: vi.fn()
+      unmounted: vi.fn(),
     }
 
     const app = createApp({
@@ -478,16 +478,16 @@ describe('renderer: teleport', () => {
         return () => {
           return toggle.value
             ? h(Teleport, { to: target }, [
-                withDirectives(h('div', ['foo']), [[dir]])
+                withDirectives(h('div', ['foo']), [[dir]]),
               ])
             : null
         }
-      }
+      },
     })
     app.mount(root)
 
     expect(serializeInner(root)).toMatchInlineSnapshot(
-      `"<!--teleport start--><!--teleport end-->"`
+      `"<!--teleport start--><!--teleport end-->"`,
     )
     expect(serializeInner(target)).toMatchInlineSnapshot(`"<div>foo</div>"`)
     expect(dir.mounted).toHaveBeenCalledTimes(1)
@@ -517,16 +517,16 @@ describe('renderer: teleport', () => {
             h(
               Teleport,
               { to: target.value, disabled: disabled.value },
-              h('div', 'teleported')
-            )
+              h('div', 'teleported'),
+            ),
           ])
-      }
+      },
     }
     render(h(App), root)
     disabled.value = false
     await nextTick()
     expect(serializeInner(target1)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
     expect(serializeInner(target2)).toMatchInlineSnapshot(`""`)
     expect(serializeInner(target3)).toMatchInlineSnapshot(`""`)
@@ -550,7 +550,7 @@ describe('renderer: teleport', () => {
     expect(serializeInner(target1)).toMatchInlineSnapshot(`""`)
     expect(serializeInner(target2)).toMatchInlineSnapshot(`""`)
     expect(serializeInner(target3)).toMatchInlineSnapshot(
-      `"<div>teleported</div>"`
+      `"<div>teleported</div>"`,
     )
   })
 })
index 16aeb3ad4bec5fc00d00e066e2cff2707b82e352..8d9982548b5b6c9a0ea1a0fca2b8e454bd4bcddd 100644 (file)
@@ -1,16 +1,19 @@
 import {
+  type DirectiveBinding,
+  type DirectiveHook,
+  type VNode,
+  defineComponent,
   h,
-  withDirectives,
+  nextTick,
+  nodeOps,
   ref,
   render,
-  nodeOps,
-  DirectiveHook,
-  VNode,
-  DirectiveBinding,
-  nextTick,
-  defineComponent
+  withDirectives,
 } from '@vue/runtime-test'
-import { currentInstance, ComponentInternalInstance } from '../src/component'
+import {
+  type ComponentInternalInstance,
+  currentInstance,
+} from '../src/component'
 
 describe('directives', () => {
   it('should work', async () => {
@@ -105,7 +108,7 @@ describe('directives', () => {
       beforeUpdate,
       updated,
       beforeUnmount,
-      unmounted
+      unmounted,
     }
 
     let _instance: ComponentInternalInstance | null = null
@@ -125,11 +128,11 @@ describe('directives', () => {
             // argument
             'foo',
             // modifiers
-            { ok: true }
-          ]
+            { ok: true },
+          ],
         ])
         return _vnode
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -185,11 +188,11 @@ describe('directives', () => {
             // argument
             'foo',
             // modifiers
-            { ok: true }
-          ]
+            { ok: true },
+          ],
         ])
         return _vnode
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -294,7 +297,7 @@ describe('directives', () => {
       beforeUpdate,
       updated,
       beforeUnmount,
-      unmounted
+      unmounted,
     }
 
     let _instance: ComponentInternalInstance | null = null
@@ -320,10 +323,10 @@ describe('directives', () => {
             // argument
             'foo',
             // modifiers
-            { ok: true }
-          ]
+            { ok: true },
+          ],
         ])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -345,22 +348,22 @@ describe('directives', () => {
   // #2298
   it('directive merging on component root', () => {
     const d1 = {
-      mounted: vi.fn()
+      mounted: vi.fn(),
     }
     const d2 = {
-      mounted: vi.fn()
+      mounted: vi.fn(),
     }
     const Comp = {
       render() {
         return withDirectives(h('div'), [[d2]])
-      }
+      },
     }
 
     const App = {
       name: 'App',
       render() {
         return h('div', [withDirectives(h(Comp), [[d1]])])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -379,11 +382,11 @@ describe('directives', () => {
         return withDirectives(h('p', text.value), [
           [
             {
-              beforeUpdate
-            }
-          ]
+              beforeUpdate,
+            },
+          ],
         ])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -402,7 +405,7 @@ describe('directives', () => {
     const App = defineComponent({
       setup(_, { expose }) {
         expose({
-          msg: 'Test'
+          msg: 'Test',
         })
 
         return () =>
@@ -411,11 +414,11 @@ describe('directives', () => {
               {
                 mounted(el, { instance }) {
                   res = (instance as any).msg as string
-                }
-              }
-            ]
+                },
+              },
+            ],
           ])
-      }
+      },
     })
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -424,14 +427,14 @@ describe('directives', () => {
 
   test('should not throw with unknown directive', async () => {
     const d1 = {
-      mounted: vi.fn()
+      mounted: vi.fn(),
     }
     const App = {
       name: 'App',
       render() {
         // simulates the code generated on an unknown directive
         return withDirectives(h('div'), [[undefined], [d1]])
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
index ebbfeb1d08ea1c854838849cd753b9cde88b38c8..d995c5fa057f8280f2850f692734b453d7248056 100644 (file)
@@ -1,15 +1,15 @@
 import {
-  onMounted,
-  onErrorCaptured,
-  render,
+  createApp,
+  defineComponent,
   h,
+  nextTick,
   nodeOps,
-  watch,
+  onErrorCaptured,
+  onMounted,
   ref,
-  nextTick,
-  defineComponent,
+  render,
+  watch,
   watchEffect,
-  createApp
 } from '@vue/runtime-test'
 
 describe('error handling', () => {
@@ -24,7 +24,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -33,7 +33,7 @@ describe('error handling', () => {
           fn(err, info, 'child')
         })
         return () => h(GrandChild)
-      }
+      },
     }
 
     const GrandChild = {
@@ -42,7 +42,7 @@ describe('error handling', () => {
           throw err
         })
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -62,7 +62,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -72,7 +72,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(GrandChild)
-      }
+      },
     }
 
     const GrandChild = {
@@ -81,7 +81,7 @@ describe('error handling', () => {
           throw err
         })
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -100,7 +100,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -109,7 +109,7 @@ describe('error handling', () => {
           throw err
         })
       },
-      render() {}
+      render() {},
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -130,7 +130,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -139,7 +139,7 @@ describe('error handling', () => {
           throw err2
         })
         return () => h(GrandChild)
-      }
+      },
     }
 
     const GrandChild = {
@@ -148,7 +148,7 @@ describe('error handling', () => {
           throw err
         })
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -168,14 +168,14 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
       setup() {
         throw err
       },
-      render() {}
+      render() {},
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -195,21 +195,21 @@ describe('error handling', () => {
           return false
         })
         return () => [h(Child1), h(Child2)]
-      }
+      },
     }
 
     const Child1 = {
       created() {
         throw err
       },
-      render() {}
+      render() {},
     }
 
     const Child2 = {
       beforeCreate() {
         throw err
       },
-      render() {}
+      render() {},
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -228,7 +228,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -236,7 +236,7 @@ describe('error handling', () => {
         return () => {
           throw err
         }
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -257,7 +257,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = defineComponent(() => () => h('div', { ref }))
@@ -277,7 +277,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -286,7 +286,7 @@ describe('error handling', () => {
           throw err
         })
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -304,7 +304,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -313,10 +313,10 @@ describe('error handling', () => {
           () => {
             throw err
           },
-          () => {}
+          () => {},
         )
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -334,7 +334,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const count = ref(0)
@@ -344,10 +344,10 @@ describe('error handling', () => {
           () => count.value,
           () => {
             throw err
-          }
+          },
         )
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -369,7 +369,7 @@ describe('error handling', () => {
           return false
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
@@ -381,7 +381,7 @@ describe('error handling', () => {
           })
         })
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -405,16 +405,16 @@ describe('error handling', () => {
           h(Child, {
             onFoo: () => {
               throw err
-            }
+            },
           })
-      }
+      },
     }
 
     const Child = {
       setup(props: any, { emit }: any) {
         emit('foo')
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -435,9 +435,9 @@ describe('error handling', () => {
           h(Child, {
             async onFoo() {
               throw err
-            }
+            },
           })
-      }
+      },
     }
 
     const Child = {
@@ -445,7 +445,7 @@ describe('error handling', () => {
       setup(props: any, { emit }: any) {
         emit('foo')
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -473,17 +473,17 @@ describe('error handling', () => {
           h(Child, {
             onFoo: [
               createAsyncHandler(Promise.reject(err)),
-              createAsyncHandler(Promise.resolve(1))
-            ]
+              createAsyncHandler(Promise.resolve(1)),
+            ],
           })
-      }
+      },
     }
 
     const Child = {
       setup(props: any, { emit }: any) {
         emit('foo')
         return () => null
-      }
+      },
     }
 
     render(h(Comp), nodeOps.createElement('div'))
@@ -511,14 +511,14 @@ describe('error handling', () => {
           fn(err, info)
         })
         return () => h(Child)
-      }
+      },
     }
 
     const Child = {
       setup() {
         throw err
       },
-      render() {}
+      render() {},
     }
 
     let caughtError
@@ -529,7 +529,7 @@ describe('error handling', () => {
     }
     expect(fn).toHaveBeenCalledWith(err, 'setup function')
     expect(
-      `Unhandled error during execution of setup function`
+      `Unhandled error during execution of setup function`,
     ).toHaveBeenWarned()
     expect(caughtError).toBe(err)
 
@@ -553,14 +553,14 @@ describe('error handling', () => {
           () => {
             throw error1
           },
-          { immediate: true }
+          { immediate: true },
         )
         watch(
           count,
           async () => {
             throw error2
           },
-          { immediate: true }
+          { immediate: true },
         )
         watchEffect(() => {
           throw error3
@@ -569,7 +569,7 @@ describe('error handling', () => {
           throw error4
         })
       },
-      render() {}
+      render() {},
     })
 
     app.config.errorHandler = handler
index 21eab3c56869deacfbd775b2a73086f5c4f86bdc..ee2dabe2f3e9b9528066d86aec9b677f2a7b50e0 100644 (file)
@@ -1,6 +1,6 @@
 import { h } from '../src/h'
 import { createVNode } from '../src/vnode'
-import { RawSlots } from '../src/componentSlots'
+import type { RawSlots } from '../src/componentSlots'
 
 // Since h is a thin layer on top of createVNode, we are only testing its
 // own logic here. Details of vnode creation is tested in vnode.spec.ts.
@@ -11,7 +11,7 @@ describe('renderer: h', () => {
 
   test('type + props', () => {
     expect(h('div', { id: 'foo' })).toMatchObject(
-      createVNode('div', { id: 'foo' })
+      createVNode('div', { id: 'foo' }),
     )
   })
 
@@ -37,12 +37,12 @@ describe('renderer: h', () => {
     expect(h('div', {}, slots)).toMatchObject(createVNode('div', {}, slots))
     const Component = { template: '<br />' }
     expect(h(Component, {}, slots)).toMatchObject(
-      createVNode(Component, {}, slots)
+      createVNode(Component, {}, slots),
     )
     // default slot
     const slot = () => {}
     expect(h(Component, {}, slot)).toMatchObject(
-      createVNode(Component, {}, slot)
+      createVNode(Component, {}, slot),
     )
     // single vnode
     const vnode = h('div')
@@ -56,12 +56,12 @@ describe('renderer: h', () => {
     const slot = () => {}
     expect(
       h(Component, null, {
-        foo: slot
-      })
+        foo: slot,
+      }),
     ).toMatchObject(
       createVNode(Component, null, {
-        foo: slot
-      })
+        foo: slot,
+      }),
     )
   })
 
@@ -69,15 +69,15 @@ describe('renderer: h', () => {
   // note this signature is not supported in types; it's purely for usage with
   // compiled code.
   test('support variadic children', () => {
-    // @ts-ignore
+    // @ts-expect-error
     const vnode = h('div', null, h('span'), h('span'))
     expect(vnode.children).toMatchObject([
       {
-        type: 'span'
+        type: 'span',
       },
       {
-        type: 'span'
-      }
+        type: 'span',
+      },
     ])
   })
 })
index 2af24380cca5ec8ba9a5d82b0000d25c661e669c..85018854eae3cb7151697ee03d070790bc898d64 100644 (file)
@@ -1,4 +1,4 @@
-import { Slot } from '../../src/componentSlots'
+import type { Slot } from '../../src/componentSlots'
 import { createSlots } from '../../src/helpers/createSlots'
 
 describe('createSlot', () => {
@@ -22,7 +22,7 @@ describe('createSlot', () => {
 
     const actual = createSlots(record, dynamicSlot)
     const ret = actual.descriptor()
-    // @ts-ignore
+    // @ts-expect-error
     expect(ret.key).toBe('1')
   })
 
@@ -37,7 +37,7 @@ describe('createSlot', () => {
   it('should add all slots to the record', () => {
     const dynamicSlot = [
       { name: 'descriptor', fn: slot },
-      { name: 'descriptor2', fn: slot }
+      { name: 'descriptor2', fn: slot },
     ]
 
     const actual = createSlots(record, dynamicSlot)
@@ -48,7 +48,7 @@ describe('createSlot', () => {
   it('should add slot to the record when given slot is an array', () => {
     const dynamicSlot = [
       { name: 'descriptor', fn: slot },
-      [{ name: 'descriptor2', fn: slot }]
+      [{ name: 'descriptor2', fn: slot }],
     ]
 
     const actual = createSlots(record, dynamicSlot)
@@ -61,8 +61,8 @@ describe('createSlot', () => {
       { name: 'descriptor', fn: slot },
       [
         { name: 'descriptor2', fn: slot },
-        { name: 'descriptor3', fn: slot }
-      ]
+        { name: 'descriptor3', fn: slot },
+      ],
     ]
 
     const actual = createSlots(record, dynamicSlot)
@@ -70,7 +70,7 @@ describe('createSlot', () => {
     expect(actual).toEqual({
       descriptor: slot,
       descriptor2: slot,
-      descriptor3: slot
+      descriptor3: slot,
     })
   })
 })
index ae487b6be23c76fd9127fd0936511c65d9d8e728..d23a63cc08e02e31fc925b3d8b25a5567e75d965 100644 (file)
@@ -3,13 +3,13 @@ import { renderList } from '../../src/helpers/renderList'
 describe('renderList', () => {
   it('should render items in an array', () => {
     expect(
-      renderList(['1', '2', '3'], (item, index) => `node ${index}: ${item}`)
+      renderList(['1', '2', '3'], (item, index) => `node ${index}: ${item}`),
     ).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
   })
 
   it('should render characters of a string', () => {
     expect(
-      renderList('123', (item, index) => `node ${index}: ${item}`)
+      renderList('123', (item, index) => `node ${index}: ${item}`),
     ).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
   })
 
@@ -17,7 +17,7 @@ describe('renderList', () => {
     expect(renderList(3, (item, index) => `node ${index}: ${item}`)).toEqual([
       'node 0: 1',
       'node 1: 2',
-      'node 2: 3'
+      'node 2: 3',
     ])
   })
 
@@ -26,7 +26,7 @@ describe('renderList', () => {
       renderList(3.1, () => {})
     } catch (e) {}
     expect(
-      `The v-for range expect an integer value but got 3.1.`
+      `The v-for range expect an integer value but got 3.1.`,
     ).toHaveBeenWarned()
   })
 
@@ -34,8 +34,8 @@ describe('renderList', () => {
     expect(
       renderList(
         { a: 1, b: 2, c: 3 },
-        (item, key, index) => `node ${index}/${key}: ${item}`
-      )
+        (item, key, index) => `node ${index}/${key}: ${item}`,
+      ),
     ).toEqual(['node 0/a: 1', 'node 1/b: 2', 'node 2/c: 3'])
   })
 
@@ -47,13 +47,13 @@ describe('renderList', () => {
     }
 
     expect(
-      renderList(iterable(), (item, index) => `node ${index}: ${item}`)
+      renderList(iterable(), (item, index) => `node ${index}: ${item}`),
     ).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
   })
 
   it('should return empty array when source is undefined', () => {
     expect(
-      renderList(undefined, (item, index) => `node ${index}: ${item}`)
+      renderList(undefined, (item, index) => `node ${index}: ${item}`),
     ).toEqual([])
   })
 })
index 4e661c406e634cfa9f298b0f88a6410f5a447c3b..b6183ac3c3677a7f770e0cf5dc130c558f5405fa 100644 (file)
@@ -1,13 +1,13 @@
 import { renderSlot } from '../../src/helpers/renderSlot'
 import {
-  h,
-  withCtx,
-  createVNode,
-  openBlock,
-  createBlock,
   Fragment,
+  type Slot,
+  createBlock,
   createCommentVNode,
-  Slot
+  createVNode,
+  h,
+  openBlock,
+  withCtx,
 } from '../../src'
 import { PatchFlags } from '@vue/shared'
 import { setCurrentRenderingInstance } from '../../src/componentRenderContext'
@@ -25,7 +25,7 @@ describe('renderSlot', () => {
     let child
     const vnode = renderSlot(
       { default: () => [(child = h('child'))] },
-      'default'
+      'default',
     )
     expect(vnode.children).toEqual([child])
   })
@@ -47,7 +47,7 @@ describe('renderSlot', () => {
         return [createVNode('div', null, 'foo', PatchFlags.TEXT)]
       },
       // mock instance
-      { type: {}, appContext: {} } as any
+      { type: {}, appContext: {} } as any,
     ) as Slot
 
     // manual invocation should not track
@@ -67,7 +67,7 @@ describe('renderSlot', () => {
         { default: () => [createCommentVNode('foo')] },
         'default',
         undefined,
-        () => [(fallback = h('fallback'))]
+        () => [(fallback = h('fallback'))],
       )
       expect(vnode.children).toEqual([fallback])
       expect(vnode.patchFlag).toBe(PatchFlags.BAIL)
@@ -79,7 +79,7 @@ describe('renderSlot', () => {
         { default: () => [renderSlot({}, 'foo')] },
         'default',
         undefined,
-        () => [(fallback = h('fallback'))]
+        () => [(fallback = h('fallback'))],
       )
       expect(vnode.children).toEqual([fallback])
       expect(vnode.patchFlag).toBe(PatchFlags.BAIL)
index fdcde4639fcfba87ae9e89e31db256333f68c7d9..d77c6034b43112603e5221b092e9a22b22f2c341 100644 (file)
@@ -1,16 +1,16 @@
 import {
+  Comment,
+  type Component,
+  type Directive,
+  type VNode,
   createApp,
+  createVNode,
+  h,
   nodeOps,
   resolveComponent,
   resolveDirective,
-  Component,
-  Directive,
   resolveDynamicComponent,
-  h,
   serializeInner,
-  createVNode,
-  Comment,
-  VNode
 } from '@vue/runtime-test'
 
 describe('resolveAssets', () => {
@@ -29,10 +29,10 @@ describe('resolveAssets', () => {
 
     const Root = {
       components: {
-        FooBar: FooBar
+        FooBar: FooBar,
       },
       directives: {
-        BarBaz: BarBaz
+        BarBaz: BarBaz,
       },
       setup() {
         return () => {
@@ -48,7 +48,7 @@ describe('resolveAssets', () => {
           component4 = resolveComponent('foo-bar')!
           directive4 = resolveDirective('bar-baz')!
         }
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -76,7 +76,7 @@ describe('resolveAssets', () => {
       name: 'Root',
       components: {
         Foo,
-        Root: Foo
+        Root: Foo,
       },
       setup() {
         return () => {
@@ -84,7 +84,7 @@ describe('resolveAssets', () => {
           component2 = resolveComponent('Foo', true)
           component3 = resolveComponent('Bar', true)
         }
-      }
+      },
     }
 
     const app = createApp(Root)
@@ -100,12 +100,12 @@ describe('resolveAssets', () => {
     test('used outside render() or setup()', () => {
       resolveComponent('foo')
       expect(
-        'resolveComponent can only be used in render() or setup().'
+        'resolveComponent can only be used in render() or setup().',
       ).toHaveBeenWarned()
 
       resolveDirective('foo')
       expect(
-        'resolveDirective can only be used in render() or setup().'
+        'resolveDirective can only be used in render() or setup().',
       ).toHaveBeenWarned()
     })
 
@@ -115,7 +115,7 @@ describe('resolveAssets', () => {
           resolveComponent('foo')
           resolveDirective('bar')
           return () => null
-        }
+        },
       }
 
       const app = createApp(Root)
@@ -129,7 +129,7 @@ describe('resolveAssets', () => {
       const dynamicComponents = {
         foo: () => 'foo',
         bar: () => 'bar',
-        baz: { render: () => 'baz' }
+        baz: { render: () => 'baz' },
       }
       let foo, bar, baz // dynamic components
       let dynamicVNode: VNode
@@ -137,7 +137,7 @@ describe('resolveAssets', () => {
       const Child = {
         render(this: any) {
           return this.$slots.default()
-        }
+        },
       }
 
       const Root = {
@@ -152,7 +152,7 @@ describe('resolveAssets', () => {
               baz = resolveDynamicComponent(dynamicComponents.baz) // <component :is="baz"/>, object
             })
           }
-        }
+        },
       }
 
       const app = createApp(Root)
@@ -170,10 +170,10 @@ describe('resolveAssets', () => {
         setup() {
           return () => {
             return createVNode(resolveDynamicComponent('div') as string, null, {
-              default: () => 'hello'
+              default: () => 'hello',
             })
           }
-        }
+        },
       }
 
       const app = createApp(Root)
@@ -198,13 +198,13 @@ describe('resolveAssets', () => {
 
     const Base = {
       components: {
-        FooBar: FooBar
-      }
+        FooBar: FooBar,
+      },
     }
     const Mixin = {
       directives: {
-        BarBaz: BarBaz
-      }
+        BarBaz: BarBaz,
+      },
     }
 
     const Root = {
@@ -224,7 +224,7 @@ describe('resolveAssets', () => {
           component4 = resolveComponent('foo-bar')!
           directive4 = resolveDirective('bar-baz')!
         }
-      }
+      },
     }
 
     const app = createApp(Root)
index 3dc5bb5172b6e611189a5caa2c025bb2021db858..f1e95e5164a76d6985c2fe20e6d0afbce96b4e3b 100644 (file)
@@ -6,7 +6,7 @@ describe('toHandlers', () => {
     toHandlers(undefined as any)
 
     expect(
-      'v-on with no argument expects an object value.'
+      'v-on with no argument expects an object value.',
     ).toHaveBeenWarnedTimes(2)
   })
 
@@ -16,7 +16,7 @@ describe('toHandlers', () => {
 
     expect(toHandlers({ input, change })).toStrictEqual({
       onInput: input,
-      onChange: change
+      onChange: change,
     })
   })
 })
index 60b5132bd5eadb8ca0f25f522af679fef63a648a..f4f356dea4fa5a382d1c18f795d8afd6b1bcd7bc 100644 (file)
@@ -4,7 +4,7 @@
 
 // since v-memo really is a compiler + runtime combo feature, we are performing
 // more of an integration test here.
-import { ComponentOptions, createApp, nextTick } from 'vue'
+import { type ComponentOptions, createApp, nextTick } from 'vue'
 
 describe('v-memo', () => {
   function mount(options: ComponentOptions): [HTMLElement, any] {
@@ -17,7 +17,7 @@ describe('v-memo', () => {
   test('on with external array', async () => {
     const [el, vm] = mount({
       template: `<div v-memo="arr">{{ arr[0] }} {{ arr[1] }} {{arr[2] ?? '_' }} ({{c}})</div>{{c}}`,
-      data: () => ({ arr: [0, 0], c: 0 })
+      data: () => ({ arr: [0, 0], c: 0 }),
     })
     expect(el.innerHTML).toBe(`<div>0 0 _ (0)</div>0`)
 
@@ -58,7 +58,7 @@ describe('v-memo', () => {
   test('on normal element', async () => {
     const [el, vm] = mount({
       template: `<div v-memo="[x]">{{ x }} {{ y }}</div>`,
-      data: () => ({ x: 0, y: 0 })
+      data: () => ({ x: 0, y: 0 }),
     })
     expect(el.innerHTML).toBe(`<div>0 0</div>`)
 
@@ -85,9 +85,9 @@ describe('v-memo', () => {
       components: {
         Comp: {
           props: ['x', 'y'],
-          template: `<div>{{x}} {{y}}</div>`
-        }
-      }
+          template: `<div>{{x}} {{y}}</div>`,
+        },
+      },
     })
     expect(el.innerHTML).toBe(`<div>0 0</div>`)
 
@@ -111,7 +111,7 @@ describe('v-memo', () => {
     const [el, vm] = mount({
       template: `<div v-if="ok" v-memo="[x]">{{ x }} {{ y }}</div>
         <div v-else v-memo="[y]">{{ y }} {{ x }}</div>`,
-      data: () => ({ ok: true, x: 0, y: 0 })
+      data: () => ({ ok: true, x: 0, y: 0 }),
     })
     expect(el.innerHTML).toBe(`<div>0 0</div>`)
 
@@ -159,37 +159,37 @@ describe('v-memo', () => {
       data: () => ({
         list: [{ x: 1 }, { x: 2 }, { x: 3 }],
         y: 1,
-        z: 'z'
-      })
+        z: 'z',
+      }),
     })
     expect(el.innerHTML).toBe(
-      `<div>1 yes z</div><div>2 no z</div><div>3 no z</div>`
+      `<div>1 yes z</div><div>2 no z</div><div>3 no z</div>`,
     )
 
     vm.y = 2
     await nextTick()
     expect(el.innerHTML).toBe(
-      `<div>1 no z</div><div>2 yes z</div><div>3 no z</div>`
+      `<div>1 no z</div><div>2 yes z</div><div>3 no z</div>`,
     )
 
     vm.list[0].x = 4
     await nextTick()
     expect(el.innerHTML).toBe(
-      `<div>4 no z</div><div>2 yes z</div><div>3 no z</div>`
+      `<div>4 no z</div><div>2 yes z</div><div>3 no z</div>`,
     )
 
     vm.list[0].x = 5
     vm.y = 5
     await nextTick()
     expect(el.innerHTML).toBe(
-      `<div>5 yes z</div><div>2 no z</div><div>3 no z</div>`
+      `<div>5 yes z</div><div>2 no z</div><div>3 no z</div>`,
     )
 
     vm.z = 'zz'
     await nextTick()
     // should not update
     expect(el.innerHTML).toBe(
-      `<div>5 yes z</div><div>2 no z</div><div>3 no z</div>`
+      `<div>5 yes z</div><div>2 no z</div><div>3 no z</div>`,
     )
   })
 
@@ -199,8 +199,8 @@ describe('v-memo', () => {
           {{count}}
         </div>`,
       data: () => ({
-        count: 0
-      })
+        count: 0,
+      }),
     })
     expect(el.innerHTML).toBe(`<div>0</div><div>0</div><div>0</div>`)
 
@@ -218,7 +218,7 @@ describe('v-memo', () => {
   test('v-memo dependency is NaN should be equal', async () => {
     const [el, vm] = mount({
       template: `<div v-memo="[x]">{{ y }}</div>`,
-      data: () => ({ x: NaN, y: 0 })
+      data: () => ({ x: NaN, y: 0 }),
     })
     expect(el.innerHTML).toBe(`<div>0</div>`)
 
index f11e7e5701f9c5579018b3e616a6155654bd9d6b..000fbf40bf8bfe7e33b1e4268e5a2b36bd6df139 100644 (file)
@@ -1,17 +1,17 @@
-import { HMRRuntime } from '../src/hmr'
+import type { HMRRuntime } from '../src/hmr'
 import '../src/hmr'
-import { ComponentOptions, InternalRenderFunction } from '../src/component'
+import type { ComponentOptions, InternalRenderFunction } from '../src/component'
 import {
-  render,
-  nodeOps,
+  type TestElement,
   h,
+  nextTick,
+  nodeOps,
+  render,
   serializeInner,
   triggerEvent,
-  TestElement,
-  nextTick
 } from '@vue/runtime-test'
 import * as runtimeTest from '@vue/runtime-test'
-import { registerRuntimeCompiler, createApp } from '@vue/runtime-test'
+import { createApp, registerRuntimeCompiler } from '@vue/runtime-test'
 import { baseCompile } from '@vue/compiler-core'
 
 declare var __VUE_HMR_RUNTIME__: HMRRuntime
@@ -22,7 +22,7 @@ registerRuntimeCompiler(compileToFunction)
 function compileToFunction(template: string) {
   const { code } = baseCompile(template, { hoistStatic: true, hmr: true })
   const render = new Function('Vue', code)(
-    runtimeTest
+    runtimeTest,
   ) as InternalRenderFunction
   render._rc = true // isRuntimeCompiled
   return render
@@ -48,7 +48,7 @@ describe('hot module replacement', () => {
 
     const Child: ComponentOptions = {
       __hmrId: childId,
-      render: compileToFunction(`<div><slot/></div>`)
+      render: compileToFunction(`<div><slot/></div>`),
     }
     createRecord(childId, Child)
 
@@ -59,8 +59,8 @@ describe('hot module replacement', () => {
       },
       components: { Child },
       render: compileToFunction(
-        `<div @click="count++">{{ count }}<Child>{{ count }}</Child></div>`
-      )
+        `<div @click="count++">{{ count }}<Child>{{ count }}</Child></div>`,
+      ),
     }
     createRecord(parentId, Parent)
 
@@ -77,8 +77,8 @@ describe('hot module replacement', () => {
     rerender(
       parentId,
       compileToFunction(
-        `<div @click="count++">{{ count }}!<Child>{{ count }}</Child></div>`
-      )
+        `<div @click="count++">{{ count }}!<Child>{{ count }}</Child></div>`,
+      ),
     )
     expect(serializeInner(root)).toBe(`<div>1!<div>1</div></div>`)
 
@@ -86,8 +86,8 @@ describe('hot module replacement', () => {
     rerender(
       parentId,
       compileToFunction(
-        `<div @click="count++">{{ count }}!<Child>{{ count }}!</Child></div>`
-      )
+        `<div @click="count++">{{ count }}!<Child>{{ count }}!</Child></div>`,
+      ),
     )
     expect(serializeInner(root)).toBe(`<div>1!<div>1!</div></div>`)
 
@@ -97,8 +97,8 @@ describe('hot module replacement', () => {
       compileToFunction(
         `<div @click="count++">{{ count }}<span>{{ count }}</span>
         <Child>{{ count }}!</Child>
-      </div>`
-      )
+      </div>`,
+      ),
     )
     expect(serializeInner(root)).toBe(`<div>1<span>1</span><div>1!</div></div>`)
 
@@ -108,8 +108,8 @@ describe('hot module replacement', () => {
       compileToFunction(
         `<div @click="count++">
         <Child><span>{{ count }}</span></Child>
-      </div>`
-      )
+      </div>`,
+      ),
     )
     expect(serializeInner(root)).toBe(`<div><div><span>1</span></div></div>`)
   })
@@ -126,12 +126,12 @@ describe('hot module replacement', () => {
         return { count: 0 }
       },
       unmounted: unmountSpy,
-      render: compileToFunction(`<div @click="count++">{{ count }}</div>`)
+      render: compileToFunction(`<div @click="count++">{{ count }}</div>`),
     }
     createRecord(childId, Child)
 
     const Parent: ComponentOptions = {
-      render: () => h(Child)
+      render: () => h(Child),
     }
 
     render(h(Parent), root)
@@ -143,7 +143,7 @@ describe('hot module replacement', () => {
         return { count: 1 }
       },
       mounted: mountSpy,
-      render: compileToFunction(`<div @click="count++">{{ count }}</div>`)
+      render: compileToFunction(`<div @click="count++">{{ count }}</div>`),
     })
     await nextTick()
     expect(serializeInner(root)).toBe(`<div>1</div>`)
@@ -166,7 +166,7 @@ describe('hot module replacement', () => {
         return { count: 0 }
       },
       unmounted: unmountSpy,
-      render: compileToFunction(`<div>{{ count }}</div>`)
+      render: compileToFunction(`<div>{{ count }}</div>`),
     }
     createRecord(childId, Child)
 
@@ -177,8 +177,8 @@ describe('hot module replacement', () => {
       },
       render: compileToFunction(
         `<button @click="toggle = !toggle" />
-        <KeepAlive><Child v-if="toggle" /></KeepAlive>`
-      )
+        <KeepAlive><Child v-if="toggle" /></KeepAlive>`,
+      ),
     }
 
     render(h(Parent), root)
@@ -193,7 +193,7 @@ describe('hot module replacement', () => {
       unmounted: unmountSpy,
       activated: activeSpy,
       deactivated: deactiveSpy,
-      render: compileToFunction(`<div>{{ count }}</div>`)
+      render: compileToFunction(`<div>{{ count }}</div>`),
     })
     await nextTick()
     expect(serializeInner(root)).toBe(`<button></button><div>1</div>`)
@@ -234,7 +234,7 @@ describe('hot module replacement', () => {
         return { count: 0 }
       },
       unmounted: unmountSpy,
-      render: compileToFunction(`<div>{{ count }}</div>`)
+      render: compileToFunction(`<div>{{ count }}</div>`),
     }
     createRecord(childId, Child)
 
@@ -247,8 +247,8 @@ describe('hot module replacement', () => {
         `<button @click="toggle = !toggle" />
         <BaseTransition>
           <KeepAlive><Child v-if="toggle" /></KeepAlive>
-        </BaseTransition>`
-      )
+        </BaseTransition>`,
+      ),
     }
 
     render(h(Parent), root)
@@ -263,7 +263,7 @@ describe('hot module replacement', () => {
       unmounted: unmountSpy,
       activated: activeSpy,
       deactivated: deactiveSpy,
-      render: compileToFunction(`<div>{{ count }}</div>`)
+      render: compileToFunction(`<div>{{ count }}</div>`),
     })
     await nextTick()
     expect(serializeInner(root)).toBe(`<button></button><div>1</div>`)
@@ -306,7 +306,7 @@ describe('hot module replacement', () => {
         return { count: 0 }
       },
       unmounted: unmountSpy,
-      render: compileToFunction(`<div>{{ count }}</div>`)
+      render: compileToFunction(`<div>{{ count }}</div>`),
     }
     createRecord(childId, Child)
 
@@ -316,17 +316,17 @@ describe('hot module replacement', () => {
         return { toggle: true }
       },
       methods: {
-        // @ts-ignore
+        // @ts-expect-error
         onLeave(_, done) {
           setTimeout(done, 0)
-        }
+        },
       },
       render: compileToFunction(
         `<button @click="toggle = !toggle" />
         <BaseTransition mode="out-in" @leave="onLeave">
           <KeepAlive><Child v-if="toggle" /></KeepAlive>
-        </BaseTransition>`
-      )
+        </BaseTransition>`,
+      ),
     }
 
     render(h(Parent), root)
@@ -342,7 +342,7 @@ describe('hot module replacement', () => {
       unmounted: unmountSpy,
       activated: activeSpy,
       deactivated: deactiveSpy,
-      render: compileToFunction(`<div>{{ count }}</div>`)
+      render: compileToFunction(`<div>{{ count }}</div>`),
     })
     await nextTick()
     await new Promise(r => setTimeout(r, 0))
@@ -385,13 +385,13 @@ describe('hot module replacement', () => {
           return { count: 0 }
         },
         unmounted: unmountSpy,
-        render: compileToFunction(`<div @click="count++">{{ count }}</div>`)
+        render: compileToFunction(`<div @click="count++">{{ count }}</div>`),
       }
     }
     createRecord(childId, Child)
 
     const Parent: ComponentOptions = {
-      render: () => h(Child)
+      render: () => h(Child),
     }
 
     render(h(Parent), root)
@@ -404,7 +404,7 @@ describe('hot module replacement', () => {
           return { count: 1 }
         },
         mounted: mountSpy,
-        render: compileToFunction(`<div @click="count++">{{ count }}</div>`)
+        render: compileToFunction(`<div @click="count++">{{ count }}</div>`),
       }
     }
 
@@ -431,29 +431,29 @@ describe('hot module replacement', () => {
       data() {
         return { count: 0 }
       },
-      render: compileToFunction(template)
+      render: compileToFunction(template),
     }
     createRecord(id, Comp)
 
     render(h(Comp), root)
     expect(serializeInner(root)).toBe(
-      `<div><div>0</div><button>++</button></div>`
+      `<div><div>0</div><button>++</button></div>`,
     )
 
     // 1. click to trigger update
     triggerEvent((root as any).children[0].children[1], 'click')
     await nextTick()
     expect(serializeInner(root)).toBe(
-      `<div><div>1</div><button>++</button></div>`
+      `<div><div>1</div><button>++</button></div>`,
     )
 
     // 2. trigger HMR
     rerender(
       id,
-      compileToFunction(template.replace(`<button`, `<button class="foo"`))
+      compileToFunction(template.replace(`<button`, `<button class="foo"`)),
     )
     expect(serializeInner(root)).toBe(
-      `<div><div>1</div><button class="foo">++</button></div>`
+      `<div><div>1</div><button class="foo">++</button></div>`,
     )
   })
 
@@ -466,16 +466,16 @@ describe('hot module replacement', () => {
     const Child: ComponentOptions = {
       __hmrId: childId,
       props: {
-        msg: String
+        msg: String,
       },
-      render: compileToFunction(`<div>{{ msg }}</div>`)
+      render: compileToFunction(`<div>{{ msg }}</div>`),
     }
     createRecord(childId, Child)
 
     const Parent: ComponentOptions = {
       __hmrId: parentId,
       components: { Child },
-      render: compileToFunction(`<Child msg="foo" />`)
+      render: compileToFunction(`<Child msg="foo" />`),
     }
     createRecord(parentId, Parent)
 
@@ -494,14 +494,14 @@ describe('hot module replacement', () => {
 
     const Child: ComponentOptions = {
       __hmrId: childId,
-      render: compileToFunction(`<div>child</div>`)
+      render: compileToFunction(`<div>child</div>`),
     }
     createRecord(childId, Child)
 
     const Parent: ComponentOptions = {
       __hmrId: parentId,
       components: { Child },
-      render: compileToFunction(`<Child class="test" />`)
+      render: compileToFunction(`<Child class="test" />`),
     }
     createRecord(parentId, Parent)
 
@@ -521,7 +521,7 @@ describe('hot module replacement', () => {
 
     const Child: ComponentOptions = {
       __hmrId: childId,
-      render: compileToFunction(`<div>child</div>`)
+      render: compileToFunction(`<div>child</div>`),
     }
     createRecord(childId, Child)
 
@@ -530,18 +530,18 @@ describe('hot module replacement', () => {
     for (let i = 0; i < numberOfParents; i++) {
       const parentId = `${parent}${i}`
       const parentComp: ComponentOptions = {
-        __hmrId: parentId
+        __hmrId: parentId,
       }
       components.push(parentComp)
       if (i === 0) {
         parentComp.render = compileToFunction(`<Child />`)
         parentComp.components = {
-          Child
+          Child,
         }
       } else {
         parentComp.render = compileToFunction(`<Parent />`)
         parentComp.components = {
-          Parent: components[i - 1]
+          Parent: components[i - 1],
         }
       }
 
@@ -568,7 +568,7 @@ describe('hot module replacement', () => {
         return {
           // style is used to ensure that the div tag will be tracked by Teleport
           style: {},
-          target
+          target,
         }
       },
       render: compileToFunction(`
@@ -577,7 +577,7 @@ describe('hot module replacement', () => {
             <slot/>
           </div>
         </teleport>
-      `)
+      `),
     }
 
     const Parent: ComponentOptions = {
@@ -589,13 +589,13 @@ describe('hot module replacement', () => {
             <div>1</div>
           </template>
         </Child>
-      `)
+      `),
     }
     createRecord(parentId, Parent)
 
     render(h(Parent), root)
     expect(serializeInner(root)).toBe(
-      `<!--teleport start--><!--teleport end-->`
+      `<!--teleport start--><!--teleport end-->`,
     )
     expect(serializeInner(target)).toBe(`<div style={}><div>1</div></div>`)
 
@@ -608,13 +608,13 @@ describe('hot module replacement', () => {
           <div>2</div>
         </template>
       </Child>
-    `)
+    `),
     )
     expect(serializeInner(root)).toBe(
-      `<!--teleport start--><!--teleport end-->`
+      `<!--teleport start--><!--teleport end-->`,
     )
     expect(serializeInner(target)).toBe(
-      `<div style={}><div>1</div><div>2</div></div>`
+      `<div style={}><div>1</div><div>2</div></div>`,
     )
   })
 
@@ -629,12 +629,12 @@ describe('hot module replacement', () => {
       created: createSpy1,
       render() {
         return h('div')
-      }
+      },
     }
     createRecord(childId, Child)
 
     const Parent: ComponentOptions = {
-      render: () => h(Child)
+      render: () => h(Child),
     }
 
     const app = createApp(Parent)
@@ -650,7 +650,7 @@ describe('hot module replacement', () => {
       created: createSpy2,
       render() {
         return h('div')
-      }
+      },
     })
     await nextTick()
     expect(createSpy1).toHaveBeenCalledTimes(1)
@@ -662,7 +662,7 @@ describe('hot module replacement', () => {
     const id = 'no-active-instance-rerender'
     const Foo: ComponentOptions = {
       __hmrId: id,
-      render: () => 'foo'
+      render: () => 'foo',
     }
 
     createRecord(id, Foo)
@@ -677,13 +677,13 @@ describe('hot module replacement', () => {
     const id = 'no-active-instance-reload'
     const Foo: ComponentOptions = {
       __hmrId: id,
-      render: () => 'foo'
+      render: () => 'foo',
     }
 
     createRecord(id, Foo)
     reload(id, {
       __hmrId: id,
-      render: () => 'bar'
+      render: () => 'bar',
     })
 
     const root = nodeOps.createElement('div')
@@ -702,16 +702,16 @@ describe('hot module replacement', () => {
       computed: {
         slotContent() {
           return this.$slots.default?.()
-        }
+        },
       },
-      render: compileToFunction(`<component :is="() => slotContent" />`)
+      render: compileToFunction(`<component :is="() => slotContent" />`),
     }
     createRecord(childId, Child)
 
     const Parent: ComponentOptions = {
       __hmrId: parentId,
       components: { Child },
-      render: compileToFunction(`<Child>1</Child>`)
+      render: compileToFunction(`<Child>1</Child>`),
     }
     createRecord(parentId, Parent)
 
@@ -733,14 +733,14 @@ describe('hot module replacement', () => {
           <div>1</div>
         </div>
         <p>2</p>
-        <p>3</p>`
-      )
+        <p>3</p>`,
+      ),
     }
     createRecord(appId, App)
 
     render(h(App), root)
     expect(serializeInner(root)).toBe(
-      `<div><div>1</div></div><div><div>1</div></div><p>2</p><p>3</p>`
+      `<div><div>1</div></div><div><div>1</div></div><p>2</p><p>3</p>`,
     )
 
     // move the <p>3</p> into the <div>1</div>
@@ -750,11 +750,11 @@ describe('hot module replacement', () => {
         `<div v-for="item of 2">
           <div>1<p>3</p></div>
         </div>
-        <p>2</p>`
-      )
+        <p>2</p>`,
+      ),
     )
     expect(serializeInner(root)).toBe(
-      `<div><div>1<p>3</p></div></div><div><div>1<p>3</p></div></div><p>2</p>`
+      `<div><div>1<p>3</p></div></div><div><div>1<p>3</p></div></div><p>2</p>`,
     )
   })
 })
index 07f19527cae1dc5711f24259f7dea44a04bb8e54..303db51cb4425916543daf09839e1b47e29cac51 100644 (file)
@@ -3,27 +3,27 @@
  */
 
 import {
-  createSSRApp,
-  h,
-  ref,
-  nextTick,
-  VNode,
+  Suspense,
   Teleport,
+  Transition,
+  type VNode,
+  createCommentVNode,
+  createSSRApp,
   createStaticVNode,
-  Suspense,
-  onMounted,
-  defineAsyncComponent,
-  defineComponent,
   createTextVNode,
   createVNode,
-  withDirectives,
-  vModelCheckbox,
+  defineAsyncComponent,
+  defineComponent,
+  h,
+  nextTick,
+  onMounted,
+  ref,
   renderSlot,
-  Transition,
-  createCommentVNode,
-  vShow
+  vModelCheckbox,
+  vShow,
+  withDirectives,
 } from '@vue/runtime-dom'
-import { renderToString, SSRContext } from '@vue/server-renderer'
+import { type SSRContext, renderToString } from '@vue/server-renderer'
 import { PatchFlags } from '@vue/shared'
 import { vShowOldKey } from '../../runtime-dom/src/directives/vShow'
 
@@ -31,13 +31,13 @@ function mountWithHydration(html: string, render: () => any) {
   const container = document.createElement('div')
   container.innerHTML = html
   const app = createSSRApp({
-    render
+    render,
   })
   return {
     vnode: app.mount(container).$.subTree as VNode<Node, Element> & {
       el: Element
     },
-    container
+    container,
   }
 }
 
@@ -63,7 +63,7 @@ describe('SSR hydration', () => {
 
   test('empty text', async () => {
     const { container } = mountWithHydration('<div></div>', () =>
-      h('div', createTextVNode(''))
+      h('div', createTextVNode('')),
     )
     expect(container.textContent).toBe('')
     expect(`Hydration children mismatch in <div>`).not.toHaveBeenWarned()
@@ -78,7 +78,7 @@ describe('SSR hydration', () => {
   test('static', () => {
     const html = '<div><span>hello</span></div>'
     const { vnode, container } = mountWithHydration(html, () =>
-      createStaticVNode('', 1)
+      createStaticVNode('', 1),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect(vnode.el.outerHTML).toBe(html)
@@ -109,7 +109,7 @@ describe('SSR hydration', () => {
   test('static (with text node as starting node)', () => {
     const html = ` A <span>foo</span> B`
     const { vnode, container } = mountWithHydration(html, () =>
-      createStaticVNode(` A <span>foo</span> B`, 3)
+      createStaticVNode(` A <span>foo</span> B`, 3),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect(vnode.anchor).toBe(container.lastChild)
@@ -119,7 +119,7 @@ describe('SSR hydration', () => {
   test('static with content adoption', () => {
     const html = ` A <span>foo</span> B`
     const { vnode, container } = mountWithHydration(html, () =>
-      createStaticVNode(``, 3)
+      createStaticVNode(``, 3),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect(vnode.anchor).toBe(container.lastChild)
@@ -131,7 +131,7 @@ describe('SSR hydration', () => {
     const msg = ref('foo')
     const { vnode, container } = mountWithHydration(
       '<div class="foo">foo</div>',
-      () => h('div', { class: msg.value }, msg.value)
+      () => h('div', { class: msg.value }, msg.value),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect(container.firstChild!.textContent).toBe('foo')
@@ -148,15 +148,15 @@ describe('SSR hydration', () => {
       () =>
         h('div', [
           h('span', msg.value),
-          h('span', { class: msg.value, onClick: fn })
-        ])
+          h('span', { class: msg.value, onClick: fn }),
+        ]),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect((vnode.children as VNode[])[0].el).toBe(
-      container.firstChild!.childNodes[0]
+      container.firstChild!.childNodes[0],
     )
     expect((vnode.children as VNode[])[1].el).toBe(
-      container.firstChild!.childNodes[1]
+      container.firstChild!.childNodes[1],
     )
 
     // event handler
@@ -171,7 +171,7 @@ describe('SSR hydration', () => {
   test('element with ref', () => {
     const el = ref()
     const { vnode, container } = mountWithHydration('<div></div>', () =>
-      h('div', { ref: el })
+      h('div', { ref: el }),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect(el.value).toBe(vnode.el)
@@ -184,13 +184,16 @@ describe('SSR hydration', () => {
       '<div><!--[--><span>foo</span><!--[--><span class="foo"></span><!--]--><!--]--></div>',
       () =>
         h('div', [
-          [h('span', msg.value), [h('span', { class: msg.value, onClick: fn })]]
-        ])
+          [
+            h('span', msg.value),
+            [h('span', { class: msg.value, onClick: fn })],
+          ],
+        ]),
     )
     expect(vnode.el).toBe(container.firstChild)
 
     expect(vnode.el.innerHTML).toBe(
-      `<!--[--><span>foo</span><!--[--><span class="foo"></span><!--]--><!--]-->`
+      `<!--[--><span>foo</span><!--[--><span class="foo"></span><!--]--><!--]-->`,
     )
 
     // start fragment 1
@@ -224,7 +227,7 @@ describe('SSR hydration', () => {
     msg.value = 'bar'
     await nextTick()
     expect(vnode.el.innerHTML).toBe(
-      `<!--[--><span>bar</span><!--[--><span class="bar"></span><!--]--><!--]-->`
+      `<!--[--><span>bar</span><!--[--><span class="bar"></span><!--]--><!--]-->`,
     )
   })
 
@@ -241,8 +244,8 @@ describe('SSR hydration', () => {
       () =>
         h(Teleport, { to: '#teleport' }, [
           h('span', msg.value),
-          h('span', { class: msg.value, onClick: fn })
-        ])
+          h('span', { class: msg.value, onClick: fn }),
+        ]),
     )
 
     expect(vnode.el).toBe(container.firstChild)
@@ -250,10 +253,10 @@ describe('SSR hydration', () => {
 
     expect(vnode.target).toBe(teleportContainer)
     expect((vnode.children as VNode[])[0].el).toBe(
-      teleportContainer.childNodes[0]
+      teleportContainer.childNodes[0],
     )
     expect((vnode.children as VNode[])[1].el).toBe(
-      teleportContainer.childNodes[1]
+      teleportContainer.childNodes[1],
     )
     expect(vnode.targetAnchor).toBe(teleportContainer.childNodes[2])
 
@@ -264,7 +267,7 @@ describe('SSR hydration', () => {
     msg.value = 'bar'
     await nextTick()
     expect(teleportContainer.innerHTML).toBe(
-      `<span>bar</span><span class="bar"></span><!--teleport anchor-->`
+      `<span>bar</span><span class="bar"></span><!--teleport anchor-->`,
     )
   })
 
@@ -276,12 +279,12 @@ describe('SSR hydration', () => {
     const Comp = () => [
       h(Teleport, { to: '#teleport2' }, [
         h('span', msg.value),
-        h('span', { class: msg.value, onClick: fn1 })
+        h('span', { class: msg.value, onClick: fn1 }),
       ]),
       h(Teleport, { to: '#teleport2' }, [
         h('span', msg.value + '2'),
-        h('span', { class: msg.value + '2', onClick: fn2 })
-      ])
+        h('span', { class: msg.value + '2', onClick: fn2 }),
+      ]),
     ]
 
     const teleportContainer = document.createElement('div')
@@ -289,12 +292,12 @@ describe('SSR hydration', () => {
     const ctx: SSRContext = {}
     const mainHtml = await renderToString(h(Comp), ctx)
     expect(mainHtml).toMatchInlineSnapshot(
-      `"<!--[--><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--><!--]-->"`
+      `"<!--[--><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--><!--]-->"`,
     )
 
     const teleportHtml = ctx.teleports!['#teleport2']
     expect(teleportHtml).toMatchInlineSnapshot(
-      `"<span>foo</span><span class="foo"></span><!--teleport anchor--><span>foo2</span><span class="foo2"></span><!--teleport anchor-->"`
+      `"<span>foo</span><span class="foo"></span><!--teleport anchor--><span>foo2</span><span class="foo2"></span><!--teleport anchor-->"`,
     )
 
     teleportContainer.innerHTML = teleportHtml
@@ -311,13 +314,13 @@ describe('SSR hydration', () => {
 
     expect(teleportVnode1.target).toBe(teleportContainer)
     expect((teleportVnode1 as any).children[0].el).toBe(
-      teleportContainer.childNodes[0]
+      teleportContainer.childNodes[0],
     )
     expect(teleportVnode1.targetAnchor).toBe(teleportContainer.childNodes[2])
 
     expect(teleportVnode2.target).toBe(teleportContainer)
     expect((teleportVnode2 as any).children[0].el).toBe(
-      teleportContainer.childNodes[3]
+      teleportContainer.childNodes[3],
     )
     expect(teleportVnode2.targetAnchor).toBe(teleportContainer.childNodes[5])
 
@@ -331,7 +334,7 @@ describe('SSR hydration', () => {
     msg.value = 'bar'
     await nextTick()
     expect(teleportContainer.innerHTML).toMatchInlineSnapshot(
-      `"<span>bar</span><span class="bar"></span><!--teleport anchor--><span>bar2</span><span class="bar2"></span><!--teleport anchor-->"`
+      `"<span>bar</span><span class="bar"></span><!--teleport anchor--><span>bar2</span><span class="bar2"></span><!--teleport anchor-->"`,
     )
   })
 
@@ -344,9 +347,9 @@ describe('SSR hydration', () => {
       h('div', 'foo'),
       h(Teleport, { to: '#teleport3', disabled: true }, [
         h('span', msg.value),
-        h('span', { class: msg.value, onClick: fn1 })
+        h('span', { class: msg.value, onClick: fn1 }),
       ]),
-      h('div', { class: msg.value + '2', onClick: fn2 }, 'bar')
+      h('div', { class: msg.value + '2', onClick: fn2 }, 'bar'),
     ]
 
     const teleportContainer = document.createElement('div')
@@ -354,7 +357,7 @@ describe('SSR hydration', () => {
     const ctx: SSRContext = {}
     const mainHtml = await renderToString(h(Comp), ctx)
     expect(mainHtml).toMatchInlineSnapshot(
-      `"<!--[--><div>foo</div><!--teleport start--><span>foo</span><span class="foo"></span><!--teleport end--><div class="foo2">bar</div><!--]-->"`
+      `"<!--[--><div>foo</div><!--teleport start--><span>foo</span><span class="foo"></span><!--teleport end--><div class="foo2">bar</div><!--]-->"`,
     )
 
     const teleportHtml = ctx.teleports!['#teleport3']
@@ -372,10 +375,10 @@ describe('SSR hydration', () => {
     const teleportVnode = children[1]
     expect(teleportVnode.el).toBe(container.childNodes[2])
     expect((teleportVnode.children as VNode[])[0].el).toBe(
-      container.childNodes[3]
+      container.childNodes[3],
     )
     expect((teleportVnode.children as VNode[])[1].el).toBe(
-      container.childNodes[4]
+      container.childNodes[4],
     )
     expect(teleportVnode.anchor).toBe(container.childNodes[5])
     expect(children[2].el).toBe(container.childNodes[6])
@@ -393,7 +396,7 @@ describe('SSR hydration', () => {
     msg.value = 'bar'
     await nextTick()
     expect(container.innerHTML).toMatchInlineSnapshot(
-      `"<!--[--><div>foo</div><!--teleport start--><span>bar</span><span class="bar"></span><!--teleport end--><div class="bar2">bar</div><!--]-->"`
+      `"<!--[--><div>foo</div><!--teleport start--><span>bar</span><span class="bar"></span><!--teleport end--><div class="bar2">bar</div><!--]-->"`,
     )
   })
 
@@ -405,17 +408,17 @@ describe('SSR hydration', () => {
         h('div', 'Parent fragment'),
         h(() =>
           h(Teleport, { to: 'body', disabled: true }, [
-            h('div', 'Teleport content')
-          ])
-        )
-      ]
+            h('div', 'Teleport content'),
+          ]),
+        ),
+      ],
     )
     expect(document.body.innerHTML).toBe('')
     expect(container.innerHTML).toBe(
-      '<!--[--><div>Parent fragment</div><!--teleport start--><div>Teleport content</div><!--teleport end--><!--]-->'
+      '<!--[--><div>Parent fragment</div><!--teleport start--><div>Teleport content</div><!--teleport end--><!--]-->',
     )
     expect(
-      `Hydration completed but contains mismatches.`
+      `Hydration completed but contains mismatches.`,
     ).not.toHaveBeenWarned()
   })
 
@@ -428,12 +431,12 @@ describe('SSR hydration', () => {
     const wrapper = {
       render() {
         return h(Teleport, { to: '#teleport4' }, ['hello'])
-      }
+      },
     }
 
     const { vnode, container } = mountWithHydration(
       '<div><!--teleport start--><!--teleport end--><div></div></div>',
-      () => h('div', [h(wrapper), h('div')])
+      () => h('div', [h(wrapper), h('div')]),
     )
     expect(vnode.el).toBe(container.firstChild)
     // component el
@@ -458,8 +461,8 @@ describe('SSR hydration', () => {
       '<!--teleport start--><!--teleport end-->',
       () =>
         h(Teleport, { to: '#teleport5' }, [
-          h('div', [h(Teleport, { to: '#teleport5' }, [h('div', 'child')])])
-        ])
+          h('div', [h(Teleport, { to: '#teleport5' }, [h('div', 'child')])]),
+        ]),
     )
 
     expect(vnode.el).toBe(container.firstChild)
@@ -476,7 +479,7 @@ describe('SSR hydration', () => {
 
     expect(childTeleportVNode.targetAnchor).toBe(teleportContainer.lastChild)
     expect(childTeleportVNode.children[0].el).toBe(
-      teleportContainer.lastChild?.previousSibling
+      teleportContainer.lastChild?.previousSibling,
     )
   })
 
@@ -492,8 +495,8 @@ describe('SSR hydration', () => {
           count: 0,
           text: 'hello',
           style: {
-            color: 'red'
-          }
+            color: 'red',
+          },
         }
       },
       mounted() {
@@ -508,7 +511,7 @@ describe('SSR hydration', () => {
         <span class="text">{{ text }}</span>
         <input v-model="text">
       </div>
-      `
+      `,
     }
 
     const App = {
@@ -530,11 +533,11 @@ describe('SSR hydration', () => {
           <span>hello</span>
         </div>`,
       components: {
-        Child
+        Child,
       },
       methods: {
-        log
-      }
+        log,
+      },
     }
 
     const container = document.createElement('div')
@@ -586,7 +589,7 @@ describe('SSR hydration', () => {
       template: `
         <div>
           <button class="parent-click" @click="throwError">click me</button>
-        </div>`
+        </div>`,
     }
 
     const container = document.createElement('div')
@@ -613,7 +616,7 @@ describe('SSR hydration', () => {
       template: `
         <div>
           <input class="parent-click" @blur="throwError"/>
-        </div>`
+        </div>`,
     }
 
     const container = document.createElement('div')
@@ -639,14 +642,14 @@ describe('SSR hydration', () => {
             {
               onClick: () => {
                 count.value++
-              }
+              },
             },
-            count.value
+            count.value,
           )
-      }
+      },
     }
     const { vnode, container } = mountWithHydration('<span>0</span>', () =>
-      h(Suspense, () => h(AsyncChild))
+      h(Suspense, () => h(AsyncChild)),
     )
     expect(vnode.el).toBe(container.firstChild)
     // wait for hydration to finish
@@ -676,11 +679,11 @@ describe('SSR hydration', () => {
             {
               onClick: () => {
                 count.value++
-              }
+              },
             },
-            count.value
+            count.value,
           )
-      }
+      },
     })
 
     const done = vi.fn()
@@ -693,18 +696,18 @@ describe('SSR hydration', () => {
         </div>
       </Suspense>`,
       components: {
-        AsyncChild
+        AsyncChild,
       },
       methods: {
-        done
-      }
+        done,
+      },
     }
 
     const container = document.createElement('div')
     // server render
     container.innerHTML = await renderToString(h(App))
     expect(container.innerHTML).toMatchInlineSnapshot(
-      `"<div><span>1</span><span>2</span></div>"`
+      `"<div><span>1</span><span>2</span></div>"`,
     )
     // reset asyncDeps from ssr
     asyncDeps.length = 0
@@ -721,21 +724,21 @@ describe('SSR hydration', () => {
     // should flush buffered effects
     expect(mountedCalls).toMatchObject([1, 2])
     expect(container.innerHTML).toMatch(
-      `<div><span>1</span><span>2</span></div>`
+      `<div><span>1</span><span>2</span></div>`,
     )
 
     const span1 = container.querySelector('span')!
     triggerEvent('click', span1)
     await nextTick()
     expect(container.innerHTML).toMatch(
-      `<div><span>2</span><span>2</span></div>`
+      `<div><span>2</span><span>2</span></div>`,
     )
 
     const span2 = span1.nextSibling as Element
     triggerEvent('click', span2)
     await nextTick()
     expect(container.innerHTML).toMatch(
-      `<div><span>2</span><span>3</span></div>`
+      `<div><span>2</span><span>3</span></div>`,
     )
   })
 
@@ -745,9 +748,9 @@ describe('SSR hydration', () => {
       h(
         'button',
         {
-          onClick: spy
+          onClick: spy,
         },
-        'hello!'
+        'hello!',
       )
 
     let serverResolve: any
@@ -755,13 +758,13 @@ describe('SSR hydration', () => {
       () =>
         new Promise(r => {
           serverResolve = r
-        })
+        }),
     )
 
     const App = {
       render() {
         return ['hello', h(AsyncComp), 'world']
-      }
+      },
     }
 
     // server render
@@ -769,7 +772,7 @@ describe('SSR hydration', () => {
     serverResolve(Comp)
     const html = await htmlPromise
     expect(html).toMatchInlineSnapshot(
-      `"<!--[-->hello<button>hello!</button>world<!--]-->"`
+      `"<!--[-->hello<button>hello!</button>world<!--]-->"`,
     )
 
     // hydration
@@ -778,7 +781,7 @@ describe('SSR hydration', () => {
       () =>
         new Promise(r => {
           clientResolve = r
-        })
+        }),
     )
 
     const container = document.createElement('div')
@@ -802,14 +805,14 @@ describe('SSR hydration', () => {
     const Comp = {
       render() {
         return h('h1', 'Async component')
-      }
+      },
     }
     let serverResolve: any
     let AsyncComp = defineAsyncComponent(
       () =>
         new Promise(r => {
           serverResolve = r
-        })
+        }),
     )
 
     const toggle = ref(true)
@@ -824,7 +827,7 @@ describe('SSR hydration', () => {
         return () => {
           return [toggle.value ? 'hello' : 'world', h(AsyncComp)]
         }
-      }
+      },
     }
 
     // server render
@@ -832,7 +835,7 @@ describe('SSR hydration', () => {
     serverResolve(Comp)
     const html = await htmlPromise
     expect(html).toMatchInlineSnapshot(
-      `"<!--[-->hello<h1>Async component</h1><!--]-->"`
+      `"<!--[-->hello<h1>Async component</h1><!--]-->"`,
     )
 
     // hydration
@@ -841,7 +844,7 @@ describe('SSR hydration', () => {
       () =>
         new Promise(r => {
           clientResolve = r
-        })
+        }),
     )
 
     const container = document.createElement('div')
@@ -855,7 +858,7 @@ describe('SSR hydration', () => {
     // should be hydrated now
     expect(`Hydration node mismatch`).not.toHaveBeenWarned()
     expect(container.innerHTML).toMatchInlineSnapshot(
-      `"<!--[-->world<h1>Async component</h1><!--]-->"`
+      `"<!--[-->world<h1>Async component</h1><!--]-->"`,
     )
   })
 
@@ -866,20 +869,20 @@ describe('SSR hydration', () => {
       async setup() {
         await new Promise<void>(r => setTimeout(r, 10))
         return () => h('h1', 'Async component')
-      }
+      },
     }
 
     const AsyncWrapper = {
       render() {
         return h(AsyncComp)
-      }
+      },
     }
 
     const SiblingComp = {
       setup() {
         toggle.value = false
         return () => h('span')
-      }
+      },
     }
 
     const App = {
@@ -892,21 +895,21 @@ describe('SSR hydration', () => {
               default: () => [
                 h('main', {}, [
                   h(AsyncWrapper, {
-                    prop: toggle.value ? 'hello' : 'world'
+                    prop: toggle.value ? 'hello' : 'world',
                   }),
-                  h(SiblingComp)
-                ])
-              ]
-            }
+                  h(SiblingComp),
+                ]),
+              ],
+            },
           )
-      }
+      },
     }
 
     // server render
     const html = await renderToString(h(App))
 
     expect(html).toMatchInlineSnapshot(
-      `"<main><h1 prop="hello">Async component</h1><span></span></main>"`
+      `"<main><h1 prop="hello">Async component</h1><span></span></main>"`,
     )
 
     expect(toggle.value).toBe(false)
@@ -927,7 +930,7 @@ describe('SSR hydration', () => {
 
     // should be hydrated now
     expect(container.innerHTML).toMatchInlineSnapshot(
-      `"<main><h1 prop="world">Async component</h1><span></span></main>"`
+      `"<main><h1 prop="world">Async component</h1><span></span></main>"`,
     )
   })
 
@@ -938,7 +941,7 @@ describe('SSR hydration', () => {
       async setup() {
         await new Promise<void>(r => setTimeout(r, 10))
         return () => h('h1', 'Async component')
-      }
+      },
     }
 
     const AsyncWrapper = { render: () => h(AsyncComp) }
@@ -948,7 +951,7 @@ describe('SSR hydration', () => {
       setup() {
         toggle.value = false
         return () => h('span')
-      }
+      },
     }
 
     const App = {
@@ -961,21 +964,21 @@ describe('SSR hydration', () => {
               default: () => [
                 h('main', {}, [
                   h(AsyncWrapperWrapper, {
-                    prop: toggle.value ? 'hello' : 'world'
+                    prop: toggle.value ? 'hello' : 'world',
                   }),
-                  h(SiblingComp)
-                ])
-              ]
-            }
+                  h(SiblingComp),
+                ]),
+              ],
+            },
           )
-      }
+      },
     }
 
     // server render
     const html = await renderToString(h(App))
 
     expect(html).toMatchInlineSnapshot(
-      `"<main><h1 prop="hello">Async component</h1><span></span></main>"`
+      `"<main><h1 prop="hello">Async component</h1><span></span></main>"`,
     )
 
     expect(toggle.value).toBe(false)
@@ -996,7 +999,7 @@ describe('SSR hydration', () => {
 
     // should be hydrated now
     expect(container.innerHTML).toMatchInlineSnapshot(
-      `"<main><h1 prop="world">Async component</h1><span></span></main>"`
+      `"<main><h1 prop="world">Async component</h1><span></span></main>"`,
     )
   })
 
@@ -1007,7 +1010,7 @@ describe('SSR hydration', () => {
       () =>
         new Promise(r => {
           resolve = r
-        })
+        }),
     )
 
     const show = ref(true)
@@ -1017,7 +1020,7 @@ describe('SSR hydration', () => {
     createSSRApp({
       render() {
         return h('div', [show.value ? h(AsyncComp) : h('div', 'hi')])
-      }
+      },
     }).mount(root)
 
     show.value = false
@@ -1032,7 +1035,7 @@ describe('SSR hydration', () => {
       () =>
         new Promise(r => {
           resolve = r
-        })
+        }),
     )
 
     const show = ref(true)
@@ -1042,7 +1045,7 @@ describe('SSR hydration', () => {
     createSSRApp({
       render() {
         return h('div', [show.value ? h(AsyncComp) : h('div', 'hi')])
-      }
+      },
     }).mount(root)
 
     show.value = false
@@ -1054,7 +1057,7 @@ describe('SSR hydration', () => {
   test('elements with camel-case in svg ', () => {
     const { vnode, container } = mountWithHydration(
       '<animateTransform></animateTransform>',
-      () => h('animateTransform')
+      () => h('animateTransform'),
     )
     expect(vnode.el).toBe(container.firstChild)
     expect(`Hydration node mismatch`).not.toHaveBeenWarned()
@@ -1064,7 +1067,7 @@ describe('SSR hydration', () => {
     const svgContainer = document.createElement('svg')
     svgContainer.innerHTML = '<g></g>'
     const app = createSSRApp({
-      render: () => h('g')
+      render: () => h('g'),
     })
 
     expect(
@@ -1072,7 +1075,7 @@ describe('SSR hydration', () => {
         app.mount(svgContainer).$.subTree as VNode<Node, Element> & {
           el: Element
         }
-      ).el instanceof SVGElement
+      ).el instanceof SVGElement,
     )
   })
 
@@ -1082,8 +1085,8 @@ describe('SSR hydration', () => {
       () =>
         h('input', {
           type: 'checkbox',
-          '.indeterminate': true
-        })
+          '.indeterminate': true,
+        }),
     )
     expect((container.firstChild! as any).indeterminate).toBe(true)
   })
@@ -1098,10 +1101,10 @@ describe('SSR hydration', () => {
             { type: 'checkbox', 'true-value': true },
             null,
             PatchFlags.PROPS,
-            ['true-value']
+            ['true-value'],
           ),
-          [[vModelCheckbox, true]]
-        )
+          [[vModelCheckbox, true]],
+        ),
     )
     expect((container.firstChild as any)._trueValue).toBe(true)
   })
@@ -1114,8 +1117,8 @@ describe('SSR hydration', () => {
           'input',
           { type: 'checkbox', indeterminate: '' },
           null,
-          PatchFlags.HOISTED
-        )
+          PatchFlags.HOISTED,
+        ),
     )
     expect((container.firstChild as any).indeterminate).toBe(true)
   })
@@ -1126,8 +1129,8 @@ describe('SSR hydration', () => {
       () =>
         h('select', [
           // hoisted because bound value is a constant...
-          createVNode('option', { value: true }, null, -1 /* HOISTED */)
-        ])
+          createVNode('option', { value: true }, null, -1 /* HOISTED */),
+        ]),
     )
     expect((container.firstChild!.firstChild as any)._value).toBe(true)
   })
@@ -1137,12 +1140,12 @@ describe('SSR hydration', () => {
     const Comp = {
       render(this: any) {
         return renderSlot(this.$slots, 'default', {}, () => [
-          createTextVNode('')
+          createTextVNode(''),
         ])
-      }
+      },
     }
     const { container, vnode } = mountWithHydration('<!--[--><!--]-->', () =>
-      h(Comp)
+      h(Comp),
     )
     expect(container.childNodes.length).toBe(3)
     const text = container.childNodes[1]
@@ -1163,9 +1166,9 @@ describe('SSR hydration', () => {
 
         return () =>
           h('button', {
-            onClick: () => count.value++
+            onClick: () => count.value++,
           })
-      }
+      },
     })
 
     const app = createSSRApp(App)
@@ -1182,7 +1185,7 @@ describe('SSR hydration', () => {
   // #6637
   test('stringified root fragment', () => {
     mountWithHydration(`<!--[--><div></div><!--]-->`, () =>
-      createStaticVNode(`<div></div>`, 1)
+      createStaticVNode(`<div></div>`, 1),
     )
     expect(`mismatch`).not.toHaveBeenWarned()
   })
@@ -1195,9 +1198,9 @@ describe('SSR hydration', () => {
           Transition,
           { appear: true },
           {
-            default: () => h('div', 'foo')
-          }
-        )
+            default: () => h('div', 'foo'),
+          },
+        ),
     )
     expect(container.firstChild).toMatchInlineSnapshot(`
       <div
@@ -1219,9 +1222,9 @@ describe('SSR hydration', () => {
           Transition,
           { appear: true },
           {
-            default: () => (show ? h('div', 'foo') : createCommentVNode(''))
-          }
-        )
+            default: () => (show ? h('div', 'foo') : createCommentVNode('')),
+          },
+        ),
     )
     expect(container.firstChild).toMatchInlineSnapshot('<!---->')
     expect(vnode.el).toBe(container.firstChild)
@@ -1238,9 +1241,9 @@ describe('SSR hydration', () => {
           { appear: true },
           {
             default: () =>
-              withDirectives(createVNode('div', null, 'foo'), [[vShow, show]])
-          }
-        )
+              withDirectives(createVNode('div', null, 'foo'), [[vShow, show]]),
+          },
+        ),
     )
     expect(container.firstChild).toMatchInlineSnapshot(`
       <div
@@ -1261,14 +1264,14 @@ describe('SSR hydration', () => {
     createSSRApp({
       data() {
         return {
-          count: 0
+          count: 0,
         }
       },
       template: `
         <Transition appear>
           <button @click="count++">{{count}}</button>
         </Transition>
-      `
+      `,
     }).mount(container)
 
     expect(container.firstChild).toMatchInlineSnapshot(`
@@ -1299,7 +1302,7 @@ describe('SSR hydration', () => {
 
     test('element text content', () => {
       const { container } = mountWithHydration(`<div>foo</div>`, () =>
-        h('div', 'bar')
+        h('div', 'bar'),
       )
       expect(container.innerHTML).toBe('<div>bar</div>')
       expect(`Hydration text content mismatch`).toHaveBeenWarned()
@@ -1307,10 +1310,10 @@ describe('SSR hydration', () => {
 
     test('not enough children', () => {
       const { container } = mountWithHydration(`<div></div>`, () =>
-        h('div', [h('span', 'foo'), h('span', 'bar')])
+        h('div', [h('span', 'foo'), h('span', 'bar')]),
       )
       expect(container.innerHTML).toBe(
-        '<div><span>foo</span><span>bar</span></div>'
+        '<div><span>foo</span><span>bar</span></div>',
       )
       expect(`Hydration children mismatch`).toHaveBeenWarned()
     })
@@ -1318,7 +1321,7 @@ describe('SSR hydration', () => {
     test('too many children', () => {
       const { container } = mountWithHydration(
         `<div><span>foo</span><span>bar</span></div>`,
-        () => h('div', [h('span', 'foo')])
+        () => h('div', [h('span', 'foo')]),
       )
       expect(container.innerHTML).toBe('<div><span>foo</span></div>')
       expect(`Hydration children mismatch`).toHaveBeenWarned()
@@ -1327,7 +1330,7 @@ describe('SSR hydration', () => {
     test('complete mismatch', () => {
       const { container } = mountWithHydration(
         `<div><span>foo</span><span>bar</span></div>`,
-        () => h('div', [h('div', 'foo'), h('p', 'bar')])
+        () => h('div', [h('div', 'foo'), h('p', 'bar')]),
       )
       expect(container.innerHTML).toBe('<div><div>foo</div><p>bar</p></div>')
       expect(`Hydration node mismatch`).toHaveBeenWarnedTimes(2)
@@ -1336,7 +1339,7 @@ describe('SSR hydration', () => {
     test('fragment mismatch removal', () => {
       const { container } = mountWithHydration(
         `<div><!--[--><div>foo</div><div>bar</div><!--]--></div>`,
-        () => h('div', [h('span', 'replaced')])
+        () => h('div', [h('span', 'replaced')]),
       )
       expect(container.innerHTML).toBe('<div><span>replaced</span></div>')
       expect(`Hydration node mismatch`).toHaveBeenWarned()
@@ -1345,10 +1348,10 @@ describe('SSR hydration', () => {
     test('fragment not enough children', () => {
       const { container } = mountWithHydration(
         `<div><!--[--><div>foo</div><!--]--><div>baz</div></div>`,
-        () => h('div', [[h('div', 'foo'), h('div', 'bar')], h('div', 'baz')])
+        () => h('div', [[h('div', 'foo'), h('div', 'bar')], h('div', 'baz')]),
       )
       expect(container.innerHTML).toBe(
-        '<div><!--[--><div>foo</div><div>bar</div><!--]--><div>baz</div></div>'
+        '<div><!--[--><div>foo</div><div>bar</div><!--]--><div>baz</div></div>',
       )
       expect(`Hydration node mismatch`).toHaveBeenWarned()
     })
@@ -1356,10 +1359,10 @@ describe('SSR hydration', () => {
     test('fragment too many children', () => {
       const { container } = mountWithHydration(
         `<div><!--[--><div>foo</div><div>bar</div><!--]--><div>baz</div></div>`,
-        () => h('div', [[h('div', 'foo')], h('div', 'baz')])
+        () => h('div', [[h('div', 'foo')], h('div', 'baz')]),
       )
       expect(container.innerHTML).toBe(
-        '<div><!--[--><div>foo</div><!--]--><div>baz</div></div>'
+        '<div><!--[--><div>foo</div><!--]--><div>baz</div></div>',
       )
       // fragment ends early and attempts to hydrate the extra <div>bar</div>
       // as 2nd fragment child.
@@ -1374,7 +1377,7 @@ describe('SSR hydration', () => {
       document.body.appendChild(teleportContainer)
 
       mountWithHydration('<!--teleport start--><!--teleport end-->', () =>
-        h(Teleport, { to: '#teleport' }, [h('span', 'value')])
+        h(Teleport, { to: '#teleport' }, [h('span', 'value')]),
       )
       expect(teleportContainer.innerHTML).toBe(`<span>value</span>`)
       expect(`Hydration children mismatch`).toHaveBeenWarned()
@@ -1382,7 +1385,7 @@ describe('SSR hydration', () => {
 
     test('comment mismatch (element)', () => {
       const { container } = mountWithHydration(`<div><span></span></div>`, () =>
-        h('div', [createCommentVNode('hi')])
+        h('div', [createCommentVNode('hi')]),
       )
       expect(container.innerHTML).toBe('<div><!--hi--></div>')
       expect(`Hydration node mismatch`).toHaveBeenWarned()
@@ -1390,7 +1393,7 @@ describe('SSR hydration', () => {
 
     test('comment mismatch (text)', () => {
       const { container } = mountWithHydration(`<div>foobar</div>`, () =>
-        h('div', [createCommentVNode('hi')])
+        h('div', [createCommentVNode('hi')]),
       )
       expect(container.innerHTML).toBe('<div><!--hi--></div>')
       expect(`Hydration node mismatch`).toHaveBeenWarned()
@@ -1398,39 +1401,39 @@ describe('SSR hydration', () => {
 
     test('class mismatch', () => {
       mountWithHydration(`<div class="foo bar"></div>`, () =>
-        h('div', { class: ['foo', 'bar'] })
+        h('div', { class: ['foo', 'bar'] }),
       )
       mountWithHydration(`<div class="foo bar"></div>`, () =>
-        h('div', { class: { foo: true, bar: true } })
+        h('div', { class: { foo: true, bar: true } }),
       )
       mountWithHydration(`<div class="foo bar"></div>`, () =>
-        h('div', { class: 'foo bar' })
+        h('div', { class: 'foo bar' }),
       )
       // SVG classes
       mountWithHydration(`<svg class="foo bar"></svg>`, () =>
-        h('svg', { class: 'foo bar' })
+        h('svg', { class: 'foo bar' }),
       )
       // class with different order
       mountWithHydration(`<div class="foo bar"></div>`, () =>
-        h('div', { class: 'bar foo' })
+        h('div', { class: 'bar foo' }),
       )
       expect(`Hydration class mismatch`).not.toHaveBeenWarned()
       mountWithHydration(`<div class="foo bar"></div>`, () =>
-        h('div', { class: 'foo' })
+        h('div', { class: 'foo' }),
       )
       expect(`Hydration class mismatch`).toHaveBeenWarned()
     })
 
     test('style mismatch', () => {
       mountWithHydration(`<div style="color:red;"></div>`, () =>
-        h('div', { style: { color: 'red' } })
+        h('div', { style: { color: 'red' } }),
       )
       mountWithHydration(`<div style="color:red;"></div>`, () =>
-        h('div', { style: `color:red;` })
+        h('div', { style: `color:red;` }),
       )
       expect(`Hydration style mismatch`).not.toHaveBeenWarned()
       mountWithHydration(`<div style="color:red;"></div>`, () =>
-        h('div', { style: { color: 'green' } })
+        h('div', { style: { color: 'green' } }),
       )
       expect(`Hydration style mismatch`).toHaveBeenWarned()
     })
@@ -1438,15 +1441,15 @@ describe('SSR hydration', () => {
     test('attr mismatch', () => {
       mountWithHydration(`<div id="foo"></div>`, () => h('div', { id: 'foo' }))
       mountWithHydration(`<div spellcheck></div>`, () =>
-        h('div', { spellcheck: '' })
+        h('div', { spellcheck: '' }),
       )
       mountWithHydration(`<div></div>`, () => h('div', { id: undefined }))
       // boolean
       mountWithHydration(`<select multiple></div>`, () =>
-        h('select', { multiple: true })
+        h('select', { multiple: true }),
       )
       mountWithHydration(`<select multiple></div>`, () =>
-        h('select', { multiple: 'multiple' })
+        h('select', { multiple: 'multiple' }),
       )
       expect(`Hydration attribute mismatch`).not.toHaveBeenWarned()
 
index 4cb93eb41cf94a36da26bbd7544f396f7b15f05c..dd4ab64f499055ad2bebdaeec0df4af5ef9f5a8a 100644 (file)
@@ -1,4 +1,4 @@
-import { render, h, nodeOps, reactive, isReactive } from '@vue/runtime-test'
+import { h, isReactive, nodeOps, reactive, render } from '@vue/runtime-test'
 
 describe('misc', () => {
   test('component public instance should not be observable', () => {
@@ -7,7 +7,7 @@ describe('misc', () => {
       render() {},
       mounted() {
         instance = this
-      }
+      },
     }
     render(h(Comp), nodeOps.createElement('div'))
     expect(instance).toBeDefined()
index 1de05b67b44e7c78a4c2f717cb20b8c4e44e14f6..ef5630ff65a6aaac8ff0409eaa8b550b775d4b8f 100644 (file)
@@ -4,19 +4,19 @@
 // using DOM renderer because this case is mostly DOM-specific
 
 import {
+  Fragment,
+  type FunctionalComponent,
+  createBlock,
+  createCommentVNode,
+  defineComponent,
   h,
-  render,
-  nextTick,
   mergeProps,
-  ref,
+  nextTick,
   onUpdated,
-  defineComponent,
   openBlock,
-  createBlock,
-  FunctionalComponent,
-  createCommentVNode,
-  Fragment,
-  withModifiers
+  ref,
+  render,
+  withModifiers,
 } from '@vue/runtime-dom'
 import { PatchFlags } from '@vue/shared'
 
@@ -41,9 +41,9 @@ describe('attribute fallthrough', () => {
             class: 'c' + count.value,
             style: { color: count.value ? 'red' : 'green' },
             onClick: inc,
-            'data-id': count.value + 1
+            'data-id': count.value + 1,
           })
-      }
+      },
     }
 
     const Child = {
@@ -54,11 +54,11 @@ describe('attribute fallthrough', () => {
             'div',
             {
               class: 'c2',
-              style: { fontWeight: 'bold' }
+              style: { fontWeight: 'bold' },
             },
-            props.foo
+            props.foo,
           )
-      }
+      },
     }
 
     const root = document.createElement('div')
@@ -103,7 +103,7 @@ describe('attribute fallthrough', () => {
         id: 'test',
         class: 'c' + count.value,
         style: { color: count.value ? 'red' : 'green' },
-        onClick: inc
+        onClick: inc,
       })
 
     const Child = (props: any) => {
@@ -112,9 +112,9 @@ describe('attribute fallthrough', () => {
         'div',
         {
           class: 'c2',
-          style: { fontWeight: 'bold' }
+          style: { fontWeight: 'bold' },
         },
-        props.foo
+        props.foo,
       )
     }
 
@@ -161,7 +161,7 @@ describe('attribute fallthrough', () => {
         id: 'test',
         class: 'c' + count.value,
         style: { color: count.value ? 'red' : 'green' },
-        onClick: inc
+        onClick: inc,
       })
 
     const Child = (props: { foo: number }) => {
@@ -170,9 +170,9 @@ describe('attribute fallthrough', () => {
         'div',
         {
           class: 'c2',
-          style: { fontWeight: 'bold' }
+          style: { fontWeight: 'bold' },
         },
-        props.foo
+        props.foo,
       )
     }
     Child.props = ['foo']
@@ -220,9 +220,9 @@ describe('attribute fallthrough', () => {
             id: 'test',
             class: 'c' + count.value,
             style: { color: count.value ? 'red' : 'green' },
-            onClick: inc
+            onClick: inc,
           })
-      }
+      },
     }
 
     const Child = {
@@ -232,13 +232,13 @@ describe('attribute fallthrough', () => {
         // this will result in merging the same attrs, but should be deduped by
         // `mergeProps`.
         return () => h(GrandChild, props)
-      }
+      },
     }
 
     const GrandChild = defineComponent({
       props: {
         id: String,
-        foo: Number
+        foo: Number,
       },
       setup(props) {
         onUpdated(grandChildUpdated)
@@ -248,11 +248,11 @@ describe('attribute fallthrough', () => {
             {
               id: props.id,
               class: 'c2',
-              style: { fontWeight: 'bold' }
+              style: { fontWeight: 'bold' },
             },
-            props.foo
+            props.foo,
           )
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -287,7 +287,7 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent' })
-      }
+      },
     }
 
     const Child = defineComponent({
@@ -295,7 +295,7 @@ describe('attribute fallthrough', () => {
       inheritAttrs: false,
       render() {
         return h('div', this.foo)
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -311,11 +311,11 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent' })
-      }
+      },
     }
 
     const mixin = {
-      inheritAttrs: false
+      inheritAttrs: false,
     }
 
     const Child = defineComponent({
@@ -323,7 +323,7 @@ describe('attribute fallthrough', () => {
       props: ['foo'],
       render() {
         return h('div', this.foo)
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -338,7 +338,7 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent' })
-      }
+      },
     }
 
     const Child = defineComponent({
@@ -349,13 +349,13 @@ describe('attribute fallthrough', () => {
           'div',
           mergeProps(
             {
-              class: 'child'
+              class: 'child',
             },
-            this.$attrs
+            this.$attrs,
           ),
-          this.foo
+          this.foo,
         )
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -370,14 +370,14 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent', onBar: () => {} })
-      }
+      },
     }
 
     const Child = defineComponent({
       props: ['foo'],
       render() {
         return [h('div'), h('div')]
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -400,7 +400,7 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { onClick: inc })
-      }
+      },
     }
 
     const Child = defineComponent({
@@ -409,12 +409,12 @@ describe('attribute fallthrough', () => {
           'div',
           mergeProps(
             {
-              onClick: withModifiers(() => {}, ['prevent', 'stop'])
+              onClick: withModifiers(() => {}, ['prevent', 'stop']),
             },
-            this.$attrs
-          )
+            this.$attrs,
+          ),
         )
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -431,14 +431,14 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent', onBar: () => {} })
-      }
+      },
     }
 
     const Child = defineComponent({
       props: ['foo'],
       render() {
         return [h('div'), h('div', this.$attrs)]
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -455,14 +455,14 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent', onBar: () => {} })
-      }
+      },
     }
 
     const Child = defineComponent({
       props: ['foo'],
       setup(_props, { attrs }) {
         return () => [h('div'), h('div', attrs)]
-      }
+      },
     })
 
     const root = document.createElement('div')
@@ -479,12 +479,12 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent', onBar: () => {} })
-      }
+      },
     }
 
     const Child: FunctionalComponent = (_, { attrs }) => [
       h('div'),
-      h('div', attrs)
+      h('div', attrs),
     ]
 
     Child.props = ['foo']
@@ -502,7 +502,7 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent', onBar: () => {} })
-      }
+      },
     }
 
     const Child = (props: any) => [h('div'), h('div', { class: props.class })]
@@ -520,7 +520,7 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { foo: 1, class: 'parent', onBar: () => {} })
-      }
+      },
     }
 
     const Child: FunctionalComponent = () => [h('div'), h('div')]
@@ -543,14 +543,14 @@ describe('attribute fallthrough', () => {
     const Parent = {
       render() {
         return h(Child, { 'aria-hidden': aria.value, class: cls.value })
-      }
+      },
     }
 
     const Child = {
       props: [],
       render() {
         return openBlock(), createBlock('div')
-      }
+      },
     }
 
     const root = document.createElement('div')
@@ -577,20 +577,20 @@ describe('attribute fallthrough', () => {
           {
             onClick: () => {
               this.$emit('click', 'custom')
-            }
+            },
           },
-          'hello'
+          'hello',
         )
-      }
+      },
     })
 
     const onClick = vi.fn()
     const App = {
       render() {
         return h(Child, {
-          onClick
+          onClick,
         })
-      }
+      },
     }
 
     const root = document.createElement('div')
@@ -610,7 +610,7 @@ describe('attribute fallthrough', () => {
       return h('button', {
         onClick: () => {
           emit('click', 'custom')
-        }
+        },
       })
     }
     Child.emits = ['click']
@@ -619,9 +619,9 @@ describe('attribute fallthrough', () => {
     const App = {
       render() {
         return h(Child, {
-          onClick
+          onClick,
         })
-      }
+      },
     }
 
     const root = document.createElement('div')
@@ -640,7 +640,7 @@ describe('attribute fallthrough', () => {
     const Hello = {
       setup() {
         return () => h(Child, { class: 'foo', onClick: click })
-      }
+      },
     }
 
     const Child = {
@@ -653,12 +653,12 @@ describe('attribute fallthrough', () => {
             [
               createCommentVNode('hello'),
               h('button'),
-              createCommentVNode('world')
+              createCommentVNode('world'),
             ],
-            PatchFlags.STABLE_FRAGMENT | PatchFlags.DEV_ROOT_FRAGMENT
+            PatchFlags.STABLE_FRAGMENT | PatchFlags.DEV_ROOT_FRAGMENT,
           )
         )
-      }
+      },
     }
 
     const root = document.createElement('div')
@@ -666,7 +666,7 @@ describe('attribute fallthrough', () => {
     render(h(Hello), root)
 
     expect(root.innerHTML).toBe(
-      `<!--hello--><button class="foo"></button><!--world-->`
+      `<!--hello--><button class="foo"></button><!--world-->`,
     )
     const button = root.children[0] as HTMLElement
     button.dispatchEvent(new CustomEvent('click'))
@@ -686,9 +686,9 @@ describe('attribute fallthrough', () => {
             modelValue: textFoo,
             'onUpdate:modelValue': (val: string) => {
               textFoo = val
-            }
+            },
           })
-      }
+      },
     })
 
     const Child = defineComponent({
@@ -700,9 +700,9 @@ describe('attribute fallthrough', () => {
             'onUpdate:modelValue': (val: string) => {
               textBar = val
               emit('update:modelValue', 'from Child')
-            }
+            },
           })
-      }
+      },
     })
 
     const GrandChild = defineComponent({
@@ -713,9 +713,9 @@ describe('attribute fallthrough', () => {
             onClick() {
               click()
               emit('update:modelValue', 'from GrandChild')
-            }
+            },
           })
-      }
+      },
     })
 
     const root = document.createElement('div')
index 747626ad53182a0375dd250a5e43d34fdcf9f98c..47024b674f4c44ef665b25874b8d2461f66cfb3b 100644 (file)
@@ -1,12 +1,12 @@
 // reference: https://github.com/vuejs/vue/blob/dev/test/unit/modules/vdom/patch/children.spec.js
 import {
+  type TestElement,
+  TestNodeTypes,
   h,
-  render,
   nodeOps,
-  TestNodeTypes,
-  TestElement,
+  render,
   serialize,
-  serializeInner
+  serializeInner,
 } from '@vue/runtime-test'
 function toSpan(content: any) {
   if (typeof content === 'string') {
@@ -99,7 +99,7 @@ describe('renderer: keyed children', () => {
       '2',
       '3',
       '4',
-      '5'
+      '5',
     ])
   })
 
@@ -114,7 +114,7 @@ describe('renderer: keyed children', () => {
       '2',
       '3',
       '4',
-      '5'
+      '5',
     ])
   })
 
@@ -129,7 +129,7 @@ describe('renderer: keyed children', () => {
       '2',
       '3',
       '4',
-      '5'
+      '5',
     ])
   })
 
@@ -144,7 +144,7 @@ describe('renderer: keyed children', () => {
       '2',
       '3',
       '4',
-      '5'
+      '5',
     ])
   })
 
@@ -156,7 +156,7 @@ describe('renderer: keyed children', () => {
       '2',
       '3',
       '4',
-      '5'
+      '5',
     ])
 
     render(h('div'), root)
@@ -191,7 +191,7 @@ describe('renderer: keyed children', () => {
       '1',
       '2',
       '4',
-      '5'
+      '5',
     ])
   })
 
@@ -205,7 +205,7 @@ describe('renderer: keyed children', () => {
       '2',
       '3',
       '1',
-      '4'
+      '4',
     ])
   })
 
@@ -219,7 +219,7 @@ describe('renderer: keyed children', () => {
       '1',
       '4',
       '2',
-      '3'
+      '3',
     ])
   })
 
@@ -242,7 +242,7 @@ describe('renderer: keyed children', () => {
       '4',
       '2',
       '3',
-      '1'
+      '1',
     ])
   })
 
@@ -257,7 +257,7 @@ describe('renderer: keyed children', () => {
       '1',
       '2',
       '3',
-      '6'
+      '6',
     ])
   })
 
@@ -291,7 +291,7 @@ describe('renderer: keyed children', () => {
       '4',
       '3',
       '2',
-      '1'
+      '1',
     ])
   })
 
@@ -306,7 +306,7 @@ describe('renderer: keyed children', () => {
       '2',
       '1',
       '5',
-      '0'
+      '0',
     ])
   })
 
@@ -324,15 +324,15 @@ describe('renderer: keyed children', () => {
       render(
         h(
           'span',
-          arr.map(n => spanNumWithOpacity(n, '1'))
+          arr.map(n => spanNumWithOpacity(n, '1')),
         ),
-        root
+        root,
       )
       elm = root.children[0] as TestElement
 
       for (let i = 0; i < elms; ++i) {
         expect(serializeInner(elm.children[i] as TestElement)).toBe(
-          i.toString()
+          i.toString(),
         )
         opacities[i] = Math.random().toFixed(5).toString()
       }
@@ -341,21 +341,21 @@ describe('renderer: keyed children', () => {
       render(
         h(
           'span',
-          arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n]))
+          arr.map(n => spanNumWithOpacity(shufArr[n], opacities[n])),
         ),
-        root
+        root,
       )
       elm = root.children[0] as TestElement
       for (let i = 0; i < elms; ++i) {
         expect(serializeInner(elm.children[i] as TestElement)).toBe(
-          shufArr[i].toString()
+          shufArr[i].toString(),
         )
         expect(elm.children[i]).toMatchObject({
           props: {
             style: {
-              opacity: opacities[i]
-            }
-          }
+              opacity: opacities[i],
+            },
+          },
         })
       }
     }
@@ -367,22 +367,22 @@ describe('renderer: keyed children', () => {
         h('div', { key: 1 }, 'one'),
         h('div', { key: 2 }, 'two'),
         h('div', { key: 3 }, 'three'),
-        h('div', { key: 4 }, 'four')
+        h('div', { key: 4 }, 'four'),
       ]),
-      root
+      root,
     )
     elm = root.children[0] as TestElement
     expect((elm.children as TestElement[]).map(c => c.tag)).toEqual([
       'div',
       'div',
       'div',
-      'div'
+      'div',
     ])
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'one',
       'two',
       'three',
-      'four'
+      'four',
     ])
 
     render(
@@ -390,21 +390,21 @@ describe('renderer: keyed children', () => {
         h('div', { key: 4 }, 'four'),
         h('span', { key: 3 }, 'three'),
         h('span', { key: 2 }, 'two'),
-        h('div', { key: 1 }, 'one')
+        h('div', { key: 1 }, 'one'),
       ]),
-      root
+      root,
     )
     expect((elm.children as TestElement[]).map(c => c.tag)).toEqual([
       'div',
       'span',
       'span',
-      'div'
+      'div',
     ])
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'four',
       'three',
       'two',
-      'one'
+      'one',
     ])
   })
 
@@ -413,8 +413,8 @@ describe('renderer: keyed children', () => {
     elm = root.children[0] as TestElement
     expect(elm.children[0]).toMatchObject({
       props: {
-        class: 'hi'
-      }
+        class: 'hi',
+      },
     })
 
     render(h('div', [h('div', 'four')]), root)
@@ -423,8 +423,8 @@ describe('renderer: keyed children', () => {
       props: {
         // in the DOM renderer this will be ''
         // but the test renderer simply sets whatever value it receives.
-        class: null
-      }
+        class: null,
+      },
     })
     expect(serialize(elm.children[0])).toBe(`<div>four</div>`)
   })
@@ -456,7 +456,7 @@ describe('renderer: unkeyed children', () => {
       '1',
       'a',
       'b',
-      'c'
+      'c',
     ])
 
     elm = renderChildren(['d', 'a', 'b', 'c', 1, 'e'])
@@ -467,7 +467,7 @@ describe('renderer: unkeyed children', () => {
       'b',
       'c',
       '1',
-      'e'
+      'e',
     ])
   })
 
@@ -478,7 +478,7 @@ describe('renderer: unkeyed children', () => {
     elm = renderChildren(['hello', 'world'])
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'hello',
-      'world'
+      'world',
     ])
   })
 
@@ -488,7 +488,7 @@ describe('renderer: unkeyed children', () => {
     elm = root.children[0] as TestElement
     expect(elm.children[0]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: 'text'
+      text: 'text',
     })
 
     render(h('div', ['text', h('span', ['hello'])]), root)
@@ -496,7 +496,7 @@ describe('renderer: unkeyed children', () => {
     elm = root.children[0] as TestElement
     expect(elm.children[0]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: 'text'
+      text: 'text',
     })
   })
 
@@ -506,7 +506,7 @@ describe('renderer: unkeyed children', () => {
     elm = root.children[0] as TestElement
     expect(elm.children[0]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: 'text'
+      text: 'text',
     })
 
     render(h('div', ['text2', h('span', ['hello'])]), root)
@@ -514,7 +514,7 @@ describe('renderer: unkeyed children', () => {
     elm = root.children[0] as TestElement
     expect(elm.children[0]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: 'text2'
+      text: 'text2',
     })
   })
 
@@ -526,7 +526,7 @@ describe('renderer: unkeyed children', () => {
     render(h('div', [h('span', ['hello']), h('span', ['world'])]), root)
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'hello',
-      'world'
+      'world',
     ])
   })
 
@@ -538,24 +538,24 @@ describe('renderer: unkeyed children', () => {
     render(h('div', [h('div', ['hello']), h('span', ['world'])]), root)
     expect((elm.children as TestElement[]).map(c => c.tag)).toEqual([
       'div',
-      'span'
+      'span',
     ])
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'hello',
-      'world'
+      'world',
     ])
   })
 
   test('remove elements with updating children without keys', () => {
     render(
       h('div', [h('span', ['one']), h('span', ['two']), h('span', ['three'])]),
-      root
+      root,
     )
     elm = root.children[0] as TestElement
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'one',
       'two',
-      'three'
+      'three',
     ])
 
     render(h('div', [h('span', ['one']), h('span', ['three'])]), root)
@@ -587,7 +587,7 @@ describe('renderer: unkeyed children', () => {
     elm = root.children[0] as TestElement
     expect((elm.children as TestElement[]).map(c => serialize(c))).toEqual([
       'one',
-      '<span>two</span>'
+      '<span>two</span>',
     ])
 
     render(h('div', [h('div', ['three'])]), root)
@@ -599,24 +599,24 @@ describe('renderer: unkeyed children', () => {
   test('reorder elements', () => {
     render(
       h('div', [h('span', ['one']), h('div', ['two']), h('b', ['three'])]),
-      root
+      root,
     )
     elm = root.children[0] as TestElement
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'one',
       'two',
-      'three'
+      'three',
     ])
 
     render(
       h('div', [h('b', ['three']), h('div', ['two']), h('span', ['one'])]),
-      root
+      root,
     )
     elm = root.children[0] as TestElement
     expect((elm.children as TestElement[]).map(inner)).toEqual([
       'three',
       'two',
-      'one'
+      'one',
     ])
   })
 
index 37daafa97254d1f93a56a83e20bedf8314d9913d..c5faa05de83c71697cd749fa81200bc5549ecd23 100644 (file)
@@ -1,16 +1,16 @@
 import {
-  ref,
+  type Ref,
+  type SetupContext,
+  type VNode,
   h,
-  render,
-  nodeOps,
-  serializeInner,
+  inject,
   nextTick,
-  VNode,
+  nodeOps,
   provide,
-  inject,
-  Ref,
+  ref,
+  render,
+  serializeInner,
   watch,
-  SetupContext
 } from '@vue/runtime-test'
 
 describe('renderer: component', () => {
@@ -24,7 +24,7 @@ describe('renderer: component', () => {
       render: () => {
         // let Parent first rerender
         return (parentVnode = h(Child))
-      }
+      },
     }
 
     const Child = {
@@ -32,7 +32,7 @@ describe('renderer: component', () => {
         return value.value
           ? (childVnode1 = h('div'))
           : (childVnode2 = h('span'))
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -50,7 +50,7 @@ describe('renderer: component', () => {
     const Comp = {
       render: () => {
         return h('div')
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp, { id: 'foo', class: 'bar' }), root)
@@ -61,7 +61,7 @@ describe('renderer: component', () => {
     const Comp = {
       render: () => {
         return h('div', 'test')
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp, { id: 'foo', class: 'bar' }), root)
@@ -72,7 +72,7 @@ describe('renderer: component', () => {
     const Comp1 = {
       render: () => {
         return h('div', 'foo')
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(Comp1), root)
@@ -81,7 +81,7 @@ describe('renderer: component', () => {
     const Comp2 = {
       render: () => {
         return h('span', 'foo')
-      }
+      },
     }
     render(h(Comp2), root)
     expect(serializeInner(root)).toBe('<span>foo</span>')
@@ -92,20 +92,20 @@ describe('renderer: component', () => {
     const Comp1 = {
       emits: ['foo'],
       updated: vi.fn(),
-      render: () => null
+      render: () => null,
     }
     const root = nodeOps.createElement('div')
     render(
       h(Comp1, {
-        onFoo: () => {}
+        onFoo: () => {},
       }),
-      root
+      root,
     )
     render(
       h(Comp1, {
-        onFoo: () => {}
+        onFoo: () => {},
       }),
-      root
+      root,
     )
     expect(Comp1.updated).not.toHaveBeenCalled()
   })
@@ -119,7 +119,7 @@ describe('renderer: component', () => {
         return () => {
           return [h('div', n.value), h(Child)]
         }
-      }
+      },
     }
 
     const Child = {
@@ -130,7 +130,7 @@ describe('renderer: component', () => {
         return () => {
           return h('div', n.value)
         }
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -150,24 +150,24 @@ describe('renderer: component', () => {
     let instance: any
     const Comp = {
       props: {
-        testProp: String
+        testProp: String,
       },
 
       data() {
         return {
-          testData: undefined
+          testData: undefined,
         }
       },
 
       watch: {
         testProp() {
-          // @ts-ignore
+          // @ts-expect-error
           propWatchSpy(this.$el)
         },
         testData() {
-          // @ts-ignore
+          // @ts-expect-error
           dataWatchSpy(this.$el)
-        }
+        },
       },
 
       created() {
@@ -176,7 +176,7 @@ describe('renderer: component', () => {
 
       render() {
         return h('div')
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -206,11 +206,11 @@ describe('renderer: component', () => {
             h('div', inner.value),
             h(Child, {
               value: outer.value,
-              onUpdate: (val: number) => (inner.value = val)
-            })
+              onUpdate: (val: number) => (inner.value = val),
+            }),
           ]
         }
-      }
+      },
     }
 
     const Child = {
@@ -218,13 +218,13 @@ describe('renderer: component', () => {
       setup(props: any, { emit }: SetupContext) {
         watch(
           () => props.value,
-          (val: number) => emit('update', val)
+          (val: number) => emit('update', val),
         )
 
         return () => {
           return h('div', props.value)
         }
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -243,7 +243,7 @@ describe('renderer: component', () => {
       props: ['foo'],
       data() {
         return {
-          count: 0
+          count: 0,
         }
       },
       watch: {
@@ -251,8 +251,8 @@ describe('renderer: component', () => {
           immediate: true,
           handler() {
             ;(this as any).count
-          }
-        }
+          },
+        },
       },
       created() {
         childInstance = this as any
@@ -260,14 +260,14 @@ describe('renderer: component', () => {
       },
       render() {
         return h('h1', (this as any).count)
-      }
+      },
     }
 
     const App = {
       setup() {
         return () => h(Child)
       },
-      updated: vi.fn()
+      updated: vi.fn(),
     }
 
     const root = nodeOps.createElement('div')
@@ -289,7 +289,7 @@ describe('renderer: component', () => {
         },
         render() {
           return h('h1', (this as any).foo)
-        }
+        },
       }
       const root = nodeOps.createElement('div')
 
@@ -305,7 +305,7 @@ describe('renderer: component', () => {
       render() {
         const c = [h(Comp)]
         return [c, c, c]
-      }
+      },
     }
 
     const ids: number[] = []
@@ -313,7 +313,7 @@ describe('renderer: component', () => {
       render: () => h('h1'),
       beforeUnmount() {
         ids.push((this as any).$.uid)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -332,7 +332,7 @@ describe('renderer: component', () => {
     const App = {
       render() {
         return h(Comp, { text: text.value })
-      }
+      },
     }
 
     const Comp = {
@@ -340,7 +340,7 @@ describe('renderer: component', () => {
       render(this: any) {
         spy()
         return h('h1', this.text)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -359,20 +359,20 @@ describe('renderer: component', () => {
     const App = {
       setup() {
         return {
-          __isScriptSetup: true
+          __isScriptSetup: true,
         }
       },
 
       render(this: any) {
         return this.$attrs.id
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
     render(h(App), root)
 
     expect(
-      `Property '$attrs' was accessed via 'this'. Avoid using 'this' in templates.`
+      `Property '$attrs' was accessed via 'this'. Avoid using 'this' in templates.`,
     ).toHaveBeenWarned()
   })
 })
index 4e044ad408e9bff6ec421751f6a57416eea62d2c..8103832e8df0ef0b7bdbd69e21a12c6c38b2fb5d 100644 (file)
@@ -1,9 +1,9 @@
 import {
+  type TestElement,
   h,
-  render,
+  serializeInner as inner,
   nodeOps,
-  TestElement,
-  serializeInner as inner
+  render,
 } from '@vue/runtime-test'
 
 describe('renderer: element', () => {
index d0c9e5c79a7818d2ccb452d5598a4806de3d0961..a8299ef93dfd25e39a66d95979173391ae3ccfe6 100644 (file)
@@ -1,19 +1,19 @@
 import {
-  h,
-  createVNode,
-  render,
-  nodeOps,
-  TestNodeTypes,
-  TestElement,
   Fragment,
-  resetOps,
-  dumpOps,
   NodeOpTypes,
-  serializeInner,
-  createTextVNode,
+  type TestElement,
+  TestNodeTypes,
   createBlock,
+  createCommentVNode,
+  createTextVNode,
+  createVNode,
+  dumpOps,
+  h,
+  nodeOps,
   openBlock,
-  createCommentVNode
+  render,
+  resetOps,
+  serializeInner,
 } from '@vue/runtime-test'
 import { PatchFlags } from '@vue/shared'
 import { renderList } from '../src/helpers/renderList'
@@ -23,7 +23,7 @@ describe('renderer: fragment', () => {
     const App = {
       render() {
         return [h('div', 'one'), 'two']
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -33,23 +33,23 @@ describe('renderer: fragment', () => {
     expect(root.children.length).toBe(4)
     expect(root.children[0]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: ''
+      text: '',
     })
     expect(root.children[1]).toMatchObject({
       type: TestNodeTypes.ELEMENT,
-      tag: 'div'
+      tag: 'div',
     })
     expect((root.children[1] as TestElement).children[0]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: 'one'
+      text: 'one',
     })
     expect(root.children[2]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: 'two'
+      text: 'two',
     })
     expect(root.children[3]).toMatchObject({
       type: TestNodeTypes.TEXT,
-      text: ''
+      text: '',
     })
   })
 
@@ -64,22 +64,22 @@ describe('renderer: fragment', () => {
     const root = nodeOps.createElement('div')
     render(
       h(Fragment, [h('div', { key: 1 }, 'one'), h('div', { key: 2 }, 'two')]),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`<div>one</div><div>two</div>`)
 
     resetOps()
     render(
       h(Fragment, [h('div', { key: 2 }, 'two'), h('div', { key: 1 }, 'one')]),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`<div>two</div><div>one</div>`)
     const ops = dumpOps()
     // should be moving nodes instead of re-creating or patching them
     expect(ops).toMatchObject([
       {
-        type: NodeOpTypes.INSERT
-      }
+        type: NodeOpTypes.INSERT,
+      },
     ])
   })
 
@@ -95,11 +95,11 @@ describe('renderer: fragment', () => {
     // should be patching nodes instead of moving or re-creating them
     expect(ops).toMatchObject([
       {
-        type: NodeOpTypes.SET_ELEMENT_TEXT
+        type: NodeOpTypes.SET_ELEMENT_TEXT,
       },
       {
-        type: NodeOpTypes.SET_ELEMENT_TEXT
-      }
+        type: NodeOpTypes.SET_ELEMENT_TEXT,
+      },
     ])
   })
 
@@ -111,11 +111,11 @@ describe('renderer: fragment', () => {
         null,
         [
           createVNode('div', null, 'one', PatchFlags.TEXT),
-          createTextVNode('two')
+          createTextVNode('two'),
         ],
-        PatchFlags.UNKEYED_FRAGMENT
+        PatchFlags.UNKEYED_FRAGMENT,
       ),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`<div>one</div>two`)
 
@@ -126,11 +126,11 @@ describe('renderer: fragment', () => {
         [
           createVNode('div', null, 'foo', PatchFlags.TEXT),
           createTextVNode('bar'),
-          createTextVNode('baz')
+          createTextVNode('baz'),
         ],
-        PatchFlags.UNKEYED_FRAGMENT
+        PatchFlags.UNKEYED_FRAGMENT,
       ),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`<div>foo</div>barbaz`)
 
@@ -140,11 +140,11 @@ describe('renderer: fragment', () => {
         null,
         [
           createTextVNode('baz'),
-          createVNode('div', null, 'foo', PatchFlags.TEXT)
+          createVNode('div', null, 'foo', PatchFlags.TEXT),
         ],
-        PatchFlags.UNKEYED_FRAGMENT
+        PatchFlags.UNKEYED_FRAGMENT,
       ),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`baz<div>foo</div>`)
   })
@@ -157,9 +157,9 @@ describe('renderer: fragment', () => {
         Fragment,
         null,
         [h('div', { key: 1 }, 'one'), h('div', { key: 2 }, 'two')],
-        PatchFlags.KEYED_FRAGMENT
+        PatchFlags.KEYED_FRAGMENT,
       ),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`<div>one</div><div>two</div>`)
 
@@ -169,17 +169,17 @@ describe('renderer: fragment', () => {
         Fragment,
         null,
         [h('div', { key: 2 }, 'two'), h('div', { key: 1 }, 'one')],
-        PatchFlags.KEYED_FRAGMENT
+        PatchFlags.KEYED_FRAGMENT,
       ),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(`<div>two</div><div>one</div>`)
     const ops = dumpOps()
     // should be moving nodes instead of re-creating or patching them
     expect(ops).toMatchObject([
       {
-        type: NodeOpTypes.INSERT
-      }
+        type: NodeOpTypes.INSERT,
+      },
     ])
   })
 
@@ -190,13 +190,13 @@ describe('renderer: fragment', () => {
         h('div', { key: 1 }, 'outer'),
         h(Fragment, { key: 2 }, [
           h('div', { key: 1 }, 'one'),
-          h('div', { key: 2 }, 'two')
-        ])
+          h('div', { key: 2 }, 'two'),
+        ]),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(
-      `<div><div>outer</div><div>one</div><div>two</div></div>`
+      `<div><div>outer</div><div>one</div><div>two</div></div>`,
     )
 
     resetOps()
@@ -204,14 +204,14 @@ describe('renderer: fragment', () => {
       h('div', [
         h(Fragment, { key: 2 }, [
           h('div', { key: 2 }, 'two'),
-          h('div', { key: 1 }, 'one')
+          h('div', { key: 1 }, 'one'),
         ]),
-        h('div', { key: 1 }, 'outer')
+        h('div', { key: 1 }, 'outer'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(
-      `<div><div>two</div><div>one</div><div>outer</div></div>`
+      `<div><div>two</div><div>one</div><div>outer</div></div>`,
     )
     const ops = dumpOps()
     // should be moving nodes instead of re-creating them
@@ -224,7 +224,7 @@ describe('renderer: fragment', () => {
       { type: NodeOpTypes.INSERT, targetNode: { type: 'text', text: '' } },
       { type: NodeOpTypes.INSERT, targetNode: { type: 'element' } },
       { type: NodeOpTypes.INSERT, targetNode: { type: 'element' } },
-      { type: NodeOpTypes.INSERT, targetNode: { type: 'text', text: '' } }
+      { type: NodeOpTypes.INSERT, targetNode: { type: 'text', text: '' } },
     ])
   })
 
@@ -236,13 +236,13 @@ describe('renderer: fragment', () => {
         h('div', { key: 1 }, 'outer'),
         h(Fragment, { key: 2 }, [
           h('div', { key: 1 }, 'one'),
-          h('div', { key: 2 }, 'two')
-        ])
+          h('div', { key: 2 }, 'two'),
+        ]),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(
-      `<div>outer</div><div>one</div><div>two</div>`
+      `<div>outer</div><div>one</div><div>two</div>`,
     )
 
     resetOps()
@@ -250,14 +250,14 @@ describe('renderer: fragment', () => {
       h(Fragment, [
         h(Fragment, { key: 2 }, [
           h('div', { key: 2 }, 'two'),
-          h('div', { key: 1 }, 'one')
+          h('div', { key: 1 }, 'one'),
         ]),
-        h('div', { key: 1 }, 'outer')
+        h('div', { key: 1 }, 'outer'),
       ]),
-      root
+      root,
     )
     expect(serializeInner(root)).toBe(
-      `<div>two</div><div>one</div><div>outer</div>`
+      `<div>two</div><div>one</div><div>outer</div>`,
     )
     const ops = dumpOps()
     // should be moving nodes instead of re-creating them
@@ -266,7 +266,7 @@ describe('renderer: fragment', () => {
       { type: NodeOpTypes.INSERT, targetNode: { type: 'text', text: '' } },
       { type: NodeOpTypes.INSERT, targetNode: { type: 'element' } },
       { type: NodeOpTypes.INSERT, targetNode: { type: 'element' } },
-      { type: NodeOpTypes.INSERT, targetNode: { type: 'text', text: '' } }
+      { type: NodeOpTypes.INSERT, targetNode: { type: 'text', text: '' } },
     ])
 
     // should properly remove nested fragments
@@ -294,25 +294,25 @@ describe('renderer: fragment', () => {
                 [
                   createCommentVNode('comment'),
                   hoisted,
-                  createVNode('div', null, item, PatchFlags.TEXT)
+                  createVNode('div', null, item, PatchFlags.TEXT),
                 ],
-                PatchFlags.STABLE_FRAGMENT
+                PatchFlags.STABLE_FRAGMENT,
               )
             )
           }),
-          PatchFlags.KEYED_FRAGMENT
+          PatchFlags.KEYED_FRAGMENT,
         )
       )
     }
 
     render(renderFn(['one', 'two']), root)
     expect(serializeInner(root)).toBe(
-      `<!--comment--><span></span><div>one</div><!--comment--><span></span><div>two</div>`
+      `<!--comment--><span></span><div>one</div><!--comment--><span></span><div>two</div>`,
     )
 
     render(renderFn(['two', 'one']), root)
     expect(serializeInner(root)).toBe(
-      `<!--comment--><span></span><div>two</div><!--comment--><span></span><div>one</div>`
+      `<!--comment--><span></span><div>two</div><!--comment--><span></span><div>one</div>`,
     )
   })
 
@@ -334,13 +334,13 @@ describe('renderer: fragment', () => {
                 { key: item },
                 [
                   createTextVNode('text'),
-                  createVNode('div', null, item, PatchFlags.TEXT)
+                  createVNode('div', null, item, PatchFlags.TEXT),
                 ],
-                PatchFlags.STABLE_FRAGMENT
+                PatchFlags.STABLE_FRAGMENT,
               )
             )
           }),
-          PatchFlags.KEYED_FRAGMENT
+          PatchFlags.KEYED_FRAGMENT,
         )
       )
     }
index c2073b966a7ecd10175aa404ec6d86d4220078c4..ef5bdbe0136fa1255d16b962cf1b8df9cbf37b68 100644 (file)
@@ -1,29 +1,29 @@
 import {
-  h,
   Fragment,
+  type FunctionalComponent,
+  type SetupContext,
   Teleport,
-  createVNode,
-  createCommentVNode,
-  openBlock,
+  type TestElement,
+  type VNode,
+  createApp,
   createBlock,
-  render,
-  nodeOps,
-  TestElement,
-  serialize,
+  createCommentVNode,
+  createTextVNode,
+  createVNode,
+  defineComponent,
+  h,
   serializeInner as inner,
-  VNode,
-  ref,
   nextTick,
-  defineComponent,
-  withCtx,
-  renderSlot,
+  nodeOps,
   onBeforeUnmount,
-  createTextVNode,
-  SetupContext,
-  createApp,
-  FunctionalComponent,
+  onUnmounted,
+  openBlock,
+  ref,
+  render,
   renderList,
-  onUnmounted
+  renderSlot,
+  serialize,
+  withCtx,
 } from '@vue/runtime-test'
 import { PatchFlags, SlotFlags } from '@vue/shared'
 import { SuspenseImpl } from '../src/components/Suspense'
@@ -40,7 +40,7 @@ describe('renderer: optimized mode', () => {
   const renderWithBlock = (renderChildren: () => VNode[]) => {
     render(
       (openBlock(), (block = createBlock('div', null, renderChildren()))),
-      root
+      root,
     )
   }
 
@@ -54,7 +54,7 @@ describe('renderer: optimized mode', () => {
   test('block can appear anywhere in the vdom tree', () => {
     render(
       h('div', (openBlock(), (block = createBlock('p', null, 'foo')))),
-      root
+      root,
     )
 
     expect(block.dynamicChildren!.length).toBe(0)
@@ -64,12 +64,12 @@ describe('renderer: optimized mode', () => {
   test('block should collect dynamic vnodes', () => {
     renderWithBlock(() => [
       createVNode('p', null, 'foo', PatchFlags.TEXT),
-      createVNode('i')
+      createVNode('i'),
     ])
 
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p>foo</p>'
+      '<p>foo</p>',
     )
   })
 
@@ -78,9 +78,9 @@ describe('renderer: optimized mode', () => {
       // disable tracking
       (openBlock(true),
       (block = createBlock('div', null, [
-        createVNode('p', null, 'foo', PatchFlags.TEXT)
+        createVNode('p', null, 'foo', PatchFlags.TEXT),
       ]))),
-      root
+      root,
     )
 
     expect(block.dynamicChildren!.length).toBe(0)
@@ -88,23 +88,23 @@ describe('renderer: optimized mode', () => {
 
   test('block as dynamic children', () => {
     renderWithBlock(() => [
-      (openBlock(), createBlock('div', { key: 0 }, [h('p')]))
+      (openBlock(), createBlock('div', { key: 0 }, [h('p')])),
     ])
 
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(0)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<div><p></p></div>'
+      '<div><p></p></div>',
     )
 
     renderWithBlock(() => [
-      (openBlock(), createBlock('div', { key: 1 }, [h('i')]))
+      (openBlock(), createBlock('div', { key: 1 }, [h('i')])),
     ])
 
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(0)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<div><i></i></div>'
+      '<div><i></i></div>',
     )
   })
 
@@ -114,7 +114,7 @@ describe('renderer: optimized mode', () => {
     expect(inner(root)).toBe('<div><p>foo</p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p>foo</p>'
+      '<p>foo</p>',
     )
 
     renderWithBlock(() => [createVNode('p', null, 'bar', PatchFlags.TEXT)])
@@ -122,73 +122,73 @@ describe('renderer: optimized mode', () => {
     expect(inner(root)).toBe('<div><p>bar</p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p>bar</p>'
+      '<p>bar</p>',
     )
   })
 
   test('PatchFlags: PatchFlags.CLASS', async () => {
     renderWithBlock(() => [
-      createVNode('p', { class: 'foo' }, '', PatchFlags.CLASS)
+      createVNode('p', { class: 'foo' }, '', PatchFlags.CLASS),
     ])
 
     expect(inner(root)).toBe('<div><p class="foo"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p class="foo"></p>'
+      '<p class="foo"></p>',
     )
 
     renderWithBlock(() => [
-      createVNode('p', { class: 'bar' }, '', PatchFlags.CLASS)
+      createVNode('p', { class: 'bar' }, '', PatchFlags.CLASS),
     ])
 
     expect(inner(root)).toBe('<div><p class="bar"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p class="bar"></p>'
+      '<p class="bar"></p>',
     )
   })
 
   test('PatchFlags: PatchFlags.STYLE', async () => {
     renderWithBlock(() => [
-      createVNode('p', { style: 'color: red' }, '', PatchFlags.STYLE)
+      createVNode('p', { style: 'color: red' }, '', PatchFlags.STYLE),
     ])
 
     expect(inner(root)).toBe('<div><p style="color: red"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p style="color: red"></p>'
+      '<p style="color: red"></p>',
     )
 
     renderWithBlock(() => [
-      createVNode('p', { style: 'color: green' }, '', PatchFlags.STYLE)
+      createVNode('p', { style: 'color: green' }, '', PatchFlags.STYLE),
     ])
 
     expect(inner(root)).toBe('<div><p style="color: green"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p style="color: green"></p>'
+      '<p style="color: green"></p>',
     )
   })
 
   test('PatchFlags: PatchFlags.PROPS', async () => {
     renderWithBlock(() => [
-      createVNode('p', { id: 'foo' }, '', PatchFlags.PROPS, ['id'])
+      createVNode('p', { id: 'foo' }, '', PatchFlags.PROPS, ['id']),
     ])
 
     expect(inner(root)).toBe('<div><p id="foo"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p id="foo"></p>'
+      '<p id="foo"></p>',
     )
 
     renderWithBlock(() => [
-      createVNode('p', { id: 'bar' }, '', PatchFlags.PROPS, ['id'])
+      createVNode('p', { id: 'bar' }, '', PatchFlags.PROPS, ['id']),
     ])
 
     expect(inner(root)).toBe('<div><p id="bar"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p id="bar"></p>'
+      '<p id="bar"></p>',
     )
   })
 
@@ -196,24 +196,24 @@ describe('renderer: optimized mode', () => {
     let propName = 'foo'
 
     renderWithBlock(() => [
-      createVNode('p', { [propName]: 'dynamic' }, '', PatchFlags.FULL_PROPS)
+      createVNode('p', { [propName]: 'dynamic' }, '', PatchFlags.FULL_PROPS),
     ])
 
     expect(inner(root)).toBe('<div><p foo="dynamic"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p foo="dynamic"></p>'
+      '<p foo="dynamic"></p>',
     )
 
     propName = 'bar'
     renderWithBlock(() => [
-      createVNode('p', { [propName]: 'dynamic' }, '', PatchFlags.FULL_PROPS)
+      createVNode('p', { [propName]: 'dynamic' }, '', PatchFlags.FULL_PROPS),
     ])
 
     expect(inner(root)).toBe('<div><p bar="dynamic"></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p bar="dynamic"></p>'
+      '<p bar="dynamic"></p>',
     )
   })
 
@@ -228,18 +228,18 @@ describe('renderer: optimized mode', () => {
         list.map(item => {
           return createVNode('p', null, item, PatchFlags.TEXT)
         }),
-        PatchFlags.STABLE_FRAGMENT
+        PatchFlags.STABLE_FRAGMENT,
       ))),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<p>foo</p><p>bar</p>')
     expect(block.dynamicChildren!.length).toBe(2)
     expect(serialize(block.dynamicChildren![0].el as TestElement)).toBe(
-      '<p>foo</p>'
+      '<p>foo</p>',
     )
     expect(serialize(block.dynamicChildren![1].el as TestElement)).toBe(
-      '<p>bar</p>'
+      '<p>bar</p>',
     )
 
     list = list.map(item => item.repeat(2))
@@ -251,18 +251,18 @@ describe('renderer: optimized mode', () => {
         list.map(item => {
           return createVNode('p', null, item, PatchFlags.TEXT)
         }),
-        PatchFlags.STABLE_FRAGMENT
+        PatchFlags.STABLE_FRAGMENT,
       )),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<p>foofoo</p><p>barbar</p>')
     expect(block.dynamicChildren!.length).toBe(2)
     expect(serialize(block.dynamicChildren![0].el as TestElement)).toBe(
-      '<p>foofoo</p>'
+      '<p>foofoo</p>',
     )
     expect(serialize(block.dynamicChildren![1].el as TestElement)).toBe(
-      '<p>barbar</p>'
+      '<p>barbar</p>',
     )
   })
 
@@ -278,9 +278,9 @@ describe('renderer: optimized mode', () => {
         list.map(item => {
           return createVNode(item.tag, null, item.text)
         }),
-        PatchFlags.UNKEYED_FRAGMENT
+        PatchFlags.UNKEYED_FRAGMENT,
       ))),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<p>foo</p>')
@@ -295,9 +295,9 @@ describe('renderer: optimized mode', () => {
         list.map(item => {
           return createVNode(item.tag, null, item.text)
         }),
-        PatchFlags.UNKEYED_FRAGMENT
+        PatchFlags.UNKEYED_FRAGMENT,
       )),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<i>bar</i><p>foo</p>')
@@ -316,9 +316,9 @@ describe('renderer: optimized mode', () => {
         list.map(item => {
           return createVNode(item.tag, { key: item.tag }, item.text)
         }),
-        PatchFlags.KEYED_FRAGMENT
+        PatchFlags.KEYED_FRAGMENT,
       ))),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<p>foo</p>')
@@ -333,9 +333,9 @@ describe('renderer: optimized mode', () => {
         list.map(item => {
           return createVNode(item.tag, { key: item.tag }, item.text)
         }),
-        PatchFlags.KEYED_FRAGMENT
+        PatchFlags.KEYED_FRAGMENT,
       )),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<i>bar</i><p>foo</p>')
@@ -357,12 +357,12 @@ describe('renderer: optimized mode', () => {
                 'p',
                 { onVnodeMounted: spyMounted, onVnodeBeforeUpdate: spyUpdated },
                 '',
-                PatchFlags.NEED_PATCH
-              )
+                PatchFlags.NEED_PATCH,
+              ),
             ]))
           )
         }
-      }
+      },
     }
 
     render(h(Comp), root)
@@ -370,7 +370,7 @@ describe('renderer: optimized mode', () => {
     expect(inner(root)).toBe('<div><p></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p></p>'
+      '<p></p>',
     )
     expect(spyMounted).toHaveBeenCalledTimes(1)
     expect(spyUpdated).toHaveBeenCalledTimes(0)
@@ -381,7 +381,7 @@ describe('renderer: optimized mode', () => {
     expect(inner(root)).toBe('<div><p></p></div>')
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(serialize(block!.dynamicChildren![0].el as TestElement)).toBe(
-      '<p></p>'
+      '<p></p>',
     )
     expect(spyMounted).toHaveBeenCalledTimes(1)
     expect(spyUpdated).toHaveBeenCalledTimes(1)
@@ -391,7 +391,7 @@ describe('renderer: optimized mode', () => {
     render(
       (openBlock(),
       (block = createBlock('div', null, [createVNode('p', null, 'foo')]))),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<div><p>foo</p></div>')
@@ -403,9 +403,9 @@ describe('renderer: optimized mode', () => {
         'div',
         null,
         [createVNode('i', null, 'bar')],
-        PatchFlags.BAIL
+        PatchFlags.BAIL,
       ))),
-      root
+      root,
     )
 
     expect(inner(root)).toBe('<div><i>bar</i></div>')
@@ -422,12 +422,12 @@ describe('renderer: optimized mode', () => {
             (openBlock(),
             (block = createBlock('div', null, {
               default: withCtx(() => [renderSlot(slots, 'default')]),
-              _: SlotFlags.FORWARDED
+              _: SlotFlags.FORWARDED,
             })))
 
           return vnode
         }
-      }
+      },
     })
 
     const foo = ref(0)
@@ -436,13 +436,13 @@ describe('renderer: optimized mode', () => {
         return () => {
           return createVNode(Comp, null, {
             default: withCtx(() => [
-              createVNode('p', null, foo.value, PatchFlags.TEXT)
+              createVNode('p', null, foo.value, PatchFlags.TEXT),
             ]),
             // Indicates that this is a stable slot to avoid bail out
-            _: SlotFlags.STABLE
+            _: SlotFlags.STABLE,
           })
         }
-      }
+      },
     }
 
     render(h(App), root)
@@ -452,8 +452,8 @@ describe('renderer: optimized mode', () => {
     expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(1)
     expect(
       serialize(
-        block!.dynamicChildren![0].dynamicChildren![0].el as TestElement
-      )
+        block!.dynamicChildren![0].dynamicChildren![0].el as TestElement,
+      ),
     ).toBe('<p>0</p>')
 
     foo.value++
@@ -474,12 +474,12 @@ describe('renderer: optimized mode', () => {
       setup() {
         onBeforeUnmount(spy)
         return () => 'child'
-      }
+      },
     }
     const Parent = () => (
       openBlock(),
       createBlock('div', null, [
-        createVNode('div', { style: {} }, [createVNode(Child)], 4 /* STYLE */)
+        createVNode('div', { style: {} }, [createVNode(Child)], 4 /* STYLE */),
       ])
     )
     render(h(Parent), root)
@@ -496,13 +496,13 @@ describe('renderer: optimized mode', () => {
       setup() {
         onBeforeUnmount(spyA)
         return () => 'child'
-      }
+      },
     }
     const ChildB = {
       setup() {
         onBeforeUnmount(spyB)
         return () => 'child'
-      }
+      },
     }
     const Parent = () => (
       openBlock(),
@@ -512,15 +512,15 @@ describe('renderer: optimized mode', () => {
           Fragment,
           null,
           [createVNode(ChildA, { key: 0 })],
-          128 /* KEYED_FRAGMENT */
+          128 /* KEYED_FRAGMENT */,
         )),
         (openBlock(true),
         createBlock(
           Fragment,
           null,
           [createVNode(ChildB)],
-          256 /* UNKEYED_FRAGMENT */
-        ))
+          256 /* UNKEYED_FRAGMENT */,
+        )),
       ])
     )
     render(h(Parent), root)
@@ -541,7 +541,7 @@ describe('renderer: optimized mode', () => {
             createBlock('div', null, [renderSlot(slots, 'default')])
           )
         }
-      }
+      },
     }
 
     const Wrapper = {
@@ -551,7 +551,7 @@ describe('renderer: optimized mode', () => {
         return () => {
           return slots.default!()[state.value]
         }
-      }
+      },
     }
 
     const app = createApp({
@@ -563,18 +563,18 @@ describe('renderer: optimized mode', () => {
               default: withCtx(() => [
                 createVNode(CompA, null, {
                   default: withCtx(() => [createTextVNode('Hello')]),
-                  _: 1 /* STABLE */
+                  _: 1 /* STABLE */,
                 }),
                 createVNode(CompA, null, {
                   default: withCtx(() => [createTextVNode('World')]),
-                  _: 1 /* STABLE */
-                })
+                  _: 1 /* STABLE */,
+                }),
               ]),
-              _: 1 /* STABLE */
+              _: 1 /* STABLE */,
             })
           )
         }
-      }
+      },
     })
 
     app.mount(root)
@@ -597,7 +597,7 @@ describe('renderer: optimized mode', () => {
         createBlock(
           Teleport as any,
           {
-            to: target
+            to: target,
           },
           [
             createVNode('div', null, [
@@ -605,21 +605,21 @@ describe('renderer: optimized mode', () => {
               createBlock(
                 Teleport as any,
                 {
-                  to: target
+                  to: target,
                 },
-                [createVNode('div', null, 'foo')]
-              ))
-            ])
-          ]
-        ))
+                [createVNode('div', null, 'foo')],
+              )),
+            ]),
+          ],
+        )),
       ])),
-      root
+      root,
     )
     expect(inner(target)).toMatchInlineSnapshot(
-      `"<div><!--teleport start--><!--teleport end--></div><div>foo</div>"`
+      `"<div><!--teleport start--><!--teleport end--></div><div>foo</div>"`,
     )
     expect(inner(root)).toMatchInlineSnapshot(
-      `"<div><!--teleport start--><!--teleport end--></div>"`
+      `"<div><!--teleport start--><!--teleport end--></div>"`,
     )
 
     render(null, root)
@@ -634,11 +634,11 @@ describe('renderer: optimized mode', () => {
           return (
             openBlock(),
             (block = createBlock('section', null, [
-              renderSlot(slots, 'default')
+              renderSlot(slots, 'default'),
             ]))
           )
         }
-      }
+      },
     }
 
     let dynamicVNode: VNode
@@ -654,19 +654,19 @@ describe('renderer: optimized mode', () => {
                     'div',
                     {
                       class: {
-                        foo: !!slots.default!()
-                      }
+                        foo: !!slots.default!(),
+                      },
                     },
                     null,
-                    PatchFlags.CLASS
-                  ))
+                    PatchFlags.CLASS,
+                  )),
                 ]
               }),
-              _: 1
+              _: 1,
             })
           )
         }
-      }
+      },
     }
     const app = createApp({
       render() {
@@ -676,10 +676,10 @@ describe('renderer: optimized mode', () => {
             default: withCtx(() => {
               return [createVNode({}) /* component */]
             }),
-            _: 1
+            _: 1,
           })
         )
-      }
+      },
     })
 
     app.mount(root)
@@ -693,7 +693,7 @@ describe('renderer: optimized mode', () => {
     expect(block!.dynamicChildren!.length).toBe(1)
     expect(block!.dynamicChildren![0].dynamicChildren!.length).toBe(1)
     expect(block!.dynamicChildren![0].dynamicChildren![0]).toEqual(
-      dynamicVNode!
+      dynamicVNode!,
     )
   })
 
@@ -705,7 +705,7 @@ describe('renderer: optimized mode', () => {
         return () => {
           return slots.default!()[index.value]
         }
-      }
+      },
     }
 
     const app = createApp({
@@ -720,13 +720,13 @@ describe('renderer: optimized mode', () => {
                   : createCommentVNode('v-if', true),
                 true
                   ? (openBlock(), createBlock('p', { key: 0 }, '2'))
-                  : createCommentVNode('v-if', true)
+                  : createCommentVNode('v-if', true),
               ]),
-              _: 1 /* STABLE */
+              _: 1 /* STABLE */,
             })
           )
         }
-      }
+      },
     })
 
     app.mount(root)
@@ -746,7 +746,7 @@ describe('renderer: optimized mode', () => {
     const Middle = {
       setup(props: any, { slots }: any) {
         return slots.default!
-      }
+      },
     }
 
     const Comp = {
@@ -758,16 +758,16 @@ describe('renderer: optimized mode', () => {
               createVNode(Middle, null, {
                 default: withCtx(
                   () => [
-                    createVNode('div', null, [renderSlot(slots, 'default')])
+                    createVNode('div', null, [renderSlot(slots, 'default')]),
                   ],
-                  undefined
+                  undefined,
                 ),
-                _: 3 /* FORWARDED */
-              })
+                _: 3 /* FORWARDED */,
+              }),
             ])
           )
         }
-      }
+      },
     }
 
     const loading = ref(false)
@@ -777,10 +777,10 @@ describe('renderer: optimized mode', () => {
           // important: write the slot content here
           const content = h('span', loading.value ? 'loading' : 'loaded')
           return h(Comp, null, {
-            default: () => content
+            default: () => content,
           })
         }
-      }
+      },
     })
 
     app.mount(root)
@@ -807,16 +807,16 @@ describe('renderer: optimized mode', () => {
               createBlock(SuspenseImpl, null, {
                 default: withCtx(() => [
                   createVNode('div', null, [
-                    createVNode('div', null, show.value, PatchFlags.TEXT)
-                  ])
+                    createVNode('div', null, show.value, PatchFlags.TEXT),
+                  ]),
                 ]),
-                _: SlotFlags.STABLE
-              }))
+                _: SlotFlags.STABLE,
+              })),
             ],
-            PatchFlags.STABLE_FRAGMENT
+            PatchFlags.STABLE_FRAGMENT,
           )
         )
-      }
+      },
     })
 
     app.mount(root)
@@ -838,17 +838,17 @@ describe('renderer: optimized mode', () => {
           openBlock(),
           createBlock(SuspenseImpl, null, {
             default: withCtx(() => [renderSlot(slots, 'default')]),
-            _: SlotFlags.FORWARDED
+            _: SlotFlags.FORWARDED,
           })
         )
-      }
+      },
     }
 
     const Child = {
       setup() {
         onUnmounted(spyUnmounted)
         return () => createVNode('div', null, show.value, PatchFlags.TEXT)
-      }
+      },
     }
 
     const app = createApp({
@@ -860,11 +860,11 @@ describe('renderer: optimized mode', () => {
               { key: 0 },
               {
                 default: withCtx(() => [createVNode(Child)]),
-                _: SlotFlags.STABLE
-              }
+                _: SlotFlags.STABLE,
+              },
             ))
           : createCommentVNode('v-if', true)
-      }
+      },
     })
 
     app.mount(root)
@@ -907,17 +907,17 @@ describe('renderer: optimized mode', () => {
                     renderList(1, item => {
                       return createVNode('li', null, [createVNode(Dummy)])
                     }),
-                    64 /* STABLE_FRAGMENT */
-                  ))
-                ])
+                    64 /* STABLE_FRAGMENT */,
+                  )),
+                ]),
               ],
               undefined,
-              true
+              true,
             ),
-            _: 1 /* STABLE */
-          }
+            _: 1 /* STABLE */,
+          },
         )
-      }
+      },
     })
 
     app.mount(root)
index 28d7a95eb0b5ce5cbf9cbca215f285382c7ca2c2..9f26bf9bdf8cf8137719c89b60d4c7471a84a8e8 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  ref,
-  nodeOps,
+  defineComponent,
   h,
-  render,
   nextTick,
-  defineComponent,
+  nodeOps,
   reactive,
+  ref,
+  render,
   serializeInner,
-  shallowRef
+  shallowRef,
 } from '@vue/runtime-test'
 
 // reference: https://vue-composition-api-rfc.netlify.com/api.html#template-refs
@@ -20,12 +20,12 @@ describe('api: template refs', () => {
     const Comp = {
       setup() {
         return {
-          refKey: el
+          refKey: el,
         }
       },
       render() {
         return h('div', { ref: 'refKey' })
-      }
+      },
     }
     render(h(Comp), root)
     expect(el.value).toBe(root.children[0])
@@ -41,12 +41,12 @@ describe('api: template refs', () => {
       setup() {
         return {
           foo: fooEl,
-          bar: barEl
+          bar: barEl,
         }
       },
       render() {
         return h('div', { ref: refKey.value })
-      }
+      },
     }
     render(h(Comp), root)
     expect(fooEl.value).toBe(root.children[0])
@@ -66,12 +66,12 @@ describe('api: template refs', () => {
     const Comp = {
       setup() {
         return {
-          refKey: el
+          refKey: el,
         }
       },
       render() {
         return toggle.value ? h('div', { ref: 'refKey' }) : null
-      }
+      },
     }
     render(h(Comp), root)
     expect(el.value).toBe(root.children[0])
@@ -116,7 +116,7 @@ describe('api: template refs', () => {
     const toggle = ref(true)
 
     const Comp = defineComponent(
-      () => () => (toggle.value ? h('div', { ref: fn }) : null)
+      () => () => (toggle.value ? h('div', { ref: fn }) : null),
     )
     render(h(Comp), root)
     expect(fn.mock.calls[0][0]).toBe(root.children[0])
@@ -132,7 +132,7 @@ describe('api: template refs', () => {
     const Comp = {
       setup() {
         return () => h('div', { ref: el })
-      }
+      },
     }
     render(h(Comp), root)
     expect(el.value).toBe(root.children[0])
@@ -142,14 +142,14 @@ describe('api: template refs', () => {
     const root = nodeOps.createElement('div')
     const refs = {
       foo: ref(null),
-      bar: ref(null)
+      bar: ref(null),
     }
     const refKey = ref<keyof typeof refs>('foo')
 
     const Comp = {
       setup() {
         return () => h('div', { ref: refs[refKey.value] })
-      }
+      },
     }
     render(h(Comp), root)
     expect(refs.foo.value).toBe(root.children[0])
@@ -169,7 +169,7 @@ describe('api: template refs', () => {
     const Comp = {
       setup() {
         return () => (toggle.value ? h('div', { ref: el }) : null)
-      }
+      },
     }
     render(h(Comp), root)
     expect(el.value).toBe(root.children[0])
@@ -185,7 +185,7 @@ describe('api: template refs', () => {
     const Child = {
       render(this: any) {
         return this.$slots.default()
-      }
+      },
     }
 
     const Comp = {
@@ -196,7 +196,7 @@ describe('api: template refs', () => {
       },
       mounted(this: any) {
         spy(this.$refs.foo.tag)
-      }
+      },
     }
     render(h(Comp), root)
 
@@ -206,7 +206,7 @@ describe('api: template refs', () => {
   it('should work with direct reactive property', () => {
     const root = nodeOps.createElement('div')
     const state = reactive({
-      refKey: null
+      refKey: null,
     })
 
     const Comp = {
@@ -215,7 +215,7 @@ describe('api: template refs', () => {
       },
       render() {
         return h('div', { ref: 'refKey' })
-      }
+      },
     }
     render(h(Comp), root)
     expect(state.refKey).toBe(root.children[0])
@@ -232,16 +232,16 @@ describe('api: template refs', () => {
         return {
           refKey1,
           refKey2,
-          refKey3
+          refKey3,
         }
       },
       render() {
         return [
           h('div', { ref: 'refKey1' }),
           h('div', { ref: 'refKey2' }),
-          h('div', { ref: 'refKey3' })
+          h('div', { ref: 'refKey3' }),
         ]
-      }
+      },
     }
     render(h(Comp), root)
     expect(refKey1.value).toBe(root.children[1])
@@ -258,7 +258,7 @@ describe('api: template refs', () => {
       },
       render(this: any) {
         return h('div', { id: 'foo', ref: 'el' }, this.el && this.el.props.id)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -279,7 +279,7 @@ describe('api: template refs', () => {
       render(this: any) {
         return [
           h('p', { ref: refToggle.value ? 'foo' : 'bar' }),
-          h('i', { ref: refToggle.value ? 'bar' : 'foo' })
+          h('i', { ref: refToggle.value ? 'bar' : 'foo' }),
         ]
       },
       mounted(this: any) {
@@ -287,7 +287,7 @@ describe('api: template refs', () => {
       },
       updated(this: any) {
         spy(this.$refs.foo.tag, this.$refs.bar.tag)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -315,7 +315,7 @@ describe('api: template refs', () => {
       },
       updated(this: any) {
         spy(this.$refs.foo.tag)
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -330,10 +330,10 @@ describe('api: template refs', () => {
   // #2078
   test('handling multiple merged refs', async () => {
     const Foo = {
-      render: () => h('div', 'foo')
+      render: () => h('div', 'foo'),
     }
     const Bar = {
-      render: () => h('div', 'bar')
+      render: () => h('div', 'bar'),
     }
 
     const viewRef = shallowRef<any>(Foo)
@@ -347,7 +347,7 @@ describe('api: template refs', () => {
         }
         const view = h(viewRef.value, { ref: elRef1 })
         return h(view, { ref: elRef2 })
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -381,11 +381,11 @@ describe('api: template refs', () => {
           'div',
           {
             ref: el,
-            ref_key: 'el'
+            ref_key: 'el',
           },
-          'hello'
+          'hello',
         )
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -411,14 +411,14 @@ describe('api: template refs', () => {
                   'li',
                   {
                     ref: listRefs,
-                    ref_for: true
+                    ref_for: true,
                   },
-                  i
-                )
-              )
+                  i,
+                ),
+              ),
             )
           : null
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -462,14 +462,14 @@ describe('api: template refs', () => {
                   'li',
                   {
                     ref: 'listRefs',
-                    ref_for: true
+                    ref_for: true,
                   },
-                  i
-                )
-              )
+                  i,
+                ),
+              ),
             )
           : null
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -512,31 +512,31 @@ describe('api: template refs', () => {
                 'li',
                 {
                   ref: 'listRefs',
-                  ref_for: true
+                  ref_for: true,
                 },
-                i
-              )
-            )
-          )
+                i,
+              ),
+            ),
+          ),
         ])
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
 
     await nextTick()
     expect(String(listRefs.value)).toBe(
-      '[object Object],[object Object],[object Object]'
+      '[object Object],[object Object],[object Object]',
     )
     expect(serializeInner(root)).toBe(
-      '<div><div>[object Object],[object Object],[object Object]</div><ul><li>1</li><li>2</li><li>3</li></ul></div>'
+      '<div><div>[object Object],[object Object],[object Object]</div><ul><li>1</li><li>2</li><li>3</li></ul></div>',
     )
 
     list.value.splice(0, 1)
     await nextTick()
     expect(String(listRefs.value)).toBe('[object Object],[object Object]')
     expect(serializeInner(root)).toBe(
-      '<div><div>[object Object],[object Object]</div><ul><li>2</li><li>3</li></ul></div>'
+      '<div><div>[object Object],[object Object]</div><ul><li>2</li><li>3</li></ul></div>',
     )
   })
 })
index 119d0f7080c0cf11af31bbdb5938e7a84b8bad81..c6fe292fb7b4761ed5b8a77bdfff2a40d68b6c46 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  queueJob,
+  flushPostFlushCbs,
+  flushPreFlushCbs,
+  invalidateJob,
   nextTick,
+  queueJob,
   queuePostFlushCb,
-  invalidateJob,
-  flushPostFlushCbs,
-  flushPreFlushCbs
 } from '../src/scheduler'
 
 describe('scheduler', () => {
@@ -497,7 +497,7 @@ describe('scheduler', () => {
       expect(e).toBe(err)
     }
     expect(
-      `Unhandled error during execution of scheduler flush`
+      `Unhandled error during execution of scheduler flush`,
     ).toHaveBeenWarned()
 
     // this one should no longer error
@@ -571,7 +571,7 @@ describe('scheduler', () => {
 
     // simulate parent component that toggles child
     const job1 = () => {
-      // @ts-ignore
+      // @ts-expect-error
       job2.active = false
     }
     // simulate child that's triggered by the same reactive change that
index cdbb81c4191c0817f04094581fd8f1fad46d068f..fb705cfad090d4eeebde80c24ce1a1f4ae70ec71 100644 (file)
@@ -1,12 +1,12 @@
 import {
   h,
-  render,
   nodeOps,
-  serializeInner,
+  popScopeId,
+  pushScopeId,
+  render,
   renderSlot,
+  serializeInner,
   withScopeId,
-  pushScopeId,
-  popScopeId
 } from '@vue/runtime-test'
 import { withCtx } from '../src/componentRenderContext'
 
@@ -14,7 +14,7 @@ describe('scopeId runtime support', () => {
   test('should attach scopeId', () => {
     const App = {
       __scopeId: 'parent',
-      render: () => h('div', [h('div')])
+      render: () => h('div', [h('div')]),
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -24,17 +24,17 @@ describe('scopeId runtime support', () => {
   test('should attach scopeId to components in parent component', () => {
     const Child = {
       __scopeId: 'child',
-      render: () => h('div')
+      render: () => h('div'),
     }
     const App = {
       __scopeId: 'parent',
-      render: () => h('div', [h(Child)])
+      render: () => h('div', [h(Child)]),
     }
 
     const root = nodeOps.createElement('div')
     render(h(App), root)
     expect(serializeInner(root)).toBe(
-      `<div parent><div child parent></div></div>`
+      `<div parent><div child parent></div></div>`,
     )
   })
 
@@ -44,11 +44,11 @@ describe('scopeId runtime support', () => {
       __scopeId: 'child',
       render(this: any) {
         return h('div', renderSlot(this.$slots, 'default'))
-      }
+      },
     }
     const Child2 = {
       __scopeId: 'child2',
-      render: () => h('span')
+      render: () => h('span'),
     }
     const App = {
       __scopeId: 'parent',
@@ -57,9 +57,9 @@ describe('scopeId runtime support', () => {
           Child,
           withCtx(() => {
             return [h('div'), h(Child2)]
-          })
+          }),
         )
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -74,7 +74,7 @@ describe('scopeId runtime support', () => {
         // - slotted scopeId from slot owner
         // - its own scopeId
         `<span child2 parent child-s></span>` +
-        `</div>`
+        `</div>`,
     )
   })
 
@@ -90,10 +90,10 @@ describe('scopeId runtime support', () => {
             'default',
             {},
             undefined,
-            true /* noSlotted */
-          )
+            true /* noSlotted */,
+          ),
         ])
-      }
+      },
     }
 
     const Slotted = {
@@ -101,9 +101,9 @@ describe('scopeId runtime support', () => {
       render(this: any) {
         // <Wrapper><slot/></Wrapper>
         return h(Wrapper, null, {
-          default: withCtx(() => [renderSlot(this.$slots, 'default')])
+          default: withCtx(() => [renderSlot(this.$slots, 'default')]),
         })
-      }
+      },
     }
 
     // simulate hoisted node
@@ -118,9 +118,9 @@ describe('scopeId runtime support', () => {
         return h(Slotted, null, {
           default: withCtx(() => {
             return [hoisted, h('div', 'dynamic')]
-          })
+          }),
         })
-      }
+      },
     }
 
     const root = nodeOps.createElement('div')
@@ -129,7 +129,7 @@ describe('scopeId runtime support', () => {
       `<div wrapper slotted root class="wrapper">` +
         `<div root slotted-s>hoisted</div>` +
         `<div root slotted-s>dynamic</div>` +
-        `</div>`
+        `</div>`,
     )
 
     const Root2 = {
@@ -143,11 +143,11 @@ describe('scopeId runtime support', () => {
         return h(Slotted, null, {
           default: withCtx(() => [
             h(Wrapper, null, {
-              default: withCtx(() => [hoisted, h('div', 'dynamic')])
-            })
-          ])
+              default: withCtx(() => [hoisted, h('div', 'dynamic')]),
+            }),
+          ]),
         })
-      }
+      },
     }
     const root2 = nodeOps.createElement('div')
     render(h(Root2), root2)
@@ -157,7 +157,7 @@ describe('scopeId runtime support', () => {
         `<div root>hoisted</div>` +
         `<div root>dynamic</div>` +
         `</div>` +
-        `</div>`
+        `</div>`,
     )
   })
 
@@ -167,7 +167,7 @@ describe('scopeId runtime support', () => {
       __scopeId: 'parent',
       render: () => {
         return h(Child)
-      }
+      },
     }
 
     function Child() {
@@ -195,7 +195,7 @@ describe('backwards compat with <=3.0.7', () => {
       __scopeId: 'parent',
       render: withParentId(() => {
         return h('div', [h('div')])
-      })
+      }),
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -207,19 +207,19 @@ describe('backwards compat with <=3.0.7', () => {
       __scopeId: 'child',
       render: withChildId(() => {
         return h('div')
-      })
+      }),
     }
     const App = {
       __scopeId: 'parent',
       render: withParentId(() => {
         return h('div', [h(Child)])
-      })
+      }),
     }
 
     const root = nodeOps.createElement('div')
     render(h(App), root)
     expect(serializeInner(root)).toBe(
-      `<div parent><div child parent></div></div>`
+      `<div parent><div child parent></div></div>`,
     )
   })
 
@@ -228,12 +228,12 @@ describe('backwards compat with <=3.0.7', () => {
       __scopeId: 'child',
       render: withChildId(function (this: any) {
         return h('div', renderSlot(this.$slots, 'default'))
-      })
+      }),
     }
     const withChild2Id = withScopeId('child2')
     const Child2 = {
       __scopeId: 'child2',
-      render: withChild2Id(() => h('span'))
+      render: withChild2Id(() => h('span')),
     }
     const App = {
       __scopeId: 'parent',
@@ -242,9 +242,9 @@ describe('backwards compat with <=3.0.7', () => {
           Child,
           withParentId(() => {
             return [h('div'), h(Child2)]
-          })
+          }),
         )
-      })
+      }),
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
@@ -259,7 +259,7 @@ describe('backwards compat with <=3.0.7', () => {
         // - slotted scopeId from slot owner
         // - its own scopeId
         `<span child2 parent child-s></span>` +
-        `</div>`
+        `</div>`,
     )
   })
 
@@ -270,7 +270,7 @@ describe('backwards compat with <=3.0.7', () => {
       __scopeId: 'parent',
       render: withParentId(() => {
         return h(Child)
-      })
+      }),
     }
 
     function Child() {
@@ -295,14 +295,14 @@ describe('backwards compat with <=3.0.7', () => {
 
     const App = {
       __scopeId: 'foobar',
-      render: () => h('div', [hoisted])
+      render: () => h('div', [hoisted]),
     }
 
     const root = nodeOps.createElement('div')
     render(h(App), root)
 
     expect(serializeInner(root)).toBe(
-      `<div foobar><div foobar>hello</div></div>`
+      `<div foobar><div foobar>hello</div></div>`,
     )
   })
 })
index 11b2044a9e3650f9987dd8cd80e2e1438ae1ac28..653613ddb2ef58bf345f562f382452bff7fe8f30 100644 (file)
@@ -1,19 +1,19 @@
 import {
-  createBlock,
-  createVNode,
-  openBlock,
   Comment,
   Fragment,
   Text,
   cloneVNode,
+  createBlock,
+  createVNode,
+  isBlockTreeEnabled,
   mergeProps,
   normalizeVNode,
+  openBlock,
   transformVNodeArgs,
-  isBlockTreeEnabled
 } from '../src/vnode'
-import { Data } from '../src/component'
-import { ShapeFlags, PatchFlags } from '@vue/shared'
-import { h, reactive, isReactive, setBlockTracking, ref, withCtx } from '../src'
+import type { Data } from '../src/component'
+import { PatchFlags, ShapeFlags } from '@vue/shared'
+import { h, isReactive, reactive, ref, setBlockTracking, withCtx } from '../src'
 import { createApp, nodeOps, serializeInner } from '@vue/runtime-test'
 import { setCurrentRenderingInstance } from '../src/componentRenderContext'
 
@@ -56,10 +56,10 @@ describe('vnode', () => {
       type: 'p',
       props: {
         id: 'foo',
-        class: 'bar'
+        class: 'bar',
       },
       children: 'baz',
-      shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN
+      shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN,
     })
   })
 
@@ -94,7 +94,7 @@ describe('vnode', () => {
 
     test('array<object>', () => {
       const vnode = createVNode('p', {
-        class: [{ foo: 'foo' }, { baz: 'baz' }]
+        class: [{ foo: 'foo' }, { baz: 'baz' }],
       })
       expect(vnode.props).toMatchObject({ class: 'foo baz' })
     })
@@ -108,7 +108,7 @@ describe('vnode', () => {
   describe('style normalization', () => {
     test('array', () => {
       const vnode = createVNode('p', {
-        style: [{ foo: 'foo' }, { baz: 'baz' }]
+        style: [{ foo: 'foo' }, { baz: 'baz' }],
       })
       expect(vnode.props).toMatchObject({ style: { foo: 'foo', baz: 'baz' } })
     })
@@ -132,7 +132,7 @@ describe('vnode', () => {
       const vnode = createVNode('p', null, ['foo'])
       expect(vnode.children).toMatchObject(['foo'])
       expect(vnode.shapeFlag).toBe(
-        ShapeFlags.ELEMENT | ShapeFlags.ARRAY_CHILDREN
+        ShapeFlags.ELEMENT | ShapeFlags.ARRAY_CHILDREN,
       )
     })
 
@@ -140,7 +140,7 @@ describe('vnode', () => {
       const vnode = createVNode({}, null, { foo: 'foo' })
       expect(vnode.children).toMatchObject({ foo: 'foo' })
       expect(vnode.shapeFlag).toBe(
-        ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.SLOTS_CHILDREN
+        ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.SLOTS_CHILDREN,
       )
     })
 
@@ -148,7 +148,7 @@ describe('vnode', () => {
       const vnode = createVNode('p', null, nop)
       expect(vnode.children).toMatchObject({ default: nop })
       expect(vnode.shapeFlag).toBe(
-        ShapeFlags.ELEMENT | ShapeFlags.SLOTS_CHILDREN
+        ShapeFlags.ELEMENT | ShapeFlags.SLOTS_CHILDREN,
       )
     })
 
@@ -156,19 +156,19 @@ describe('vnode', () => {
       const vnode = createVNode('p', null, 'foo')
       expect(vnode.children).toBe('foo')
       expect(vnode.shapeFlag).toBe(
-        ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN
+        ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN,
       )
     })
 
     test('element with slots', () => {
       const children = [createVNode('span', null, 'hello')]
       const vnode = createVNode('div', null, {
-        default: () => children
+        default: () => children,
       })
 
       expect(vnode.children).toBe(children)
       expect(vnode.shapeFlag).toBe(
-        ShapeFlags.ELEMENT | ShapeFlags.ARRAY_CHILDREN
+        ShapeFlags.ELEMENT | ShapeFlags.ARRAY_CHILDREN,
       )
     })
   })
@@ -207,7 +207,7 @@ describe('vnode', () => {
     expect(createVNode('div').shapeFlag).toBe(ShapeFlags.ELEMENT)
     expect(createVNode({}).shapeFlag).toBe(ShapeFlags.STATEFUL_COMPONENT)
     expect(createVNode(() => {}).shapeFlag).toBe(
-      ShapeFlags.FUNCTIONAL_COMPONENT
+      ShapeFlags.FUNCTIONAL_COMPONENT,
     )
     expect(createVNode(Text).shapeFlag).toBe(0)
   })
@@ -239,7 +239,7 @@ describe('vnode', () => {
     expect(original.ref).toMatchObject({
       i: mockInstance1,
       r: 'foo',
-      f: false
+      f: false,
     })
 
     // clone and preserve original ref
@@ -276,7 +276,7 @@ describe('vnode', () => {
     expect(original3.ref).toMatchObject({
       i: mockInstance2,
       r: 'foo',
-      f: true
+      f: true,
     })
     const cloned7 = cloneVNode(original3, { ref: 'bar', ref_for: true })
     expect(cloned7.ref).toMatchObject({ i: mockInstance2, r: 'bar', f: true })
@@ -286,7 +286,7 @@ describe('vnode', () => {
     expect(original4.ref).toMatchObject({
       i: mockInstance2,
       r,
-      k: 'foo'
+      k: 'foo',
     })
     const cloned8 = cloneVNode(original4)
     expect(cloned8.ref).toMatchObject({ i: mockInstance2, r, k: 'foo' })
@@ -307,7 +307,7 @@ describe('vnode', () => {
     const cloned1 = cloneVNode(original, { ref: 'bar' }, true)
     expect(cloned1.ref).toMatchObject([
       { i: mockInstance1, r: 'foo', f: false },
-      { i: mockInstance2, r: 'bar', f: false }
+      { i: mockInstance2, r: 'bar', f: false },
     ])
 
     setCurrentRenderingInstance(null)
@@ -316,19 +316,19 @@ describe('vnode', () => {
   test('cloneVNode class normalization', () => {
     const vnode = createVNode('div')
     const expectedProps = {
-      class: 'a b'
+      class: 'a b',
     }
     expect(cloneVNode(vnode, { class: 'a b' }).props).toMatchObject(
-      expectedProps
+      expectedProps,
     )
     expect(cloneVNode(vnode, { class: ['a', 'b'] }).props).toMatchObject(
-      expectedProps
+      expectedProps,
     )
     expect(
-      cloneVNode(vnode, { class: { a: true, b: true } }).props
+      cloneVNode(vnode, { class: { a: true, b: true } }).props,
     ).toMatchObject(expectedProps)
     expect(
-      cloneVNode(vnode, { class: [{ a: true, b: true }] }).props
+      cloneVNode(vnode, { class: [{ a: true, b: true }] }).props,
     ).toMatchObject(expectedProps)
   })
 
@@ -337,29 +337,29 @@ describe('vnode', () => {
     const expectedProps = {
       style: {
         color: 'blue',
-        width: '300px'
-      }
+        width: '300px',
+      },
     }
     expect(
-      cloneVNode(vnode, { style: 'color: blue; width: 300px;' }).props
+      cloneVNode(vnode, { style: 'color: blue; width: 300px;' }).props,
     ).toMatchObject(expectedProps)
     expect(
       cloneVNode(vnode, {
         style: {
           color: 'blue',
-          width: '300px'
-        }
-      }).props
+          width: '300px',
+        },
+      }).props,
     ).toMatchObject(expectedProps)
     expect(
       cloneVNode(vnode, {
         style: [
           {
             color: 'blue',
-            width: '300px'
-          }
-        ]
-      }).props
+            width: '300px',
+          },
+        ],
+      }).props,
     ).toMatchObject(expectedProps)
   })
 
@@ -370,7 +370,7 @@ describe('vnode', () => {
       let props3: Data = { class: [{ ccc: true }] }
       let props4: Data = { class: { cccc: true } }
       expect(mergeProps(props1, props2, props3, props4)).toMatchObject({
-        class: 'c cc ccc cccc'
+        class: 'c cc ccc cccc',
       })
     })
 
@@ -379,49 +379,49 @@ describe('vnode', () => {
         style: [
           {
             color: 'red',
-            fontSize: 10
-          }
-        ]
+            fontSize: 10,
+          },
+        ],
       }
       let props2: Data = {
         style: [
           {
             color: 'blue',
-            width: '200px'
+            width: '200px',
           },
           {
             width: '300px',
             height: '300px',
-            fontSize: 30
-          }
-        ]
+            fontSize: 30,
+          },
+        ],
       }
       expect(mergeProps(props1, props2)).toMatchObject({
         style: {
           color: 'blue',
           width: '300px',
           height: '300px',
-          fontSize: 30
-        }
+          fontSize: 30,
+        },
       })
     })
 
     test('style w/ strings', () => {
       let props1: Data = {
-        style: 'width:100px;right:10;top:10'
+        style: 'width:100px;right:10;top:10',
       }
       let props2: Data = {
         style: [
           {
             color: 'blue',
-            width: '200px'
+            width: '200px',
           },
           {
             width: '300px',
             height: '300px',
-            fontSize: 30
-          }
-        ]
+            fontSize: 30,
+          },
+        ],
       }
       expect(mergeProps(props1, props2)).toMatchObject({
         style: {
@@ -430,8 +430,8 @@ describe('vnode', () => {
           height: '300px',
           fontSize: 30,
           right: '10',
-          top: '10'
-        }
+          top: '10',
+        },
       })
     })
 
@@ -444,11 +444,11 @@ describe('vnode', () => {
       let props2: Data = { onClick: clickHandler2, onFocus: focusHandler2 }
       expect(mergeProps(props1, props2)).toMatchObject({
         onClick: [clickHandler1, clickHandler2],
-        onFocus: focusHandler2
+        onFocus: focusHandler2,
       })
       let props3: Data = { onClick: undefined }
       expect(mergeProps(props1, props3)).toMatchObject({
-        onClick: clickHandler1
+        onClick: clickHandler1,
       })
     })
 
@@ -459,7 +459,7 @@ describe('vnode', () => {
       expect(mergeProps(props1, props2, props3)).toMatchObject({
         foo: {},
         bar: ['cc'],
-        baz: { ccc: true }
+        baz: { ccc: true },
       })
     })
   })
@@ -472,7 +472,7 @@ describe('vnode', () => {
         (openBlock(),
         createBlock('div', null, [
           hoist,
-          (vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
+          (vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
     })
@@ -483,7 +483,7 @@ describe('vnode', () => {
         (openBlock(),
         createBlock('div', null, [
           hoist,
-          createVNode('div', null, 'text', PatchFlags.NEED_HYDRATION)
+          createVNode('div', null, 'text', PatchFlags.NEED_HYDRATION),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([])
     })
@@ -500,8 +500,8 @@ describe('vnode', () => {
             (openBlock(),
             createBlock('div', null, [
               hoist,
-              (vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT))
-            ])))
+              (vnode3 = createVNode('div', null, 'text', PatchFlags.TEXT)),
+            ]))),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1, vnode2])
       expect(vnode2.dynamicChildren).toStrictEqual([vnode3])
@@ -514,7 +514,7 @@ describe('vnode', () => {
         (openBlock(),
         createBlock('div', null, [
           hoist,
-          (vnode1 = createVNode({}, null, 'text'))
+          (vnode1 = createVNode({}, null, 'text')),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
     })
@@ -526,7 +526,7 @@ describe('vnode', () => {
         (openBlock(),
         createBlock('div', null, [
           hoist,
-          (vnode1 = createVNode(() => {}, null, 'text'))
+          (vnode1 = createVNode(() => {}, null, 'text')),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
     })
@@ -538,7 +538,7 @@ describe('vnode', () => {
         (openBlock(),
         createBlock('div', null, [
           hoist,
-          (vnode1 = createVNode(() => {}, null, 'text'))
+          (vnode1 = createVNode(() => {}, null, 'text')),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
     })
@@ -558,9 +558,9 @@ describe('vnode', () => {
           default: () => {
             return [
               hoist,
-              (vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT))
+              (vnode1 = createVNode('div', null, 'text', PatchFlags.TEXT)),
             ]
-          }
+          },
         }))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
     })
@@ -578,8 +578,8 @@ describe('vnode', () => {
             (openBlock(true),
             createBlock(Fragment, null, [
               hoist,
-              /*vnode2*/ createVNode(() => {}, null, 'text')
-            ])))
+              /*vnode2*/ createVNode(() => {}, null, 'text'),
+            ]))),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
       expect(vnode1.dynamicChildren).toStrictEqual([])
@@ -595,8 +595,8 @@ describe('vnode', () => {
             (openBlock(),
             createBlock(Fragment, null, [
               hoist,
-              (vnode2 = createVNode(() => {}, null, 'text'))
-            ])))
+              (vnode2 = createVNode(() => {}, null, 'text')),
+            ]))),
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([vnode1])
       expect(vnode1.dynamicChildren).toStrictEqual([vnode2])
@@ -610,7 +610,7 @@ describe('vnode', () => {
           setBlockTracking(-1),
           (vnode1 = (openBlock(), createBlock('div'))),
           setBlockTracking(1),
-          vnode1
+          vnode1,
         ]))
       expect(vnode.dynamicChildren).toStrictEqual([])
     })
@@ -621,7 +621,7 @@ describe('vnode', () => {
         () => {
           throw new Error('slot execution error')
         },
-        { type: {}, appContext: {} } as any
+        { type: {}, appContext: {} } as any,
       )
       const Parent = {
         setup(_: any, { slots }: any) {
@@ -630,7 +630,7 @@ describe('vnode', () => {
               slots.default()
             } catch (e) {}
           }
-        }
+        },
       }
       const vnode =
         (openBlock(), createBlock(Parent, null, { default: slotFn }))
@@ -652,7 +652,7 @@ describe('vnode', () => {
         type: 'div',
         props: { id: 'foo' },
         children: 'hello',
-        shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN
+        shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN,
       })
     })
 
@@ -663,7 +663,7 @@ describe('vnode', () => {
         type: 'div',
         props: { id: 'foo' },
         children: 'hello',
-        shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN
+        shapeFlag: ShapeFlags.ELEMENT | ShapeFlags.TEXT_CHILDREN,
       })
     })
 
@@ -680,7 +680,7 @@ describe('vnode', () => {
         name: 'Root Component',
         render() {
           return h('p') // this will be overwritten by the transform
-        }
+        },
       }
       const root = nodeOps.createElement('div')
       createApp(App).mount(root)
index 15478bfd743109c267646ac94012995d4dc97811..bd3a8a378fec1c2a73557dc3ef555e0623c79d4c 100644 (file)
@@ -1,11 +1,11 @@
 import {
+  type TestElement,
+  TestNodeTypes,
+  type VNode,
+  type VNodeProps,
   h,
-  render,
   nodeOps,
-  VNodeProps,
-  TestElement,
-  TestNodeTypes,
-  VNode
+  render,
 } from '@vue/runtime-test'
 
 describe('renderer: vnode hooks', () => {
@@ -45,17 +45,17 @@ describe('renderer: vnode hooks', () => {
       onVnodeBeforeUpdate: vi.fn(vnode => {
         expect((vnode.el as TestElement).children[0]).toMatchObject({
           type: TestNodeTypes.TEXT,
-          text: 'foo'
+          text: 'foo',
         })
       }),
       onVnodeUpdated: vi.fn(vnode => {
         expect((vnode.el as TestElement).children[0]).toMatchObject({
           type: TestNodeTypes.TEXT,
-          text: 'bar'
+          text: 'bar',
         })
       }),
       onVnodeBeforeUnmount: vi.fn(),
-      onVnodeUnmounted: vi.fn()
+      onVnodeUnmounted: vi.fn(),
     }
 
     assertHooks(hooks, h('div', hooks, 'foo'), h('div', hooks, 'bar'))
@@ -70,29 +70,29 @@ describe('renderer: vnode hooks', () => {
       onVnodeBeforeUpdate: vi.fn(vnode => {
         expect(vnode.el as TestElement).toMatchObject({
           type: TestNodeTypes.TEXT,
-          text: 'foo'
+          text: 'foo',
         })
       }),
       onVnodeUpdated: vi.fn(vnode => {
         expect(vnode.el as TestElement).toMatchObject({
           type: TestNodeTypes.TEXT,
-          text: 'bar'
+          text: 'bar',
         })
       }),
       onVnodeBeforeUnmount: vi.fn(),
-      onVnodeUnmounted: vi.fn()
+      onVnodeUnmounted: vi.fn(),
     }
 
     assertHooks(
       hooks,
       h(Comp, {
         ...hooks,
-        msg: 'foo'
+        msg: 'foo',
       }),
       h(Comp, {
         ...hooks,
-        msg: 'bar'
-      })
+        msg: 'bar',
+      }),
     )
   })
 })
index 535cb83fb5deec904b0c3c46dd7d9ba6057af8cd..4c6e4bad11b6ff2d8294bb434a1b4f7448257fbe 100644 (file)
@@ -1,18 +1,18 @@
 import {
-  Component,
-  ConcreteComponent,
+  type Component,
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type ConcreteComponent,
   currentInstance,
-  ComponentInternalInstance,
   isInSSRComponentSetup,
-  ComponentOptions
 } from './component'
 import { isFunction, isObject } from '@vue/shared'
-import { ComponentPublicInstance } from './componentPublicInstance'
-import { createVNode, VNode } from './vnode'
+import type { ComponentPublicInstance } from './componentPublicInstance'
+import { type VNode, createVNode } from './vnode'
 import { defineComponent } from './apiDefineComponent'
 import { warn } from './warning'
 import { ref } from '@vue/reactivity'
-import { handleError, ErrorCodes } from './errorHandling'
+import { ErrorCodes, handleError } from './errorHandling'
 import { isKeepAlive } from './components/KeepAlive'
 import { queueJob } from './scheduler'
 
@@ -33,7 +33,7 @@ export interface AsyncComponentOptions<T = any> {
     error: Error,
     retry: () => void,
     fail: () => void,
-    attempts: number
+    attempts: number,
   ) => any
 }
 
@@ -42,7 +42,7 @@ export const isAsyncWrapper = (i: ComponentInternalInstance | VNode): boolean =>
 
 /*! #__NO_SIDE_EFFECTS__ */
 export function defineAsyncComponent<
-  T extends Component = { new (): ComponentPublicInstance }
+  T extends Component = { new (): ComponentPublicInstance },
 >(source: AsyncComponentLoader<T> | AsyncComponentOptions<T>): T {
   if (isFunction(source)) {
     source = { loader: source }
@@ -55,7 +55,7 @@ export function defineAsyncComponent<
     delay = 200,
     timeout, // undefined = never times out
     suspensible = true,
-    onError: userOnError
+    onError: userOnError,
   } = source
 
   let pendingRequest: Promise<ConcreteComponent> | null = null
@@ -93,7 +93,7 @@ export function defineAsyncComponent<
             if (__DEV__ && !comp) {
               warn(
                 `Async component loader resolved to undefined. ` +
-                  `If you are using retry(), make sure to return its return value.`
+                  `If you are using retry(), make sure to return its return value.`,
               )
             }
             // interop module default
@@ -135,7 +135,7 @@ export function defineAsyncComponent<
           err,
           instance,
           ErrorCodes.ASYNC_COMPONENT_LOADER,
-          !errorComponent /* do not throw in dev if user provided error component */
+          !errorComponent /* do not throw in dev if user provided error component */,
         )
       }
 
@@ -153,7 +153,7 @@ export function defineAsyncComponent<
             return () =>
               errorComponent
                 ? createVNode(errorComponent as ConcreteComponent, {
-                    error: err
+                    error: err,
                   })
                 : null
           })
@@ -173,7 +173,7 @@ export function defineAsyncComponent<
         setTimeout(() => {
           if (!loaded.value && !error.value) {
             const err = new Error(
-              `Async component timed out after ${timeout}ms.`
+              `Async component timed out after ${timeout}ms.`,
             )
             onError(err)
             error.value = err
@@ -201,19 +201,19 @@ export function defineAsyncComponent<
           return createInnerComp(resolvedComp, instance)
         } else if (error.value && errorComponent) {
           return createVNode(errorComponent, {
-            error: error.value
+            error: error.value,
           })
         } else if (loadingComponent && !delayed.value) {
           return createVNode(loadingComponent)
         }
       }
-    }
+    },
   }) as T
 }
 
 function createInnerComp(
   comp: ConcreteComponent,
-  parent: ComponentInternalInstance
+  parent: ComponentInternalInstance,
 ) {
   const { ref, props, children, ce } = parent.vnode
   const vnode = createVNode(comp, props, children)
index 1cd9c2ec21815e5ff1d4313857e0bbef484d2c5b..97db0da453cd63bcb48979c49e81f6067c9ad864 100644 (file)
@@ -3,8 +3,8 @@ import { isInSSRComponentSetup } from './component'
 
 export const computed: typeof _computed = (
   getterOrOptions: any,
-  debugOptions?: any
+  debugOptions?: any,
 ) => {
-  // @ts-ignore
+  // @ts-expect-error
   return _computed(getterOrOptions, debugOptions, isInSSRComponentSetup)
 }
index 0afae35f0d1ce2e586b73b2cb6e1c9c83ed81c7f..b99d06e01ff5465b311869ae53e6db74345df6e1 100644 (file)
@@ -1,33 +1,33 @@
 import {
-  ConcreteComponent,
-  Data,
+  type Component,
+  type ComponentInternalInstance,
+  type ConcreteComponent,
+  type Data,
+  getExposeProxy,
   validateComponentName,
-  Component,
-  ComponentInternalInstance,
-  getExposeProxy
 } from './component'
-import {
+import type {
   ComponentOptions,
   MergedComponentOptions,
-  RuntimeCompilerOptions
+  RuntimeCompilerOptions,
 } from './componentOptions'
-import {
+import type {
   ComponentCustomProperties,
-  ComponentPublicInstance
+  ComponentPublicInstance,
 } from './componentPublicInstance'
-import { Directive, validateDirectiveName } from './directives'
-import { ElementNamespace, RootRenderFunction } from './renderer'
-import { InjectionKey } from './apiInject'
+import { type Directive, validateDirectiveName } from './directives'
+import type { ElementNamespace, RootRenderFunction } from './renderer'
+import type { InjectionKey } from './apiInject'
 import { warn } from './warning'
-import { createVNode, cloneVNode, VNode } from './vnode'
-import { RootHydrateFunction } from './hydration'
+import { type VNode, cloneVNode, createVNode } from './vnode'
+import type { RootHydrateFunction } from './hydration'
 import { devtoolsInitApp, devtoolsUnmountApp } from './devtools'
-import { isFunction, NO, isObject, extend } from '@vue/shared'
+import { NO, extend, isFunction, isObject } from '@vue/shared'
 import { version } from '.'
 import { installAppCompatProperties } from './compat/global'
-import { NormalizedPropsOptions } from './componentProps'
-import { ObjectEmitsOptions } from './componentEmits'
-import { DefineComponent } from './apiDefineComponent'
+import type { NormalizedPropsOptions } from './componentProps'
+import type { ObjectEmitsOptions } from './componentEmits'
+import type { DefineComponent } from './apiDefineComponent'
 
 export interface App<HostElement = any> {
   version: string
@@ -47,7 +47,7 @@ export interface App<HostElement = any> {
   mount(
     rootContainer: HostElement | string,
     isHydrate?: boolean,
-    namespace?: boolean | ElementNamespace
+    namespace?: boolean | ElementNamespace,
   ): ComponentPublicInstance
   unmount(): void
   provide<T>(key: InjectionKey<T> | string, value: T): this
@@ -92,12 +92,12 @@ export interface AppConfig {
   errorHandler?: (
     err: unknown,
     instance: ComponentPublicInstance | null,
-    info: string
+    info: string,
   ) => void
   warnHandler?: (
     msg: string,
     instance: ComponentPublicInstance | null,
-    trace: string
+    trace: string,
   ) => void
 
   /**
@@ -173,7 +173,7 @@ export function createAppContext(): AppContext {
       optionMergeStrategies: {},
       errorHandler: undefined,
       warnHandler: undefined,
-      compilerOptions: {}
+      compilerOptions: {},
     },
     mixins: [],
     components: {},
@@ -181,20 +181,20 @@ export function createAppContext(): AppContext {
     provides: Object.create(null),
     optionsCache: new WeakMap(),
     propsCache: new WeakMap(),
-    emitsCache: new WeakMap()
+    emitsCache: new WeakMap(),
   }
 }
 
 export type CreateAppFunction<HostElement> = (
   rootComponent: Component,
-  rootProps?: Data | null
+  rootProps?: Data | null,
 ) => App<HostElement>
 
 let uid = 0
 
 export function createAppAPI<HostElement>(
   render: RootRenderFunction<HostElement>,
-  hydrate?: RootHydrateFunction
+  hydrate?: RootHydrateFunction,
 ): CreateAppFunction<HostElement> {
   return function createApp(rootComponent, rootProps = null) {
     if (!isFunction(rootComponent)) {
@@ -228,7 +228,7 @@ export function createAppAPI<HostElement>(
       set config(v) {
         if (__DEV__) {
           warn(
-            `app.config cannot be replaced. Modify individual options instead.`
+            `app.config cannot be replaced. Modify individual options instead.`,
           )
         }
       },
@@ -245,7 +245,7 @@ export function createAppAPI<HostElement>(
         } else if (__DEV__) {
           warn(
             `A plugin must either be a function or an object with an "install" ` +
-              `function.`
+              `function.`,
           )
         }
         return app
@@ -258,7 +258,7 @@ export function createAppAPI<HostElement>(
           } else if (__DEV__) {
             warn(
               'Mixin has already been applied to target app' +
-                (mixin.name ? `: ${mixin.name}` : '')
+                (mixin.name ? `: ${mixin.name}` : ''),
             )
           }
         } else if (__DEV__) {
@@ -299,7 +299,7 @@ export function createAppAPI<HostElement>(
       mount(
         rootContainer: HostElement,
         isHydrate?: boolean,
-        namespace?: boolean | ElementNamespace
+        namespace?: boolean | ElementNamespace,
       ): any {
         if (!isMounted) {
           // #5571
@@ -307,7 +307,7 @@ export function createAppAPI<HostElement>(
             warn(
               `There is already an app instance mounted on the host container.\n` +
                 ` If you want to mount another app on the same host container,` +
-                ` you need to unmount the previous app by calling \`app.unmount()\` first.`
+                ` you need to unmount the previous app by calling \`app.unmount()\` first.`,
             )
           }
           const vnode = createVNode(rootComponent, rootProps)
@@ -329,7 +329,7 @@ export function createAppAPI<HostElement>(
               render(
                 cloneVNode(vnode),
                 rootContainer,
-                namespace as ElementNamespace
+                namespace as ElementNamespace,
               )
             }
           }
@@ -355,7 +355,7 @@ export function createAppAPI<HostElement>(
             `App has already been mounted.\n` +
               `If you want to remount the same app, move your app creation logic ` +
               `into a factory function and create fresh app instances for each ` +
-              `mount - e.g. \`const createMyApp = () => createApp(App)\``
+              `mount - e.g. \`const createMyApp = () => createApp(App)\``,
           )
         }
       },
@@ -377,7 +377,7 @@ export function createAppAPI<HostElement>(
         if (__DEV__ && (key as string | symbol) in context.provides) {
           warn(
             `App already provides property with key "${String(key)}". ` +
-              `It will be overwritten with the new value.`
+              `It will be overwritten with the new value.`,
           )
         }
 
@@ -393,7 +393,7 @@ export function createAppAPI<HostElement>(
         } finally {
           currentApp = null
         }
-      }
+      },
     })
 
     if (__COMPAT__) {
index 092f679e9664fa4e9c4e2a804f16de5f89fe6443..47bcf9f2acb5e8a0f52acb1d7be4ef636eaa2872 100644 (file)
@@ -1,34 +1,34 @@
-import {
-  ComputedOptions,
-  MethodOptions,
-  ComponentOptionsWithoutProps,
+import type {
+  ComponentInjectOptions,
+  ComponentOptions,
+  ComponentOptionsBase,
+  ComponentOptionsMixin,
   ComponentOptionsWithArrayProps,
   ComponentOptionsWithObjectProps,
-  ComponentOptionsMixin,
+  ComponentOptionsWithoutProps,
+  ComputedOptions,
+  MethodOptions,
   RenderFunction,
-  ComponentOptionsBase,
-  ComponentInjectOptions,
-  ComponentOptions
 } from './componentOptions'
-import {
-  SetupContext,
+import type {
   AllowedComponentProps,
-  ComponentCustomProps
+  ComponentCustomProps,
+  SetupContext,
 } from './component'
-import {
-  ExtractPropTypes,
+import type {
+  ComponentObjectPropsOptions,
   ComponentPropsOptions,
   ExtractDefaultPropTypes,
-  ComponentObjectPropsOptions
+  ExtractPropTypes,
 } from './componentProps'
-import { EmitsOptions, EmitsToProps } from './componentEmits'
+import type { EmitsOptions, EmitsToProps } from './componentEmits'
 import { extend, isFunction } from '@vue/shared'
-import { VNodeProps } from './vnode'
-import {
+import type { VNodeProps } from './vnode'
+import type {
+  ComponentPublicInstanceConstructor,
   CreateComponentPublicInstance,
-  ComponentPublicInstanceConstructor
 } from './componentPublicInstance'
-import { SlotsType } from './componentSlots'
+import type { SlotsType } from './componentSlots'
 
 export type PublicProps = VNodeProps &
   AllowedComponentProps &
@@ -54,7 +54,7 @@ export type DefineComponent<
   PP = PublicProps,
   Props = ResolveProps<PropsOrPropOptions, E>,
   Defaults = ExtractDefaultPropTypes<PropsOrPropOptions>,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 > = ComponentPublicInstanceConstructor<
   CreateComponentPublicInstance<
     Props,
@@ -100,33 +100,33 @@ export function defineComponent<
   Props extends Record<string, any>,
   E extends EmitsOptions = {},
   EE extends string = string,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 >(
   setup: (
     props: Props,
-    ctx: SetupContext<E, S>
+    ctx: SetupContext<E, S>,
   ) => RenderFunction | Promise<RenderFunction>,
   options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
     props?: (keyof Props)[]
     emits?: E | EE[]
     slots?: S
-  }
+  },
 ): (props: Props & EmitsToProps<E>) => any
 export function defineComponent<
   Props extends Record<string, any>,
   E extends EmitsOptions = {},
   EE extends string = string,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 >(
   setup: (
     props: Props,
-    ctx: SetupContext<E, S>
+    ctx: SetupContext<E, S>,
   ) => RenderFunction | Promise<RenderFunction>,
   options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
     props?: ComponentObjectPropsOptions<Props>
     emits?: E | EE[]
     slots?: S
-  }
+  },
 ): (props: Props & EmitsToProps<E>) => any
 
 // overload 2: object format with no props
@@ -144,7 +144,7 @@ export function defineComponent<
   EE extends string = string,
   S extends SlotsType = {},
   I extends ComponentInjectOptions = {},
-  II extends string = string
+  II extends string = string,
 >(
   options: ComponentOptionsWithoutProps<
     Props,
@@ -159,7 +159,7 @@ export function defineComponent<
     I,
     II,
     S
-  >
+  >,
 ): DefineComponent<
   Props,
   RawBindings,
@@ -192,7 +192,7 @@ export function defineComponent<
   S extends SlotsType = {},
   I extends ComponentInjectOptions = {},
   II extends string = string,
-  Props = Readonly<{ [key in PropNames]?: any }>
+  Props = Readonly<{ [key in PropNames]?: any }>,
 >(
   options: ComponentOptionsWithArrayProps<
     PropNames,
@@ -207,7 +207,7 @@ export function defineComponent<
     I,
     II,
     S
-  >
+  >,
 ): DefineComponent<
   Props,
   RawBindings,
@@ -240,7 +240,7 @@ export function defineComponent<
   EE extends string = string,
   S extends SlotsType = {},
   I extends ComponentInjectOptions = {},
-  II extends string = string
+  II extends string = string,
 >(
   options: ComponentOptionsWithObjectProps<
     PropsOptions,
@@ -255,7 +255,7 @@ export function defineComponent<
     I,
     II,
     S
-  >
+  >,
 ): DefineComponent<
   PropsOptions,
   RawBindings,
@@ -276,7 +276,7 @@ export function defineComponent<
 /*! #__NO_SIDE_EFFECTS__ */
 export function defineComponent(
   options: unknown,
-  extraOptions?: ComponentOptions
+  extraOptions?: ComponentOptions,
 ) {
   return isFunction(options)
     ? // #8326: extend call and options.name access are considered side-effects
index bbf925102d83016511437519a3e30cdf8df8866d..f15983604bb3c2b78607f6cbba27a906a0331023 100644 (file)
@@ -8,7 +8,7 @@ export interface InjectionKey<T> extends Symbol {}
 
 export function provide<T, K = InjectionKey<T> | string | number>(
   key: K,
-  value: K extends InjectionKey<infer V> ? V : T
+  value: K extends InjectionKey<infer V> ? V : T,
 ) {
   if (!currentInstance) {
     if (__DEV__) {
@@ -35,17 +35,17 @@ export function inject<T>(key: InjectionKey<T> | string): T | undefined
 export function inject<T>(
   key: InjectionKey<T> | string,
   defaultValue: T,
-  treatDefaultAsFactory?: false
+  treatDefaultAsFactory?: false,
 ): T
 export function inject<T>(
   key: InjectionKey<T> | string,
   defaultValue: T | (() => T),
-  treatDefaultAsFactory: true
+  treatDefaultAsFactory: true,
 ): T
 export function inject(
   key: InjectionKey<any> | string,
   defaultValue?: unknown,
-  treatDefaultAsFactory = false
+  treatDefaultAsFactory = false,
 ) {
   // fallback to `currentRenderingInstance` so that this can be called in
   // a functional component
index 0cd88846354a5819d4161183c940b50af6179e77..9de0887250d1e8c57f8db12577b58699104adccb 100644 (file)
@@ -1,15 +1,19 @@
 import {
-  ComponentInternalInstance,
+  type ComponentInternalInstance,
   currentInstance,
   isInSSRComponentSetup,
   setCurrentInstance,
-  unsetCurrentInstance
+  unsetCurrentInstance,
 } from './component'
-import { ComponentPublicInstance } from './componentPublicInstance'
-import { callWithAsyncErrorHandling, ErrorTypeStrings } from './errorHandling'
+import type { ComponentPublicInstance } from './componentPublicInstance'
+import { ErrorTypeStrings, callWithAsyncErrorHandling } from './errorHandling'
 import { warn } from './warning'
 import { toHandlerKey } from '@vue/shared'
-import { DebuggerEvent, pauseTracking, resetTracking } from '@vue/reactivity'
+import {
+  type DebuggerEvent,
+  pauseTracking,
+  resetTracking,
+} from '@vue/reactivity'
 import { LifecycleHooks } from './enums'
 
 export { onActivated, onDeactivated } from './components/KeepAlive'
@@ -18,7 +22,7 @@ export function injectHook(
   type: LifecycleHooks,
   hook: Function & { __weh?: Function },
   target: ComponentInternalInstance | null = currentInstance,
-  prepend: boolean = false
+  prepend: boolean = false,
 ): Function | undefined {
   if (target) {
     const hooks = target[type] || (target[type] = [])
@@ -58,7 +62,7 @@ export function injectHook(
         (__FEATURE_SUSPENSE__
           ? ` If you are using async setup(), make sure to register lifecycle ` +
             `hooks before the first await statement.`
-          : ``)
+          : ``),
     )
   }
 }
@@ -80,21 +84,21 @@ export const onServerPrefetch = createHook(LifecycleHooks.SERVER_PREFETCH)
 
 export type DebuggerHook = (e: DebuggerEvent) => void
 export const onRenderTriggered = createHook<DebuggerHook>(
-  LifecycleHooks.RENDER_TRIGGERED
+  LifecycleHooks.RENDER_TRIGGERED,
 )
 export const onRenderTracked = createHook<DebuggerHook>(
-  LifecycleHooks.RENDER_TRACKED
+  LifecycleHooks.RENDER_TRACKED,
 )
 
 export type ErrorCapturedHook<TError = unknown> = (
   err: TError,
   instance: ComponentPublicInstance | null,
-  info: string
+  info: string,
 ) => boolean | void
 
 export function onErrorCaptured<TError = Error>(
   hook: ErrorCapturedHook<TError>,
-  target: ComponentInternalInstance | null = currentInstance
+  target: ComponentInternalInstance | null = currentInstance,
 ) {
   injectHook(LifecycleHooks.ERROR_CAPTURED, hook, target)
 }
index 4f8f3853300da37b9e324ae9229f7c3a6c72d6f9..9440e8a62df0303a16df20bb2fc0104c760b49a4 100644 (file)
@@ -1,37 +1,37 @@
 import {
+  type LooseRequired,
+  type Prettify,
+  type UnionToIntersection,
+  extend,
+  hasChanged,
   isArray,
-  isPromise,
   isFunction,
-  Prettify,
-  UnionToIntersection,
-  extend,
-  LooseRequired,
-  hasChanged
+  isPromise,
 } from '@vue/shared'
 import {
+  type SetupContext,
+  createSetupContext,
   getCurrentInstance,
   setCurrentInstance,
-  SetupContext,
-  createSetupContext,
-  unsetCurrentInstance
+  unsetCurrentInstance,
 } from './component'
-import { EmitFn, EmitsOptions, ObjectEmitsOptions } from './componentEmits'
-import {
+import type { EmitFn, EmitsOptions, ObjectEmitsOptions } from './componentEmits'
+import type {
   ComponentOptionsMixin,
   ComponentOptionsWithoutProps,
   ComputedOptions,
-  MethodOptions
+  MethodOptions,
 } from './componentOptions'
-import {
-  ComponentPropsOptions,
+import type {
   ComponentObjectPropsOptions,
+  ComponentPropsOptions,
   ExtractPropTypes,
   NormalizedProps,
-  PropOptions
+  PropOptions,
 } from './componentProps'
 import { warn } from './warning'
-import { SlotsType, StrictUnwrapSlotsType } from './componentSlots'
-import { Ref, customRef, ref } from '@vue/reactivity'
+import type { SlotsType, StrictUnwrapSlotsType } from './componentSlots'
+import { type Ref, customRef, ref } from '@vue/reactivity'
 import { watchSyncEffect } from '.'
 
 // dev only
@@ -39,7 +39,7 @@ const warnRuntimeUsage = (method: string) =>
   warn(
     `${method}() is a compiler-hint helper that is only usable inside ` +
       `<script setup> of a single file component. Its arguments should be ` +
-      `compiled away and passing it at runtime has no effect.`
+      `compiled away and passing it at runtime has no effect.`,
   )
 
 /**
@@ -76,11 +76,11 @@ const warnRuntimeUsage = (method: string) =>
  */
 // overload 1: runtime props w/ array
 export function defineProps<PropNames extends string = string>(
-  props: PropNames[]
+  props: PropNames[],
 ): Prettify<Readonly<{ [key in PropNames]?: any }>>
 // overload 2: runtime props w/ object
 export function defineProps<
-  PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions
+  PP extends ComponentObjectPropsOptions = ComponentObjectPropsOptions,
 >(props: PP): Prettify<Readonly<ExtractPropTypes<PP>>>
 // overload 3: typed-based declaration
 export function defineProps<TypeProps>(): DefineProps<
@@ -133,13 +133,13 @@ type BooleanKey<T, K extends keyof T = keyof T> = K extends any
  */
 // overload 1: runtime emits w/ array
 export function defineEmits<EE extends string = string>(
-  emitOptions: EE[]
+  emitOptions: EE[],
 ): EmitFn<EE[]>
 export function defineEmits<E extends EmitsOptions = EmitsOptions>(
-  emitOptions: E
+  emitOptions: E,
 ): EmitFn<E>
 export function defineEmits<
-  T extends ((...args: any[]) => any) | Record<string, any[]>
+  T extends ((...args: any[]) => any) | Record<string, any[]>,
 >(): T extends (...args: any[]) => any ? T : ShortEmits<T>
 // implementation
 export function defineEmits() {
@@ -172,7 +172,7 @@ type ShortEmits<T extends Record<string, any>> = UnionToIntersection<
  * @see {@link https://vuejs.org/api/sfc-script-setup.html#defineexpose}
  */
 export function defineExpose<
-  Exposed extends Record<string, any> = Record<string, any>
+  Exposed extends Record<string, any> = Record<string, any>,
 >(exposed?: Exposed) {
   if (__DEV__) {
     warnRuntimeUsage(`defineExpose`)
@@ -192,7 +192,7 @@ export function defineOptions<
   C extends ComputedOptions = {},
   M extends MethodOptions = {},
   Mixin extends ComponentOptionsMixin = ComponentOptionsMixin,
-  Extends extends ComponentOptionsMixin = ComponentOptionsMixin
+  Extends extends ComponentOptionsMixin = ComponentOptionsMixin,
 >(
   options?: ComponentOptionsWithoutProps<
     {},
@@ -202,7 +202,7 @@ export function defineOptions<
     M,
     Mixin,
     Extends
-  > & { emits?: undefined; expose?: undefined; slots?: undefined }
+  > & { emits?: undefined; expose?: undefined; slots?: undefined },
 ): void {
   if (__DEV__) {
     warnRuntimeUsage(`defineOptions`)
@@ -210,7 +210,7 @@ export function defineOptions<
 }
 
 export function defineSlots<
-  S extends Record<string, any> = Record<string, any>
+  S extends Record<string, any> = Record<string, any>,
 >(): StrictUnwrapSlotsType<SlotsType<S>> {
   if (__DEV__) {
     warnRuntimeUsage(`defineSlots`)
@@ -252,23 +252,23 @@ export function defineSlots<
  * ```
  */
 export function defineModel<T>(
-  options: { required: true } & PropOptions<T>
+  options: { required: true } & PropOptions<T>,
 ): Ref<T>
 export function defineModel<T>(
-  options: { default: any } & PropOptions<T>
+  options: { default: any } & PropOptions<T>,
 ): Ref<T>
 export function defineModel<T>(options?: PropOptions<T>): Ref<T | undefined>
 export function defineModel<T>(
   name: string,
-  options: { required: true } & PropOptions<T>
+  options: { required: true } & PropOptions<T>,
 ): Ref<T>
 export function defineModel<T>(
   name: string,
-  options: { default: any } & PropOptions<T>
+  options: { default: any } & PropOptions<T>,
 ): Ref<T>
 export function defineModel<T>(
   name: string,
-  options?: PropOptions<T>
+  options?: PropOptions<T>,
 ): Ref<T | undefined>
 export function defineModel(): any {
   if (__DEV__) {
@@ -291,7 +291,7 @@ type InferDefault<P, T> =
 type PropsWithDefaults<
   T,
   Defaults extends InferDefaults<T>,
-  BKeys extends keyof T
+  BKeys extends keyof T,
 > = Readonly<Omit<T, keyof Defaults>> & {
   readonly [K in keyof Defaults]-?: K extends keyof T
     ? Defaults[K] extends undefined
@@ -329,10 +329,10 @@ type PropsWithDefaults<
 export function withDefaults<
   T,
   BKeys extends keyof T,
-  Defaults extends InferDefaults<T>
+  Defaults extends InferDefaults<T>,
 >(
   props: DefineProps<T, BKeys>,
-  defaults: Defaults
+  defaults: Defaults,
 ): PropsWithDefaults<T, Defaults, BKeys> {
   if (__DEV__) {
     warnRuntimeUsage(`withDefaults`)
@@ -350,7 +350,7 @@ export function useAttrs(): SetupContext['attrs'] {
 
 export function useModel<T extends Record<string, any>, K extends keyof T>(
   props: T,
-  name: K
+  name: K,
 ): Ref<T[K]>
 export function useModel(props: Record<string, any>, name: string): Ref {
   const i = getCurrentInstance()!
@@ -385,7 +385,7 @@ export function useModel(props: Record<string, any>, name: string): Ref {
           trigger()
         }
         i.emit(`update:${name}`, value)
-      }
+      },
     }
   })
 }
@@ -402,12 +402,12 @@ function getContext(): SetupContext {
  * @internal
  */
 export function normalizePropsOrEmits(
-  props: ComponentPropsOptions | EmitsOptions
+  props: ComponentPropsOptions | EmitsOptions,
 ) {
   return isArray(props)
     ? props.reduce(
         (normalized, p) => ((normalized[p] = null), normalized),
-        {} as ComponentObjectPropsOptions | ObjectEmitsOptions
+        {} as ComponentObjectPropsOptions | ObjectEmitsOptions,
       )
     : props
 }
@@ -419,7 +419,7 @@ export function normalizePropsOrEmits(
  */
 export function mergeDefaults(
   raw: ComponentPropsOptions,
-  defaults: Record<string, any>
+  defaults: Record<string, any>,
 ): ComponentObjectPropsOptions {
   const props = normalizePropsOrEmits(raw)
   for (const key in defaults) {
@@ -450,7 +450,7 @@ export function mergeDefaults(
  */
 export function mergeModels(
   a: ComponentPropsOptions | EmitsOptions,
-  b: ComponentPropsOptions | EmitsOptions
+  b: ComponentPropsOptions | EmitsOptions,
 ) {
   if (!a || !b) return a || b
   if (isArray(a) && isArray(b)) return a.concat(b)
@@ -464,14 +464,14 @@ export function mergeModels(
  */
 export function createPropsRestProxy(
   props: any,
-  excludedKeys: string[]
+  excludedKeys: string[],
 ): Record<string, any> {
   const ret: Record<string, any> = {}
   for (const key in props) {
     if (!excludedKeys.includes(key)) {
       Object.defineProperty(ret, key, {
         enumerable: true,
-        get: () => props[key]
+        get: () => props[key],
       })
     }
   }
@@ -501,7 +501,7 @@ export function withAsyncContext(getAwaitable: () => any) {
   if (__DEV__ && !ctx) {
     warn(
       `withAsyncContext called without active current instance. ` +
-        `This is likely a bug.`
+        `This is likely a bug.`,
     )
   }
   let awaitable = getAwaitable()
index 5d5b8713f8c61be6b9477d6c1276fb79bbdb9e33..ecd750117db1928d23d14211a6165fe55783d43f 100644 (file)
@@ -1,47 +1,47 @@
 import {
-  isRef,
-  isShallow,
-  Ref,
-  ComputedRef,
+  type ComputedRef,
+  type DebuggerOptions,
+  type EffectScheduler,
   ReactiveEffect,
-  isReactive,
   ReactiveFlags,
-  EffectScheduler,
-  DebuggerOptions,
-  getCurrentScope
+  type Ref,
+  getCurrentScope,
+  isReactive,
+  isRef,
+  isShallow,
 } from '@vue/reactivity'
-import { SchedulerJob, queueJob } from './scheduler'
+import { type SchedulerJob, queueJob } from './scheduler'
 import {
   EMPTY_OBJ,
-  isObject,
+  NOOP,
+  extend,
+  hasChanged,
   isArray,
   isFunction,
-  isString,
-  hasChanged,
-  NOOP,
-  remove,
   isMap,
-  isSet,
+  isObject,
   isPlainObject,
-  extend
+  isSet,
+  isString,
+  remove,
 } from '@vue/shared'
 import {
+  type ComponentInternalInstance,
   currentInstance,
-  ComponentInternalInstance,
   isInSSRComponentSetup,
   setCurrentInstance,
-  unsetCurrentInstance
+  unsetCurrentInstance,
 } from './component'
 import {
   ErrorCodes,
+  callWithAsyncErrorHandling,
   callWithErrorHandling,
-  callWithAsyncErrorHandling
 } from './errorHandling'
 import { queuePostRenderEffect } from './renderer'
 import { warn } from './warning'
 import { DeprecationTypes } from './compat/compatConfig'
 import { checkCompatEnabled, isCompatEnabled } from './compat/compatConfig'
-import { ObjectWatchOptionItem } from './componentOptions'
+import type { ObjectWatchOptionItem } from './componentOptions'
 import { useSSRContext } from '@vue/runtime-core'
 
 export type WatchEffect = (onCleanup: OnCleanup) => void
@@ -51,7 +51,7 @@ export type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
 export type WatchCallback<V = any, OV = any> = (
   value: V,
   oldValue: OV,
-  onCleanup: OnCleanup
+  onCleanup: OnCleanup,
 ) => any
 
 type MapSources<T, Immediate> = {
@@ -83,30 +83,30 @@ export type WatchStopHandle = () => void
 // Simple effect.
 export function watchEffect(
   effect: WatchEffect,
-  options?: WatchOptionsBase
+  options?: WatchOptionsBase,
 ): WatchStopHandle {
   return doWatch(effect, null, options)
 }
 
 export function watchPostEffect(
   effect: WatchEffect,
-  options?: DebuggerOptions
+  options?: DebuggerOptions,
 ) {
   return doWatch(
     effect,
     null,
-    __DEV__ ? extend({}, options as any, { flush: 'post' }) : { flush: 'post' }
+    __DEV__ ? extend({}, options as any, { flush: 'post' }) : { flush: 'post' },
   )
 }
 
 export function watchSyncEffect(
   effect: WatchEffect,
-  options?: DebuggerOptions
+  options?: DebuggerOptions,
 ) {
   return doWatch(
     effect,
     null,
-    __DEV__ ? extend({}, options as any, { flush: 'sync' }) : { flush: 'sync' }
+    __DEV__ ? extend({}, options as any, { flush: 'sync' }) : { flush: 'sync' },
   )
 }
 
@@ -118,11 +118,11 @@ type MultiWatchSources = (WatchSource<unknown> | object)[]
 // overload: array of multiple sources + cb
 export function watch<
   T extends MultiWatchSources,
-  Immediate extends Readonly<boolean> = false
+  Immediate extends Readonly<boolean> = false,
 >(
   sources: [...T],
   cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>,
-  options?: WatchOptions<Immediate>
+  options?: WatchOptions<Immediate>,
 ): WatchStopHandle
 
 // overload: multiple sources w/ `as const`
@@ -130,41 +130,41 @@ export function watch<
 // somehow [...T] breaks when the type is readonly
 export function watch<
   T extends Readonly<MultiWatchSources>,
-  Immediate extends Readonly<boolean> = false
+  Immediate extends Readonly<boolean> = false,
 >(
   source: T,
   cb: WatchCallback<MapSources<T, false>, MapSources<T, Immediate>>,
-  options?: WatchOptions<Immediate>
+  options?: WatchOptions<Immediate>,
 ): WatchStopHandle
 
 // overload: single source + cb
 export function watch<T, Immediate extends Readonly<boolean> = false>(
   source: WatchSource<T>,
   cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
-  options?: WatchOptions<Immediate>
+  options?: WatchOptions<Immediate>,
 ): WatchStopHandle
 
 // overload: watching reactive object w/ cb
 export function watch<
   T extends object,
-  Immediate extends Readonly<boolean> = false
+  Immediate extends Readonly<boolean> = false,
 >(
   source: T,
   cb: WatchCallback<T, Immediate extends true ? T | undefined : T>,
-  options?: WatchOptions<Immediate>
+  options?: WatchOptions<Immediate>,
 ): WatchStopHandle
 
 // implementation
 export function watch<T = any, Immediate extends Readonly<boolean> = false>(
   source: T | WatchSource<T>,
   cb: any,
-  options?: WatchOptions<Immediate>
+  options?: WatchOptions<Immediate>,
 ): WatchStopHandle {
   if (__DEV__ && !isFunction(cb)) {
     warn(
       `\`watch(fn, options?)\` signature has been moved to a separate API. ` +
         `Use \`watchEffect(fn, options?)\` instead. \`watch\` now only ` +
-        `supports \`watch(source, cb, options?) signature.`
+        `supports \`watch(source, cb, options?) signature.`,
     )
   }
   return doWatch(source as any, cb, options)
@@ -173,7 +173,14 @@ export function watch<T = any, Immediate extends Readonly<boolean> = false>(
 function doWatch(
   source: WatchSource | WatchSource[] | WatchEffect | object,
   cb: WatchCallback | null,
-  { immediate, deep, flush, once, onTrack, onTrigger }: WatchOptions = EMPTY_OBJ
+  {
+    immediate,
+    deep,
+    flush,
+    once,
+    onTrack,
+    onTrigger,
+  }: WatchOptions = EMPTY_OBJ,
 ): WatchStopHandle {
   if (cb && once) {
     const _cb = cb
@@ -187,19 +194,19 @@ function doWatch(
     if (immediate !== undefined) {
       warn(
         `watch() "immediate" option is only respected when using the ` +
-          `watch(source, callback, options?) signature.`
+          `watch(source, callback, options?) signature.`,
       )
     }
     if (deep !== undefined) {
       warn(
         `watch() "deep" option is only respected when using the ` +
-          `watch(source, callback, options?) signature.`
+          `watch(source, callback, options?) signature.`,
       )
     }
     if (once !== undefined) {
       warn(
         `watch() "once" option is only respected when using the ` +
-          `watch(source, callback, options?) signature.`
+          `watch(source, callback, options?) signature.`,
       )
     }
   }
@@ -209,7 +216,7 @@ function doWatch(
       `Invalid watch source: `,
       s,
       `A watch source can only be a getter/effect function, a ref, ` +
-        `a reactive object, or an array of these types.`
+        `a reactive object, or an array of these types.`,
     )
   }
 
@@ -259,7 +266,7 @@ function doWatch(
           source,
           instance,
           ErrorCodes.WATCH_CALLBACK,
-          [onCleanup]
+          [onCleanup],
         )
       }
     }
@@ -308,7 +315,7 @@ function doWatch(
       callWithAsyncErrorHandling(cb, instance, ErrorCodes.WATCH_CALLBACK, [
         getter(),
         isMultiSource ? [] : undefined,
-        onCleanup
+        onCleanup,
       ])
     }
     if (flush === 'sync') {
@@ -351,7 +358,7 @@ function doWatch(
             : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE
               ? []
               : oldValue,
-          onCleanup
+          onCleanup,
         ])
         oldValue = newValue
       }
@@ -401,7 +408,7 @@ function doWatch(
   } else if (flush === 'post') {
     queuePostRenderEffect(
       effect.run.bind(effect),
-      instance && instance.suspense
+      instance && instance.suspense,
     )
   } else {
     effect.run()
@@ -416,7 +423,7 @@ export function instanceWatch(
   this: ComponentInternalInstance,
   source: string | Function,
   value: WatchCallback | ObjectWatchOptionItem,
-  options?: WatchOptions
+  options?: WatchOptions,
 ): WatchStopHandle {
   const publicThis = this.proxy as any
   const getter = isString(source)
index e2fc730e8a11fcd4ba6c396874cdeeb2ef0e90fb..6c374dc3ce9e82ae647de996affe30d40f8ace54 100644 (file)
@@ -1,10 +1,10 @@
 import { isOn } from '@vue/shared'
-import { ComponentInternalInstance } from '../component'
+import type { ComponentInternalInstance } from '../component'
 import { DeprecationTypes, isCompatEnabled } from './compatConfig'
 
 export function shouldSkipAttr(
   key: string,
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): boolean {
   if (key === 'is') {
     return true
index 9ae34c07a5c71b359d0ec4730d4acbf65dfb4fb8..d0a04d3af454bad8258eb7fa174d1719314e2eb2 100644 (file)
@@ -1,12 +1,12 @@
 import { extend, hasOwn, isArray, isFunction } from '@vue/shared'
 import {
-  Component,
-  ComponentInternalInstance,
-  ComponentOptions,
+  type Component,
+  type ComponentInternalInstance,
+  type ComponentOptions,
   formatComponentName,
   getComponentName,
   getCurrentInstance,
-  isRuntimeOnly
+  isRuntimeOnly,
 } from '../component'
 import { warn } from '../warning'
 
@@ -63,7 +63,7 @@ export enum DeprecationTypes {
 
   FILTERS = 'FILTERS',
 
-  PRIVATE_APIS = 'PRIVATE_APIS'
+  PRIVATE_APIS = 'PRIVATE_APIS',
 }
 
 type DeprecationData = {
@@ -76,7 +76,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
     message:
       `The global app bootstrapping API has changed: vm.$mount() and the "el" ` +
       `option have been removed. Use createApp(RootComponent).mount() instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#mounting-app-instance`
+    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#mounting-app-instance`,
   },
 
   [DeprecationTypes.GLOBAL_MOUNT_CONTAINER]: {
@@ -84,72 +84,72 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `Vue detected directives on the mount container. ` +
       `In Vue 3, the container is no longer considered part of the template ` +
       `and will not be processed/replaced.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/mount-changes.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/mount-changes.html`,
   },
 
   [DeprecationTypes.GLOBAL_EXTEND]: {
     message:
       `Vue.extend() has been removed in Vue 3. ` +
       `Use defineComponent() instead.`,
-    link: `https://vuejs.org/api/general.html#definecomponent`
+    link: `https://vuejs.org/api/general.html#definecomponent`,
   },
 
   [DeprecationTypes.GLOBAL_PROTOTYPE]: {
     message:
       `Vue.prototype is no longer available in Vue 3. ` +
       `Use app.config.globalProperties instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#vue-prototype-replaced-by-config-globalproperties`
+    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#vue-prototype-replaced-by-config-globalproperties`,
   },
 
   [DeprecationTypes.GLOBAL_SET]: {
     message:
       `Vue.set() has been removed as it is no longer needed in Vue 3. ` +
-      `Simply use native JavaScript mutations.`
+      `Simply use native JavaScript mutations.`,
   },
 
   [DeprecationTypes.GLOBAL_DELETE]: {
     message:
       `Vue.delete() has been removed as it is no longer needed in Vue 3. ` +
-      `Simply use native JavaScript mutations.`
+      `Simply use native JavaScript mutations.`,
   },
 
   [DeprecationTypes.GLOBAL_OBSERVABLE]: {
     message:
       `Vue.observable() has been removed. ` +
       `Use \`import { reactive } from "vue"\` from Composition API instead.`,
-    link: `https://vuejs.org/api/reactivity-core.html#reactive`
+    link: `https://vuejs.org/api/reactivity-core.html#reactive`,
   },
 
   [DeprecationTypes.GLOBAL_PRIVATE_UTIL]: {
     message:
       `Vue.util has been removed. Please refactor to avoid its usage ` +
-      `since it was an internal API even in Vue 2.`
+      `since it was an internal API even in Vue 2.`,
   },
 
   [DeprecationTypes.CONFIG_SILENT]: {
     message:
       `config.silent has been removed because it is not good practice to ` +
       `intentionally suppress warnings. You can use your browser console's ` +
-      `filter features to focus on relevant messages.`
+      `filter features to focus on relevant messages.`,
   },
 
   [DeprecationTypes.CONFIG_DEVTOOLS]: {
     message:
       `config.devtools has been removed. To enable devtools for ` +
       `production, configure the __VUE_PROD_DEVTOOLS__ compile-time flag.`,
-    link: `https://github.com/vuejs/core/tree/main/packages/vue#bundler-build-feature-flags`
+    link: `https://github.com/vuejs/core/tree/main/packages/vue#bundler-build-feature-flags`,
   },
 
   [DeprecationTypes.CONFIG_KEY_CODES]: {
     message:
       `config.keyCodes has been removed. ` +
       `In Vue 3, you can directly use the kebab-case key names as v-on modifiers.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers.html`,
   },
 
   [DeprecationTypes.CONFIG_PRODUCTION_TIP]: {
     message: `config.productionTip has been removed.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#config-productiontip-removed`
+    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#config-productiontip-removed`,
   },
 
   [DeprecationTypes.CONFIG_IGNORED_ELEMENTS]: {
@@ -162,7 +162,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       }
       return msg
     },
-    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#config-ignoredelements-is-now-config-iscustomelement`
+    link: `https://v3-migration.vuejs.org/breaking-changes/global-api.html#config-ignoredelements-is-now-config-iscustomelement`,
   },
 
   [DeprecationTypes.CONFIG_WHITESPACE]: {
@@ -171,37 +171,37 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
     message:
       `Vue 3 compiler's whitespace option will default to "condense" instead of ` +
       `"preserve". To suppress this warning, provide an explicit value for ` +
-      `\`config.compilerOptions.whitespace\`.`
+      `\`config.compilerOptions.whitespace\`.`,
   },
 
   [DeprecationTypes.CONFIG_OPTION_MERGE_STRATS]: {
     message:
       `config.optionMergeStrategies no longer exposes internal strategies. ` +
-      `Use custom merge functions instead.`
+      `Use custom merge functions instead.`,
   },
 
   [DeprecationTypes.INSTANCE_SET]: {
     message:
       `vm.$set() has been removed as it is no longer needed in Vue 3. ` +
-      `Simply use native JavaScript mutations.`
+      `Simply use native JavaScript mutations.`,
   },
 
   [DeprecationTypes.INSTANCE_DELETE]: {
     message:
       `vm.$delete() has been removed as it is no longer needed in Vue 3. ` +
-      `Simply use native JavaScript mutations.`
+      `Simply use native JavaScript mutations.`,
   },
 
   [DeprecationTypes.INSTANCE_DESTROY]: {
     message: `vm.$destroy() has been removed. Use app.unmount() instead.`,
-    link: `https://vuejs.org/api/application.html#app-unmount`
+    link: `https://vuejs.org/api/application.html#app-unmount`,
   },
 
   [DeprecationTypes.INSTANCE_EVENT_EMITTER]: {
     message:
       `vm.$on/$once/$off() have been removed. ` +
       `Use an external event emitter library instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/events-api.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/events-api.html`,
   },
 
   [DeprecationTypes.INSTANCE_EVENT_HOOKS]: {
@@ -211,14 +211,14 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `should be changed to @vue:${event.slice(5)}. ` +
       `From JavaScript, use Composition API to dynamically register lifecycle ` +
       `hooks.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/vnode-lifecycle-events.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/vnode-lifecycle-events.html`,
   },
 
   [DeprecationTypes.INSTANCE_CHILDREN]: {
     message:
       `vm.$children has been removed. Consider refactoring your logic ` +
       `to avoid relying on direct access to child components.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/children.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/children.html`,
   },
 
   [DeprecationTypes.INSTANCE_LISTENERS]: {
@@ -227,12 +227,12 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `included in vm.$attrs and it is no longer necessary to separately use ` +
       `v-on="$listeners" if you are already using v-bind="$attrs". ` +
       `(Note: the Vue 3 behavior only applies if this compat config is disabled)`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/listeners-removed.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/listeners-removed.html`,
   },
 
   [DeprecationTypes.INSTANCE_SCOPED_SLOTS]: {
     message: `vm.$scopedSlots has been removed. Use vm.$slots instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/slots-unification.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/slots-unification.html`,
   },
 
   [DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE]: {
@@ -247,29 +247,29 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `If you are binding $attrs to a non-root element and expecting ` +
       `class/style to fallthrough on root, you will need to now manually bind ` +
       `them on root via :class="$attrs.class".`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/attrs-includes-class-style.html`,
   },
 
   [DeprecationTypes.OPTIONS_DATA_FN]: {
     message:
       `The "data" option can no longer be a plain object. ` +
       `Always use a function.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/data-option.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/data-option.html`,
   },
 
   [DeprecationTypes.OPTIONS_DATA_MERGE]: {
     message: (key: string) =>
       `Detected conflicting key "${key}" when merging data option values. ` +
       `In Vue 3, data keys are merged shallowly and will override one another.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/data-option.html#mixin-merge-behavior-change`
+    link: `https://v3-migration.vuejs.org/breaking-changes/data-option.html#mixin-merge-behavior-change`,
   },
 
   [DeprecationTypes.OPTIONS_BEFORE_DESTROY]: {
-    message: `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`
+    message: `\`beforeDestroy\` has been renamed to \`beforeUnmount\`.`,
   },
 
   [DeprecationTypes.OPTIONS_DESTROYED]: {
-    message: `\`destroyed\` has been renamed to \`unmounted\`.`
+    message: `\`destroyed\` has been renamed to \`unmounted\`.`,
   },
 
   [DeprecationTypes.WATCH_ARRAY]: {
@@ -279,7 +279,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `If current usage is intended, you can disable the compat behavior and ` +
       `suppress this warning with:` +
       `\n\n  configureCompat({ ${DeprecationTypes.WATCH_ARRAY}: false })\n`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/watch.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/watch.html`,
   },
 
   [DeprecationTypes.PROPS_DEFAULT_THIS]: {
@@ -287,21 +287,21 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `props default value function no longer has access to "this". The compat ` +
       `build only offers access to this.$options.` +
       `(found in prop "${key}")`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/props-default-this.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/props-default-this.html`,
   },
 
   [DeprecationTypes.CUSTOM_DIR]: {
     message: (legacyHook: string, newHook: string) =>
       `Custom directive hook "${legacyHook}" has been removed. ` +
       `Use "${newHook}" instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/custom-directives.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/custom-directives.html`,
   },
 
   [DeprecationTypes.V_ON_KEYCODE_MODIFIER]: {
     message:
       `Using keyCode as v-on modifier is no longer supported. ` +
       `Use kebab-case key name modifiers instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/keycode-modifiers.html`,
   },
 
   [DeprecationTypes.ATTR_FALSE_VALUE]: {
@@ -311,7 +311,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `use \`null\` or \`undefined\` instead. If the usage is intended, ` +
       `you can disable the compat behavior and suppress this warning with:` +
       `\n\n  configureCompat({ ${DeprecationTypes.ATTR_FALSE_VALUE}: false })\n`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html`,
   },
 
   [DeprecationTypes.ATTR_ENUMERATED_COERCION]: {
@@ -324,11 +324,11 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `If the usage is intended, ` +
       `you can disable the compat behavior and suppress this warning with:` +
       `\n\n  configureCompat({ ${DeprecationTypes.ATTR_ENUMERATED_COERCION}: false })\n`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html`,
   },
 
   [DeprecationTypes.TRANSITION_CLASSES]: {
-    message: `` // this feature cannot be runtime-detected
+    message: ``, // this feature cannot be runtime-detected
   },
 
   [DeprecationTypes.TRANSITION_GROUP_ROOT]: {
@@ -338,7 +338,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `for styling, you can disable the compat behavior and suppress this ` +
       `warning with:` +
       `\n\n  configureCompat({ ${DeprecationTypes.TRANSITION_GROUP_ROOT}: false })\n`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/transition-group.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/transition-group.html`,
   },
 
   [DeprecationTypes.COMPONENT_ASYNC]: {
@@ -356,7 +356,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
         `\n\n  configureCompat({ ${DeprecationTypes.COMPONENT_ASYNC}: false })\n`
       )
     },
-    link: `https://v3-migration.vuejs.org/breaking-changes/async-components.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/async-components.html`,
   },
 
   [DeprecationTypes.COMPONENT_FUNCTIONAL]: {
@@ -372,7 +372,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
         `been disabled.`
       )
     },
-    link: `https://v3-migration.vuejs.org/breaking-changes/functional-components.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/functional-components.html`,
   },
 
   [DeprecationTypes.COMPONENT_V_MODEL]: {
@@ -397,7 +397,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
         `"update:modelValue" event. You can update the usage and then ${configMsg}`
       )
     },
-    link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/v-model.html`,
   },
 
   [DeprecationTypes.RENDER_FUNCTION]: {
@@ -406,7 +406,7 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `You can opt-in to the new API with:` +
       `\n\n  configureCompat({ ${DeprecationTypes.RENDER_FUNCTION}: false })\n` +
       `\n  (This can also be done per-component via the "compatConfig" option.)`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/render-function-api.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/render-function-api.html`,
   },
 
   [DeprecationTypes.FILTERS]: {
@@ -414,15 +414,15 @@ export const deprecationData: Record<DeprecationTypes, DeprecationData> = {
       `filters have been removed in Vue 3. ` +
       `The "|" symbol will be treated as native JavaScript bitwise OR operator. ` +
       `Use method calls or computed properties instead.`,
-    link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`
+    link: `https://v3-migration.vuejs.org/breaking-changes/filters.html`,
   },
 
   [DeprecationTypes.PRIVATE_APIS]: {
     message: name =>
       `"${name}" is a Vue 2 private API that no longer exists in Vue 3. ` +
       `If you are seeing this warning only due to a dependency, you can ` +
-      `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`
-  }
+      `suppress this warning via { PRIVATE_APIS: 'suppress-warning' }.`,
+  },
 }
 
 const instanceWarned: Record<string, true> = Object.create(null)
@@ -482,12 +482,12 @@ export function warnDeprecation(
   warn(
     `(deprecation ${key}) ${
       typeof message === 'function' ? message(...args) : message
-    }${link ? `\n  Details: ${link}` : ``}`
+    }${link ? `\n  Details: ${link}` : ``}`,
   )
   if (!isCompatEnabled(key, instance, true)) {
     console.error(
       `^ The above deprecation's compat behavior is disabled and will likely ` +
-        `lead to runtime errors.`
+        `lead to runtime errors.`,
     )
   }
 }
@@ -499,7 +499,7 @@ export type CompatConfig = Partial<
 }
 
 export const globalCompatConfig: CompatConfig = {
-  MODE: 2
+  MODE: 2,
 }
 
 export function configureCompat(config: CompatConfig) {
@@ -515,7 +515,7 @@ const warnedInvalidKeys: Record<string, boolean> = {}
 // dev only
 export function validateCompatConfig(
   config: CompatConfig,
-  instance?: ComponentInternalInstance
+  instance?: ComponentInternalInstance,
 ) {
   if (seenConfigObjects.has(config)) {
     return
@@ -534,7 +534,7 @@ export function validateCompatConfig(
             `Deprecation config "${key}" is compiler-specific and you are ` +
               `running a runtime-only build of Vue. This deprecation should be ` +
               `configured via compiler options in your build setup instead.\n` +
-              `Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`
+              `Details: https://v3-migration.vuejs.org/breaking-changes/migration-build.html`,
           )
         }
       } else {
@@ -546,14 +546,14 @@ export function validateCompatConfig(
 
   if (instance && config[DeprecationTypes.OPTIONS_DATA_MERGE] != null) {
     warn(
-      `Deprecation config "${DeprecationTypes.OPTIONS_DATA_MERGE}" can only be configured globally.`
+      `Deprecation config "${DeprecationTypes.OPTIONS_DATA_MERGE}" can only be configured globally.`,
     )
   }
 }
 
 export function getCompatConfigForKey(
   key: DeprecationTypes | 'MODE',
-  instance: ComponentInternalInstance | null
+  instance: ComponentInternalInstance | null,
 ) {
   const instanceConfig =
     instance && (instance.type as ComponentOptions).compatConfig
@@ -566,7 +566,7 @@ export function getCompatConfigForKey(
 export function isCompatEnabled(
   key: DeprecationTypes,
   instance: ComponentInternalInstance | null,
-  enableForBuiltIn = false
+  enableForBuiltIn = false,
 ): boolean {
   // skip compat for built-in components
   if (!enableForBuiltIn && instance && instance.type.__isBuiltIn) {
@@ -637,6 +637,6 @@ export function checkCompatEnabled(
 // run tests in v3 mode by default
 if (__TEST__) {
   configureCompat({
-    MODE: 3
+    MODE: 3,
   })
 }
index b09d579a59a95e6861b858d3f328a438ca2aa5b7..84a76eb73a134d60b961399e556a1df100521f28 100644 (file)
@@ -1,16 +1,16 @@
 import { isFunction, isObject } from '@vue/shared'
-import { Component, ComponentInternalInstance } from '../component'
+import type { Component, ComponentInternalInstance } from '../component'
 import {
-  checkCompatEnabled,
   DeprecationTypes,
-  softAssertCompatEnabled
+  checkCompatEnabled,
+  softAssertCompatEnabled,
 } from './compatConfig'
 import { convertLegacyAsyncComponent } from './componentAsync'
 import { convertLegacyFunctionalComponent } from './componentFunctional'
 
 export function convertLegacyComponent(
   comp: any,
-  instance: ComponentInternalInstance | null
+  instance: ComponentInternalInstance | null,
 ): Component {
   if (comp.__isBuiltIn) {
     return comp
@@ -38,7 +38,7 @@ export function convertLegacyComponent(
     softAssertCompatEnabled(
       DeprecationTypes.COMPONENT_FUNCTIONAL,
       instance,
-      comp
+      comp,
     )
   ) {
     return convertLegacyFunctionalComponent(comp)
index 5b2ac22c23398615f5d1f99e0ed791931b960260..4621cd2e8786e195e32263f21b25539d01bc98dc 100644 (file)
@@ -1,6 +1,6 @@
 import { isArray, isObject, isPromise } from '@vue/shared'
 import { defineAsyncComponent } from '../apiAsyncComponent'
-import { Component } from '../component'
+import type { Component } from '../component'
 import { isVNode } from '../vnode'
 
 interface LegacyAsyncOptions {
@@ -15,7 +15,7 @@ type LegacyAsyncReturnValue = Promise<Component> | LegacyAsyncOptions
 
 type LegacyAsyncComponent = (
   resolve?: (res: LegacyAsyncReturnValue) => void,
-  reject?: (reason?: any) => void
+  reject?: (reason?: any) => void,
 ) => LegacyAsyncReturnValue | undefined
 
 const normalizedAsyncComponentMap = new WeakMap<
@@ -47,7 +47,7 @@ export function convertLegacyAsyncComponent(comp: LegacyAsyncComponent) {
       loadingComponent: res.loading,
       errorComponent: res.error,
       delay: res.delay,
-      timeout: res.timeout
+      timeout: res.timeout,
     })
   } else if (res == null) {
     converted = defineAsyncComponent(() => fallbackPromise)
index 90d24e1ba734e5bf62b591273e4adfd2fb342aa1..c2fbcbe2564ac3a07f83e4746d9224b8649fa8e1 100644 (file)
@@ -1,10 +1,10 @@
 import {
-  ComponentOptions,
-  FunctionalComponent,
-  getCurrentInstance
+  type ComponentOptions,
+  type FunctionalComponent,
+  getCurrentInstance,
 } from '../component'
 import { resolveInjections } from '../componentOptions'
-import { InternalSlots } from '../componentSlots'
+import type { InternalSlots } from '../componentSlots'
 import { getCompatListeners } from './instanceListeners'
 import { compatH } from './renderFn'
 
@@ -16,7 +16,7 @@ export const legacySlotProxyHandlers: ProxyHandler<InternalSlots> = {
   get(target, key: string) {
     const slot = target[key]
     return slot && slot()
-  }
+  },
 }
 
 export function convertLegacyFunctionalComponent(comp: ComponentOptions) {
@@ -48,7 +48,7 @@ export function convertLegacyFunctionalComponent(comp: ComponentOptions) {
           return injections
         }
         return {}
-      }
+      },
     }
     return legacyFn(compatH, legacyCtx)
   }
index b446fb4274d20f6f0b60c8ad90f6a177ceef857d..e8523496ee3e21462e5156f00b5e051479cdd79d 100644 (file)
@@ -1,12 +1,12 @@
-import { extend, ShapeFlags } from '@vue/shared'
-import { ComponentInternalInstance, ComponentOptions } from '../component'
-import { callWithErrorHandling, ErrorCodes } from '../errorHandling'
-import { VNode } from '../vnode'
+import { ShapeFlags, extend } from '@vue/shared'
+import type { ComponentInternalInstance, ComponentOptions } from '../component'
+import { ErrorCodes, callWithErrorHandling } from '../errorHandling'
+import type { VNode } from '../vnode'
 import { popWarningContext, pushWarningContext } from '../warning'
 import {
   DeprecationTypes,
+  isCompatEnabled,
   warnDeprecation,
-  isCompatEnabled
 } from './compatConfig'
 
 export const compatModelEventPrefix = `onModelCompat:`
@@ -23,7 +23,7 @@ export function convertLegacyVModelProps(vnode: VNode) {
         // this is a special case where we want to use the vnode component's
         // compat config instead of the current rendering instance (which is the
         // parent of the component that exposes v-model)
-        { type } as any
+        { type } as any,
       )
     ) {
       return
@@ -67,7 +67,7 @@ function applyModelFromMixins(model: any, mixins?: ComponentOptions[]) {
 export function compatModelEmit(
   instance: ComponentInternalInstance,
   event: string,
-  args: any[]
+  args: any[],
 ) {
   if (!isCompatEnabled(DeprecationTypes.COMPONENT_V_MODEL, instance)) {
     return
@@ -79,7 +79,7 @@ export function compatModelEmit(
       modelHandler,
       instance,
       ErrorCodes.COMPONENT_EVENT_HANDLER,
-      args
+      args,
     )
   }
 }
index da351eb0812cce3cf034eb558a38782868a0626f..d5ce1d78e3d3b0e94c9e4393cd4a7ce22696d4a1 100644 (file)
@@ -1,7 +1,7 @@
 import { isArray } from '@vue/shared'
-import { ComponentInternalInstance } from '../component'
-import { ObjectDirective, DirectiveHook } from '../directives'
-import { softAssertCompatEnabled, DeprecationTypes } from './compatConfig'
+import type { ComponentInternalInstance } from '../component'
+import type { DirectiveHook, ObjectDirective } from '../directives'
+import { DeprecationTypes, softAssertCompatEnabled } from './compatConfig'
 
 export interface LegacyDirective {
   bind?: DirectiveHook
@@ -20,13 +20,13 @@ const legacyDirectiveHookMap: Partial<
   beforeMount: 'bind',
   mounted: 'inserted',
   updated: ['update', 'componentUpdated'],
-  unmounted: 'unbind'
+  unmounted: 'unbind',
 }
 
 export function mapCompatDirectiveHook(
   name: keyof ObjectDirective,
   dir: ObjectDirective & LegacyDirective,
-  instance: ComponentInternalInstance | null
+  instance: ComponentInternalInstance | null,
 ): DirectiveHook | DirectiveHook[] | undefined {
   const mappedName = legacyDirectiveHookMap[name]
   if (mappedName) {
@@ -39,7 +39,7 @@ export function mapCompatDirectiveHook(
             DeprecationTypes.CUSTOM_DIR,
             instance,
             mapped,
-            name
+            name,
           )
           hook.push(mappedHook)
         }
@@ -51,7 +51,7 @@ export function mapCompatDirectiveHook(
           DeprecationTypes.CUSTOM_DIR,
           instance,
           mappedName,
-          name
+          name,
         )
       }
       return dir[mappedName]
index 1e4d206eae3f361e87aa547f2fe84d646e7c8917..5bf234fcf4592fe68f89fbc7f09fb195fd3caca9 100644 (file)
@@ -1,63 +1,63 @@
 import {
+  TrackOpTypes,
+  TriggerOpTypes,
   isReactive,
   reactive,
   track,
-  TrackOpTypes,
   trigger,
-  TriggerOpTypes
 } from '@vue/reactivity'
 import {
-  isFunction,
-  extend,
   NOOP,
+  extend,
+  invokeArrayFns,
   isArray,
+  isFunction,
   isObject,
   isString,
-  invokeArrayFns
 } from '@vue/shared'
 import { warn } from '../warning'
 import { cloneVNode, createVNode } from '../vnode'
-import { ElementNamespace, RootRenderFunction } from '../renderer'
-import {
+import type { ElementNamespace, RootRenderFunction } from '../renderer'
+import type {
   App,
   AppConfig,
   AppContext,
   CreateAppFunction,
-  Plugin
+  Plugin,
 } from '../apiCreateApp'
 import {
-  Component,
-  ComponentOptions,
+  type Component,
+  type ComponentOptions,
   createComponentInstance,
   finishComponentSetup,
   isRuntimeOnly,
-  setupComponent
+  setupComponent,
 } from '../component'
 import {
-  RenderFunction,
+  type RenderFunction,
+  internalOptionMergeStrats,
   mergeOptions,
-  internalOptionMergeStrats
 } from '../componentOptions'
-import { ComponentPublicInstance } from '../componentPublicInstance'
+import type { ComponentPublicInstance } from '../componentPublicInstance'
 import { devtoolsInitApp, devtoolsUnmountApp } from '../devtools'
-import { Directive } from '../directives'
+import type { Directive } from '../directives'
 import { nextTick } from '../scheduler'
 import { version } from '..'
 import {
+  type LegacyConfig,
   installLegacyConfigWarnings,
   installLegacyOptionMergeStrats,
-  LegacyConfig
 } from './globalConfig'
-import { LegacyDirective } from './customDirective'
+import type { LegacyDirective } from './customDirective'
 import {
-  warnDeprecation,
   DeprecationTypes,
   assertCompatEnabled,
   configureCompat,
   isCompatEnabled,
-  softAssertCompatEnabled
+  softAssertCompatEnabled,
+  warnDeprecation,
 } from './compatConfig'
-import { LegacyPublicInstance } from './instance'
+import type { LegacyPublicInstance } from './instance'
 
 /**
  * @deprecated the default `Vue` export has been removed in Vue 3. The type for
@@ -85,7 +85,7 @@ export type CompatVue = Pick<App, 'version' | 'component' | 'directive'> & {
   directive<T = any, V = any>(name: string): Directive<T, V> | undefined
   directive<T = any, V = any>(
     name: string,
-    directive: Directive<T, V>
+    directive: Directive<T, V>,
   ): CompatVue
 
   compile(template: string): RenderFunction
@@ -137,12 +137,12 @@ let singletonCtor: CompatVue
 // Legacy global Vue constructor
 export function createCompatVue(
   createApp: CreateAppFunction<Element>,
-  createSingletonApp: CreateAppFunction<Element>
+  createSingletonApp: CreateAppFunction<Element>,
 ): CompatVue {
   singletonApp = createSingletonApp({})
 
   const Vue: CompatVue = (singletonCtor = function Vue(
-    options: ComponentOptions = {}
+    options: ComponentOptions = {},
   ) {
     return createCompatApp(options, Vue)
   } as any)
@@ -236,9 +236,9 @@ export function createCompatVue(
           mergeOptions(
             extend({}, SubVue.options),
             inlineOptions,
-            internalOptionMergeStrats as any
+            internalOptionMergeStrats as any,
           ),
-          SubVue
+          SubVue,
         )
       }
     }
@@ -261,7 +261,7 @@ export function createCompatVue(
     SubVue.options = mergeOptions(
       mergeBase,
       extendOptions,
-      internalOptionMergeStrats as any
+      internalOptionMergeStrats as any,
     )
 
     SubVue.options._base = SubVue
@@ -308,15 +308,15 @@ export function createCompatVue(
       mergeOptions(
         parent,
         child,
-        vm ? undefined : (internalOptionMergeStrats as any)
+        vm ? undefined : (internalOptionMergeStrats as any),
       ),
-    defineReactive
+    defineReactive,
   }
   Object.defineProperty(Vue, 'util', {
     get() {
       assertCompatEnabled(DeprecationTypes.GLOBAL_PRIVATE_UTIL, null)
       return util
-    }
+    },
   })
 
   Vue.configureCompat = configureCompat
@@ -327,7 +327,7 @@ export function createCompatVue(
 export function installAppCompatProperties(
   app: App,
   context: AppContext,
-  render: RootRenderFunction<any>
+  render: RootRenderFunction<any>,
 ) {
   installFilterMethod(app, context)
   installLegacyOptionMergeStrats(app.config)
@@ -367,7 +367,7 @@ function installLegacyAPIs(app: App) {
       get() {
         __DEV__ && warnDeprecation(DeprecationTypes.GLOBAL_PROTOTYPE, null)
         return app.config.globalProperties
-      }
+      },
     },
     nextTick: { value: nextTick },
     extend: { value: singletonCtor.extend },
@@ -377,8 +377,8 @@ function installLegacyAPIs(app: App) {
     util: {
       get() {
         return singletonCtor.util
-      }
-    }
+      },
+    },
   })
 }
 
@@ -386,7 +386,7 @@ function applySingletonAppMutations(app: App) {
   // copy over asset registries and deopt flag
   app._context.mixins = [...singletonApp._context.mixins]
   ;['components', 'directives', 'filters'].forEach(key => {
-    // @ts-ignore
+    // @ts-expect-error
     app._context[key] = Object.create(singletonApp._context[key])
   })
 
@@ -401,7 +401,7 @@ function applySingletonAppMutations(app: App) {
       continue
     }
     const val = singletonApp.config[key as keyof AppConfig]
-    // @ts-ignore
+    // @ts-expect-error
     app.config[key] = isObject(val) ? Object.create(val) : val
 
     // compat for runtime ignoredElements -> isCustomElement
@@ -435,7 +435,7 @@ function applySingletonPrototype(app: App, Ctor: Function) {
         Object.defineProperty(
           app.config.globalProperties,
           key,
-          descriptors[key]
+          descriptors[key],
         )
       }
     }
@@ -448,7 +448,7 @@ function applySingletonPrototype(app: App, Ctor: Function) {
 function installCompatMount(
   app: App,
   context: AppContext,
-  render: RootRenderFunction
+  render: RootRenderFunction,
 ) {
   let isMounted = false
 
@@ -496,7 +496,7 @@ function installCompatMount(
         if (!result) {
           __DEV__ &&
             warn(
-              `Failed to mount root instance: selector "${selectorOrEl}" returned null.`
+              `Failed to mount root instance: selector "${selectorOrEl}" returned null.`,
             )
           return
         }
@@ -606,7 +606,7 @@ const methodsToPatch = [
   'unshift',
   'splice',
   'sort',
-  'reverse'
+  'reverse',
 ]
 
 const patched = new WeakSet<object>()
@@ -619,9 +619,9 @@ function defineReactive(obj: any, key: string, val: any) {
     const reactiveVal = reactive(val)
     if (isArray(val)) {
       methodsToPatch.forEach(m => {
-        // @ts-ignore
+        // @ts-expect-error
         val[m] = (...args: any[]) => {
-          // @ts-ignore
+          // @ts-expect-error
           Array.prototype[m].call(reactiveVal, ...args)
         }
       })
@@ -658,6 +658,6 @@ function defineReactiveSimple(obj: any, key: string, val: any) {
     set(newVal) {
       val = isObject(newVal) ? reactive(newVal) : newVal
       trigger(obj, TriggerOpTypes.SET, key, newVal)
-    }
+    },
   })
 }
index 03a4699aa559ce29f70e1dbd4ade3ff307a6c3e3..8c4afa7a7662b9716a5eadd28a491556cb7e5ede 100644 (file)
@@ -1,8 +1,8 @@
-import { AppConfig } from '../apiCreateApp'
+import type { AppConfig } from '../apiCreateApp'
 import {
   DeprecationTypes,
   softAssertCompatEnabled,
-  warnDeprecation
+  warnDeprecation,
 } from './compatConfig'
 import { isCopyingConfig } from './global'
 import { internalOptionMergeStrats } from '../componentOptions'
@@ -42,7 +42,7 @@ export function installLegacyConfigWarnings(config: AppConfig) {
     devtools: DeprecationTypes.CONFIG_DEVTOOLS,
     ignoredElements: DeprecationTypes.CONFIG_IGNORED_ELEMENTS,
     keyCodes: DeprecationTypes.CONFIG_KEY_CODES,
-    productionTip: DeprecationTypes.CONFIG_PRODUCTION_TIP
+    productionTip: DeprecationTypes.CONFIG_PRODUCTION_TIP,
   }
 
   Object.keys(legacyConfigOptions).forEach(key => {
@@ -57,7 +57,7 @@ export function installLegacyConfigWarnings(config: AppConfig) {
           warnDeprecation(legacyConfigOptions[key], null)
         }
         val = newVal
-      }
+      },
     })
   })
 }
@@ -72,13 +72,13 @@ export function installLegacyOptionMergeStrats(config: AppConfig) {
         key in internalOptionMergeStrats &&
         softAssertCompatEnabled(
           DeprecationTypes.CONFIG_OPTION_MERGE_STRATS,
-          null
+          null,
         )
       ) {
         return internalOptionMergeStrats[
           key as keyof typeof internalOptionMergeStrats
         ]
       }
-    }
+    },
   })
 }
index e6baeda6a8e30555e32dcbb372c7c6f76f280222..5beaf5f5ebb6cb197b60993d222277d1c06db2ad 100644 (file)
@@ -1,20 +1,20 @@
 import {
+  NOOP,
   extend,
   looseEqual,
   looseIndexOf,
   looseToNumber,
-  NOOP,
-  toDisplayString
+  toDisplayString,
 } from '@vue/shared'
-import {
+import type {
   ComponentPublicInstance,
-  PublicPropertiesMap
+  PublicPropertiesMap,
 } from '../componentPublicInstance'
 import { getCompatChildren } from './instanceChildren'
 import {
   DeprecationTypes,
   assertCompatEnabled,
-  isCompatEnabled
+  isCompatEnabled,
 } from './compatConfig'
 import { off, on, once } from './instanceEventEmitter'
 import { getCompatListeners } from './instanceListeners'
@@ -32,11 +32,11 @@ import {
   legacyPrependModifier,
   legacyRenderSlot,
   legacyRenderStatic,
-  legacyresolveScopedSlots
+  legacyresolveScopedSlots,
 } from './renderHelpers'
 import { resolveFilter } from '../helpers/resolveAssets'
-import { InternalSlots, Slots } from '../componentSlots'
-import { ContextualRenderFn } from '../componentRenderContext'
+import type { InternalSlots, Slots } from '../componentSlots'
+import type { ContextualRenderFn } from '../componentRenderContext'
 import { resolveMergedOptions } from '../componentOptions'
 
 export type LegacyPublicInstance = ComponentPublicInstance &
@@ -79,7 +79,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
     $mount: i => {
       assertCompatEnabled(
         DeprecationTypes.GLOBAL_MOUNT,
-        null /* this warning is global */
+        null /* this warning is global */,
       )
       // root mount override from ./global.ts in installCompatMount
       return i.ctx._compat_mount || NOOP
@@ -120,7 +120,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
     $off: i => off.bind(null, i),
 
     $children: getCompatChildren,
-    $listeners: getCompatListeners
+    $listeners: getCompatListeners,
   } as PublicPropertiesMap)
 
   /* istanbul ignore if */
@@ -164,7 +164,7 @@ export function installCompatInstanceProperties(map: PublicPropertiesMap) {
       _u: () => legacyresolveScopedSlots,
       _g: () => legacyBindObjectListeners,
       _d: () => legacyBindDynamicKeys,
-      _p: () => legacyPrependModifier
+      _p: () => legacyPrependModifier,
     } as PublicPropertiesMap)
   }
 }
index 7524e53b7f1ab400691301b60dd57e44055bcde6..415275342ab6b3ca106b289bcffd2098bdee2c0f 100644 (file)
@@ -1,11 +1,11 @@
 import { ShapeFlags } from '@vue/shared'
-import { ComponentInternalInstance } from '../component'
-import { ComponentPublicInstance } from '../componentPublicInstance'
-import { VNode } from '../vnode'
-import { assertCompatEnabled, DeprecationTypes } from './compatConfig'
+import type { ComponentInternalInstance } from '../component'
+import type { ComponentPublicInstance } from '../componentPublicInstance'
+import type { VNode } from '../vnode'
+import { DeprecationTypes, assertCompatEnabled } from './compatConfig'
 
 export function getCompatChildren(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): ComponentPublicInstance[] {
   assertCompatEnabled(DeprecationTypes.INSTANCE_CHILDREN, instance)
   const root = instance.subTree
index b314f686c4eeed738c4694e825d4489639af9f8c..a8d3f52518bfa438fec5cdf3ad501f7c098955d0 100644 (file)
@@ -1,7 +1,7 @@
 import { isArray } from '@vue/shared'
-import { ComponentInternalInstance } from '../component'
-import { callWithAsyncErrorHandling, ErrorCodes } from '../errorHandling'
-import { assertCompatEnabled, DeprecationTypes } from './compatConfig'
+import type { ComponentInternalInstance } from '../component'
+import { ErrorCodes, callWithAsyncErrorHandling } from '../errorHandling'
+import { DeprecationTypes, assertCompatEnabled } from './compatConfig'
 
 interface EventRegistry {
   [event: string]: Function[] | undefined
@@ -13,7 +13,7 @@ const eventRegistryMap = /*#__PURE__*/ new WeakMap<
 >()
 
 export function getRegistry(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): EventRegistry {
   let events = eventRegistryMap.get(instance)
   if (!events) {
@@ -25,7 +25,7 @@ export function getRegistry(
 export function on(
   instance: ComponentInternalInstance,
   event: string | string[],
-  fn: Function
+  fn: Function,
 ) {
   if (isArray(event)) {
     event.forEach(e => on(instance, e, fn))
@@ -34,7 +34,7 @@ export function on(
       assertCompatEnabled(
         DeprecationTypes.INSTANCE_EVENT_HOOKS,
         instance,
-        event
+        event,
       )
     } else {
       assertCompatEnabled(DeprecationTypes.INSTANCE_EVENT_EMITTER, instance)
@@ -48,7 +48,7 @@ export function on(
 export function once(
   instance: ComponentInternalInstance,
   event: string,
-  fn: Function
+  fn: Function,
 ) {
   const wrapped = (...args: any[]) => {
     off(instance, event, wrapped)
@@ -62,7 +62,7 @@ export function once(
 export function off(
   instance: ComponentInternalInstance,
   event?: string | string[],
-  fn?: Function
+  fn?: Function,
 ) {
   assertCompatEnabled(DeprecationTypes.INSTANCE_EVENT_EMITTER, instance)
   const vm = instance.proxy
@@ -93,7 +93,7 @@ export function off(
 export function emit(
   instance: ComponentInternalInstance,
   event: string,
-  args: any[]
+  args: any[],
 ) {
   const cbs = getRegistry(instance)[event]
   if (cbs) {
@@ -101,7 +101,7 @@ export function emit(
       cbs.map(cb => cb.bind(instance.proxy)),
       instance,
       ErrorCodes.COMPONENT_EVENT_HANDLER,
-      args
+      args,
     )
   }
   return instance.proxy
index 973d440b10c6802c8418e0c6f022896a646050fa..e01b72411d38b7ca35be4a64847a548ffc7471f0 100644 (file)
@@ -1,6 +1,6 @@
 import { isOn } from '@vue/shared'
-import { ComponentInternalInstance } from '../component'
-import { assertCompatEnabled, DeprecationTypes } from './compatConfig'
+import type { ComponentInternalInstance } from '../component'
+import { DeprecationTypes, assertCompatEnabled } from './compatConfig'
 
 export function getCompatListeners(instance: ComponentInternalInstance) {
   assertCompatEnabled(DeprecationTypes.INSTANCE_LISTENERS, instance)
index e2fccb6675fccad563f9693545f5fdec5997f409..0330e33aa1592873aa14ecc84406fd115c1e8580 100644 (file)
@@ -1,13 +1,16 @@
 import { isArray } from '@vue/shared'
 import { inject } from '../apiInject'
-import { ComponentInternalInstance, Data } from '../component'
-import { ComponentOptions, resolveMergedOptions } from '../componentOptions'
+import type { ComponentInternalInstance, Data } from '../component'
+import {
+  type ComponentOptions,
+  resolveMergedOptions,
+} from '../componentOptions'
 import { DeprecationTypes, warnDeprecation } from './compatConfig'
 
 export function createPropsDefaultThis(
   instance: ComponentInternalInstance,
   rawProps: Data,
-  propKey: string
+  propKey: string,
 ) {
   return new Proxy(
     {},
@@ -34,7 +37,7 @@ export function createPropsDefaultThis(
             return inject(key)
           }
         }
-      }
-    }
+      },
+    },
   )
 }
index 4cf2fc226cf25d083d3549ae3a9e0cabfb223104..52a19d08f8e9f9d4620111c58e03b6b179458af7 100644 (file)
@@ -1,4 +1,5 @@
 import {
+  ShapeFlags,
   extend,
   hyphenate,
   isArray,
@@ -7,35 +8,34 @@ import {
   makeMap,
   normalizeClass,
   normalizeStyle,
-  ShapeFlags,
-  toHandlerKey
+  toHandlerKey,
 } from '@vue/shared'
-import {
+import type {
   Component,
   ComponentInternalInstance,
   ComponentOptions,
   Data,
-  InternalRenderFunction
+  InternalRenderFunction,
 } from '../component'
 import { currentRenderingInstance } from '../componentRenderContext'
-import { DirectiveArguments, withDirectives } from '../directives'
+import { type DirectiveArguments, withDirectives } from '../directives'
 import {
   resolveDirective,
-  resolveDynamicComponent
+  resolveDynamicComponent,
 } from '../helpers/resolveAssets'
 import {
   Comment,
+  type VNode,
+  type VNodeArrayChildren,
+  type VNodeProps,
   createVNode,
   isVNode,
   normalizeChildren,
-  VNode,
-  VNodeArrayChildren,
-  VNodeProps
 } from '../vnode'
 import {
-  checkCompatEnabled,
   DeprecationTypes,
-  isCompatEnabled
+  checkCompatEnabled,
+  isCompatEnabled,
 } from './compatConfig'
 import { compatModelEventPrefix } from './componentVModel'
 
@@ -59,10 +59,10 @@ export function convertLegacyRenderFn(instance: ComponentInternalInstance) {
   // v2 render function, try to provide compat
   if (checkCompatEnabled(DeprecationTypes.RENDER_FUNCTION, instance)) {
     const wrapped = (Component.render = function compatRender() {
-      // @ts-ignore
+      // @ts-expect-error
       return render.call(this, compatH)
     })
-    // @ts-ignore
+    // @ts-expect-error
     wrapped._compatWrapped = true
   }
 }
@@ -109,18 +109,18 @@ type LegacyVNodeChildren =
 
 export function compatH(
   type: string | Component,
-  children?: LegacyVNodeChildren
+  children?: LegacyVNodeChildren,
 ): VNode
 export function compatH(
   type: string | Component,
   props?: Data & LegacyVNodeProps,
-  children?: LegacyVNodeChildren
+  children?: LegacyVNodeChildren,
 ): VNode
 
 export function compatH(
   type: any,
   propsOrChildren?: any,
-  children?: any
+  children?: any,
 ): VNode {
   if (!type) {
     type = Comment
@@ -150,8 +150,8 @@ export function compatH(
       return convertLegacySlots(
         convertLegacyDirectives(
           createVNode(type, convertLegacyProps(propsOrChildren, type)),
-          propsOrChildren
-        )
+          propsOrChildren,
+        ),
       )
     } else {
       // omit props
@@ -164,19 +164,19 @@ export function compatH(
     return convertLegacySlots(
       convertLegacyDirectives(
         createVNode(type, convertLegacyProps(propsOrChildren, type), children),
-        propsOrChildren
-      )
+        propsOrChildren,
+      ),
     )
   }
 }
 
 const skipLegacyRootLevelProps = /*#__PURE__*/ makeMap(
-  'staticStyle,staticClass,directives,model,hook'
+  'staticStyle,staticClass,directives,model,hook',
 )
 
 function convertLegacyProps(
   legacyProps: LegacyVNodeProps | undefined,
-  type: any
+  type: any,
 ): (Data & VNodeProps) | null {
   if (!legacyProps) {
     return null
@@ -240,7 +240,7 @@ function convertLegacyEventKey(event: string): string {
 
 function convertLegacyDirectives(
   vnode: VNode,
-  props?: LegacyVNodeProps
+  props?: LegacyVNodeProps,
 ): VNode {
   if (props && props.directives) {
     return withDirectives(
@@ -250,9 +250,9 @@ function convertLegacyDirectives(
           resolveDirective(name)!,
           value,
           arg,
-          modifiers
+          modifiers,
         ] as DirectiveArguments[number]
-      })
+      }),
     )
   }
   return vnode
@@ -309,12 +309,12 @@ export function defineLegacyVNodeProperties(vnode: VNode) {
     isCompatEnabled(
       DeprecationTypes.RENDER_FUNCTION,
       currentRenderingInstance,
-      true /* enable for built-ins */
+      true /* enable for built-ins */,
     ) &&
     isCompatEnabled(
       DeprecationTypes.PRIVATE_APIS,
       currentRenderingInstance,
-      true /* enable for built-ins */
+      true /* enable for built-ins */,
     )
   ) {
     const context = currentRenderingInstance
@@ -337,11 +337,11 @@ export function defineLegacyVNodeProperties(vnode: VNode) {
             return (componentOptions = {
               Ctor: vnode.type,
               propsData: vnode.props,
-              children: vnode.children
+              children: vnode.children,
             })
           }
-        }
-      }
+        },
+      },
     })
   }
 }
index aa156c11a4008352c0006c8793278ce4bbd5894c..56dad6238c87879e41bf0873b5b3e876a6719dd1 100644 (file)
@@ -5,14 +5,14 @@ import {
   isArray,
   isObject,
   isReservedProp,
-  normalizeClass
+  normalizeClass,
 } from '@vue/shared'
-import { ComponentInternalInstance } from '../component'
-import { Slot } from '../componentSlots'
+import type { ComponentInternalInstance } from '../component'
+import type { Slot } from '../componentSlots'
 import { createSlots } from '../helpers/createSlots'
 import { renderSlot } from '../helpers/renderSlot'
 import { toHandlers } from '../helpers/toHandlers'
-import { mergeProps, VNode } from '../vnode'
+import { type VNode, mergeProps } from '../vnode'
 
 function toObject(arr: Array<any>): Object {
   const res = {}
@@ -29,7 +29,7 @@ export function legacyBindObjectProps(
   _tag: string,
   value: any,
   _asProp: boolean,
-  isSync?: boolean
+  isSync?: boolean,
 ) {
   if (value && isObject(value)) {
     if (isArray(value)) {
@@ -71,7 +71,7 @@ export function legacyRenderSlot(
   name: string,
   fallback?: VNode[],
   props?: any,
-  bindObject?: any
+  bindObject?: any,
 ) {
   if (bindObject) {
     props = mergeProps(props, bindObject)
@@ -91,12 +91,12 @@ export function legacyresolveScopedSlots(
   fns: LegacyScopedSlotsData,
   raw?: Record<string, Slot>,
   // the following are added in 2.6
-  hasDynamicKeys?: boolean
+  hasDynamicKeys?: boolean,
 ) {
   // v2 default slot doesn't have name
   return createSlots(
     raw || ({ $stable: !hasDynamicKeys } as any),
-    mapKeyToName(fns)
+    mapKeyToName(fns),
   )
 }
 
@@ -121,7 +121,7 @@ const staticCacheMap = /*#__PURE__*/ new WeakMap<
 
 export function legacyRenderStatic(
   instance: ComponentInternalInstance,
-  index: number
+  index: number,
 ) {
   let cache = staticCacheMap.get(instance)
   if (!cache) {
@@ -141,7 +141,7 @@ export function legacyCheckKeyCodes(
   key: string,
   builtInKeyCode?: number | number[],
   eventKeyName?: string,
-  builtInKeyName?: string | string[]
+  builtInKeyName?: string | string[],
 ) {
   const config = instance.appContext.config as any
   const configKeyCodes = config.keyCodes || {}
index 8e82c74c5f1e49b884477748caad127cb9ddca94..6595df8fd5547daa32b2ed25fe4e7e736e5375b6 100644 (file)
@@ -1,86 +1,90 @@
-import { VNode, VNodeChild, isVNode } from './vnode'
+import { type VNode, type VNodeChild, isVNode } from './vnode'
 import {
+  EffectScope,
+  type ReactiveEffect,
+  TrackOpTypes,
   isRef,
+  markRaw,
   pauseTracking,
+  proxyRefs,
   resetTracking,
   shallowReadonly,
-  proxyRefs,
-  EffectScope,
-  markRaw,
   track,
-  TrackOpTypes,
-  ReactiveEffect
 } from '@vue/reactivity'
 import {
-  ComponentPublicInstance,
+  type ComponentPublicInstance,
+  type ComponentPublicInstanceConstructor,
   PublicInstanceProxyHandlers,
+  RuntimeCompiledPublicInstanceProxyHandlers,
   createDevRenderContext,
   exposePropsOnRenderContext,
   exposeSetupStateOnRenderContext,
-  ComponentPublicInstanceConstructor,
   publicPropertiesMap,
-  RuntimeCompiledPublicInstanceProxyHandlers
 } from './componentPublicInstance'
 import {
-  ComponentPropsOptions,
-  NormalizedPropsOptions,
+  type ComponentPropsOptions,
+  type NormalizedPropsOptions,
   initProps,
-  normalizePropsOptions
+  normalizePropsOptions,
 } from './componentProps'
 import {
+  type InternalSlots,
+  type Slots,
+  type SlotsType,
+  type UnwrapSlotsType,
   initSlots,
-  InternalSlots,
-  Slots,
-  SlotsType,
-  UnwrapSlotsType
 } from './componentSlots'
 import { warn } from './warning'
 import { ErrorCodes, callWithErrorHandling, handleError } from './errorHandling'
-import { AppContext, createAppContext, AppConfig } from './apiCreateApp'
-import { Directive, validateDirectiveName } from './directives'
 import {
+  type AppConfig,
+  type AppContext,
+  createAppContext,
+} from './apiCreateApp'
+import { type Directive, validateDirectiveName } from './directives'
+import {
+  type ComponentOptions,
+  type ComputedOptions,
+  type MethodOptions,
   applyOptions,
-  ComponentOptions,
-  ComputedOptions,
-  MethodOptions,
-  resolveMergedOptions
+  resolveMergedOptions,
 } from './componentOptions'
 import {
-  EmitsOptions,
-  ObjectEmitsOptions,
-  EmitFn,
+  type EmitFn,
+  type EmitsOptions,
+  type EmitsToProps,
+  type ObjectEmitsOptions,
+  type ShortEmitsToObject,
   emit,
   normalizeEmitsOptions,
-  EmitsToProps,
-  ShortEmitsToObject
 } from './componentEmits'
 import {
   EMPTY_OBJ,
-  isArray,
-  isFunction,
-  NOOP,
-  isObject,
+  type IfAny,
   NO,
-  makeMap,
-  isPromise,
+  NOOP,
   ShapeFlags,
   extend,
   getGlobalThis,
-  IfAny
+  isArray,
+  isFunction,
+  isObject,
+  isPromise,
+  makeMap,
 } from '@vue/shared'
-import { SuspenseBoundary } from './components/Suspense'
-import { CompilerOptions } from '@vue/compiler-core'
+import type { SuspenseBoundary } from './components/Suspense'
+import type { CompilerOptions } from '@vue/compiler-core'
 import { markAttrsAccessed } from './componentRenderUtils'
 import { currentRenderingInstance } from './componentRenderContext'
-import { startMeasure, endMeasure } from './profiling'
+import { endMeasure, startMeasure } from './profiling'
 import { convertLegacyRenderFn } from './compat/renderFn'
 import {
-  CompatConfig,
+  type CompatConfig,
   globalCompatConfig,
-  validateCompatConfig
+  validateCompatConfig,
 } from './compat/compatConfig'
-import { SchedulerJob } from './scheduler'
-import { LifecycleHooks } from './enums'
+import type { SchedulerJob } from './scheduler'
+import type { LifecycleHooks } from './enums'
 
 export type Data = Record<string, unknown>
 
@@ -163,12 +167,12 @@ export interface FunctionalComponent<
   P = {},
   E extends EmitsOptions | Record<string, any[]> = {},
   S extends Record<string, any> = any,
-  EE extends EmitsOptions = ShortEmitsToObject<E>
+  EE extends EmitsOptions = ShortEmitsToObject<E>,
 > extends ComponentInternalOptions {
   // use of any here is intentional so it can be a valid JSX Element constructor
   (
     props: P & EmitsToProps<EE>,
-    ctx: Omit<SetupContext<EE, IfAny<S, {}, SlotsType<S>>>, 'expose'>
+    ctx: Omit<SetupContext<EE, IfAny<S, {}, SlotsType<S>>>, 'expose'>,
   ): any
   props?: ComponentPropsOptions<P>
   emits?: EE | (keyof EE)[]
@@ -196,7 +200,7 @@ export type ConcreteComponent<
   C extends ComputedOptions = ComputedOptions,
   M extends MethodOptions = MethodOptions,
   E extends EmitsOptions | Record<string, any[]> = {},
-  S extends Record<string, any> = any
+  S extends Record<string, any> = any,
 > =
   | ComponentOptions<Props, RawBindings, D, C, M>
   | FunctionalComponent<Props, E, S>
@@ -212,7 +216,7 @@ export type Component<
   C extends ComputedOptions = ComputedOptions,
   M extends MethodOptions = MethodOptions,
   E extends EmitsOptions | Record<string, any[]> = {},
-  S extends Record<string, any> = any
+  S extends Record<string, any> = any,
 > =
   | ConcreteComponent<Props, RawBindings, D, C, M, E, S>
   | ComponentPublicInstanceConstructor<Props>
@@ -224,7 +228,7 @@ type LifecycleHook<TFn = Function> = TFn[] | null
 // use `E extends any` to force evaluating type to fix #2362
 export type SetupContext<
   E = EmitsOptions,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 > = E extends any
   ? {
       attrs: Data
@@ -245,7 +249,7 @@ export type InternalRenderFunction = {
     $props: ComponentInternalInstance['props'],
     $setup: ComponentInternalInstance['setupState'],
     $data: ComponentInternalInstance['data'],
-    $options: ComponentInternalInstance['ctx']
+    $options: ComponentInternalInstance['ctx'],
   ): VNodeChild
   _rc?: boolean // isRuntimeCompiled
 
@@ -524,7 +528,7 @@ let uid = 0
 export function createComponentInstance(
   vnode: VNode,
   parent: ComponentInternalInstance | null,
-  suspense: SuspenseBoundary | null
+  suspense: SuspenseBoundary | null,
 ) {
   const type = vnode.type as ConcreteComponent
   // inherit parent app context - or - if root, adopt from root vnode
@@ -607,7 +611,7 @@ export function createComponentInstance(
     rtg: null,
     rtc: null,
     ec: null,
-    sp: null
+    sp: null,
   }
   if (__DEV__) {
     instance.ctx = createDevRenderContext(instance)
@@ -631,7 +635,7 @@ export const getCurrentInstance: () => ComponentInternalInstance | null = () =>
   currentInstance || currentRenderingInstance
 
 let internalSetCurrentInstance: (
-  instance: ComponentInternalInstance | null
+  instance: ComponentInternalInstance | null,
 ) => void
 let setInSSRSetupState: (state: boolean) => void
 
@@ -661,7 +665,7 @@ if (__SSR__) {
   }
   internalSetCurrentInstance = registerGlobalSetter(
     `__VUE_INSTANCE_SETTERS__`,
-    v => (currentInstance = v)
+    v => (currentInstance = v),
   )
   // also make `isInSSRComponentSetup` sharable across copies of Vue.
   // this is needed in the SFC playground when SSRing async components, since
@@ -669,7 +673,7 @@ if (__SSR__) {
   // contain duplicated copies of Vue runtime code.
   setInSSRSetupState = registerGlobalSetter(
     `__VUE_SSR_SETTERS__`,
-    v => (isInSSRComponentSetup = v)
+    v => (isInSSRComponentSetup = v),
   )
 } else {
   internalSetCurrentInstance = i => {
@@ -696,7 +700,7 @@ export function validateComponentName(name: string, config: AppConfig) {
   const appIsNativeTag = config.isNativeTag || NO
   if (isBuiltInTag(name) || appIsNativeTag(name)) {
     warn(
-      'Do not use built-in or reserved HTML elements as component id: ' + name
+      'Do not use built-in or reserved HTML elements as component id: ' + name,
     )
   }
 }
@@ -709,7 +713,7 @@ export let isInSSRComponentSetup = false
 
 export function setupComponent(
   instance: ComponentInternalInstance,
-  isSSR = false
+  isSSR = false,
 ) {
   isSSR && setInSSRSetupState(isSSR)
 
@@ -728,7 +732,7 @@ export function setupComponent(
 
 function setupStatefulComponent(
   instance: ComponentInternalInstance,
-  isSSR: boolean
+  isSSR: boolean,
 ) {
   const Component = instance.type as ComponentOptions
 
@@ -752,7 +756,7 @@ function setupStatefulComponent(
       warn(
         `"compilerOptions" is only supported when using a build of Vue that ` +
           `includes the runtime compiler. Since you are using a runtime-only ` +
-          `build, the options should be passed via your build tool config instead.`
+          `build, the options should be passed via your build tool config instead.`,
       )
     }
   }
@@ -776,7 +780,10 @@ function setupStatefulComponent(
       setup,
       instance,
       ErrorCodes.SETUP_FUNCTION,
-      [__DEV__ ? shallowReadonly(instance.props) : instance.props, setupContext]
+      [
+        __DEV__ ? shallowReadonly(instance.props) : instance.props,
+        setupContext,
+      ],
     )
     resetTracking()
     unsetCurrentInstance()
@@ -802,13 +809,13 @@ function setupStatefulComponent(
             `Component <${name}>: setup function returned a promise, but no ` +
               `<Suspense> boundary was found in the parent component tree. ` +
               `A component with async setup() must be nested in a <Suspense> ` +
-              `in order to be rendered.`
+              `in order to be rendered.`,
           )
         }
       } else if (__DEV__) {
         warn(
           `setup() returned a Promise, but the version of Vue you are using ` +
-            `does not support it yet.`
+            `does not support it yet.`,
         )
       }
     } else {
@@ -822,7 +829,7 @@ function setupStatefulComponent(
 export function handleSetupResult(
   instance: ComponentInternalInstance,
   setupResult: unknown,
-  isSSR: boolean
+  isSSR: boolean,
 ) {
   if (isFunction(setupResult)) {
     // setup returned an inline render function
@@ -837,7 +844,7 @@ export function handleSetupResult(
     if (__DEV__ && isVNode(setupResult)) {
       warn(
         `setup() should not return VNodes directly - ` +
-          `return a render function instead.`
+          `return a render function instead.`,
       )
     }
     // setup returned bindings.
@@ -853,7 +860,7 @@ export function handleSetupResult(
     warn(
       `setup() should return an object. Received: ${
         setupResult === null ? 'null' : typeof setupResult
-      }`
+      }`,
     )
   }
   finishComponentSetup(instance, isSSR)
@@ -861,7 +868,7 @@ export function handleSetupResult(
 
 type CompileFunction = (
   template: string | object,
-  options?: CompilerOptions
+  options?: CompilerOptions,
 ) => InternalRenderFunction
 
 let compile: CompileFunction | undefined
@@ -886,7 +893,7 @@ export const isRuntimeOnly = () => !compile
 export function finishComponentSetup(
   instance: ComponentInternalInstance,
   isSSR: boolean,
-  skipOptions?: boolean
+  skipOptions?: boolean,
 ) {
   const Component = instance.type as ComponentOptions
 
@@ -921,11 +928,11 @@ export function finishComponentSetup(
           extend(
             {
               isCustomElement,
-              delimiters
+              delimiters,
             },
-            compilerOptions
+            compilerOptions,
           ),
-          componentCompilerOptions
+          componentCompilerOptions,
         )
         if (__COMPAT__) {
           // pass runtime compat config into the compiler
@@ -978,7 +985,7 @@ export function finishComponentSetup(
               ? ` Use "vue.esm-browser.js" instead.`
               : __GLOBAL__
                 ? ` Use "vue.global.js" instead.`
-                : ``) /* should not happen */
+                : ``) /* should not happen */,
       )
     } else {
       warn(`Component is missing template or render function.`)
@@ -1005,14 +1012,14 @@ function getAttrsProxy(instance: ComponentInternalInstance): Data {
             deleteProperty() {
               warn(`setupContext.attrs is readonly.`)
               return false
-            }
+            },
           }
         : {
             get(target, key: string) {
               track(instance, TrackOpTypes.GET, '$attrs')
               return target[key]
-            }
-          }
+            },
+          },
     ))
   )
 }
@@ -1027,13 +1034,13 @@ function getSlotsProxy(instance: ComponentInternalInstance): Slots {
       get(target, key: string) {
         track(instance, TrackOpTypes.GET, '$slots')
         return target[key]
-      }
+      },
     }))
   )
 }
 
 export function createSetupContext(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): SetupContext {
   const expose: SetupContext['expose'] = exposed => {
     if (__DEV__) {
@@ -1051,7 +1058,7 @@ export function createSetupContext(
         }
         if (exposedType !== 'object') {
           warn(
-            `expose() should be passed a plain object, received ${exposedType}.`
+            `expose() should be passed a plain object, received ${exposedType}.`,
           )
         }
       }
@@ -1072,7 +1079,7 @@ export function createSetupContext(
       get emit() {
         return (event: string, ...args: any[]) => instance.emit(event, ...args)
       },
-      expose
+      expose,
     })
   } else {
     return {
@@ -1081,7 +1088,7 @@ export function createSetupContext(
       },
       slots: instance.slots,
       emit: instance.emit,
-      expose
+      expose,
     }
   }
 }
@@ -1100,7 +1107,7 @@ export function getExposeProxy(instance: ComponentInternalInstance) {
         },
         has(target, key: string) {
           return key in target || key in publicPropertiesMap
-        }
+        },
       }))
     )
   }
@@ -1112,7 +1119,7 @@ const classify = (str: string): string =>
 
 export function getComponentName(
   Component: ConcreteComponent,
-  includeInferred = true
+  includeInferred = true,
 ): string | false | undefined {
   return isFunction(Component)
     ? Component.displayName || Component.name
@@ -1123,7 +1130,7 @@ export function getComponentName(
 export function formatComponentName(
   instance: ComponentInternalInstance | null,
   Component: ConcreteComponent,
-  isRoot = false
+  isRoot = false,
 ): string {
   let name = getComponentName(Component)
   if (!name && Component.__file) {
@@ -1145,7 +1152,7 @@ export function formatComponentName(
     name =
       inferFromRegistry(
         instance.components ||
-          (instance.parent.type as ComponentOptions).components
+          (instance.parent.type as ComponentOptions).components,
       ) || inferFromRegistry(instance.appContext.components)
   }
 
index ebb374d4c89a94f292cfcc8a0cea618ff85599c1..3c0a111aa3e60057b45d2ffabb6e0fc5342efeab 100644 (file)
@@ -1,32 +1,32 @@
 import {
-  camelize,
   EMPTY_OBJ,
-  toHandlerKey,
+  type UnionToIntersection,
+  camelize,
   extend,
   hasOwn,
   hyphenate,
   isArray,
   isFunction,
   isObject,
-  isString,
   isOn,
-  UnionToIntersection,
-  looseToNumber
+  isString,
+  looseToNumber,
+  toHandlerKey,
 } from '@vue/shared'
 import {
-  ComponentInternalInstance,
-  ComponentOptions,
-  ConcreteComponent,
-  formatComponentName
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type ConcreteComponent,
+  formatComponentName,
 } from './component'
-import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling'
+import { ErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
 import { warn } from './warning'
 import { devtoolsComponentEmit } from './devtools'
-import { AppContext } from './apiCreateApp'
+import type { AppContext } from './apiCreateApp'
 import { emit as compatInstanceEmit } from './compat/instanceEventEmitter'
 import {
+  compatModelEmit,
   compatModelEventPrefix,
-  compatModelEmit
 } from './compat/componentVModel'
 
 export type ObjectEmitsOptions = Record<
@@ -62,7 +62,7 @@ export type ShortEmitsToObject<E> = E extends Record<string, any[]>
 
 export type EmitFn<
   Options = ObjectEmitsOptions,
-  Event extends keyof Options = keyof Options
+  Event extends keyof Options = keyof Options,
 > = Options extends Array<infer V>
   ? (event: V, ...args: any[]) => void
   : {} extends Options // if the emit is empty object (usually the default value for emit) should be converted to function
@@ -88,7 +88,7 @@ export function emit(
   if (__DEV__) {
     const {
       emitsOptions,
-      propsOptions: [propsOptions]
+      propsOptions: [propsOptions],
     } = instance
     if (emitsOptions) {
       if (
@@ -102,7 +102,7 @@ export function emit(
         if (!propsOptions || !(toHandlerKey(event) in propsOptions)) {
           warn(
             `Component emitted event "${event}" but it is neither declared in ` +
-              `the emits option nor as an "${toHandlerKey(event)}" prop.`
+              `the emits option nor as an "${toHandlerKey(event)}" prop.`,
           )
         }
       } else {
@@ -111,7 +111,7 @@ export function emit(
           const isValid = validator(...rawArgs)
           if (!isValid) {
             warn(
-              `Invalid event arguments: event validation failed for event "${event}".`
+              `Invalid event arguments: event validation failed for event "${event}".`,
             )
           }
         }
@@ -148,11 +148,13 @@ export function emit(
         `Event "${lowerCaseEvent}" is emitted in component ` +
           `${formatComponentName(
             instance,
-            instance.type
+            instance.type,
           )} but the handler is registered for "${event}". ` +
           `Note that HTML attributes are case-insensitive and you cannot use ` +
           `v-on to listen to camelCase events when using in-DOM templates. ` +
-          `You should probably use "${hyphenate(event)}" instead of "${event}".`
+          `You should probably use "${hyphenate(
+            event,
+          )}" instead of "${event}".`,
       )
     }
   }
@@ -173,7 +175,7 @@ export function emit(
       handler,
       instance,
       ErrorCodes.COMPONENT_EVENT_HANDLER,
-      args
+      args,
     )
   }
 
@@ -189,7 +191,7 @@ export function emit(
       onceHandler,
       instance,
       ErrorCodes.COMPONENT_EVENT_HANDLER,
-      args
+      args,
     )
   }
 
@@ -202,7 +204,7 @@ export function emit(
 export function normalizeEmitsOptions(
   comp: ConcreteComponent,
   appContext: AppContext,
-  asMixin = false
+  asMixin = false,
 ): ObjectEmitsOptions | null {
   const cache = appContext.emitsCache
   const cached = cache.get(comp)
@@ -258,7 +260,7 @@ export function normalizeEmitsOptions(
 // both considered matched listeners.
 export function isEmitListener(
   options: ObjectEmitsOptions | null,
-  key: string
+  key: string,
 ): boolean {
   if (!options || !isOn(key)) {
     return false
index 9633cbfe907199278a381058c1533666ada8b105..65b952b0b51ea84c9dc6739b2edb086e684b840a 100644 (file)
@@ -1,81 +1,81 @@
-import {
+import type {
+  Component,
   ComponentInternalInstance,
-  Data,
-  SetupContext,
   ComponentInternalOptions,
-  Component,
   ConcreteComponent,
-  InternalRenderFunction
+  Data,
+  InternalRenderFunction,
+  SetupContext,
 } from './component'
 import {
-  isFunction,
+  type LooseRequired,
+  NOOP,
+  type Prettify,
   extend,
-  isString,
-  isObject,
   isArray,
-  NOOP,
+  isFunction,
+  isObject,
   isPromise,
-  LooseRequired,
-  Prettify
+  isString,
 } from '@vue/shared'
-import { isRef, Ref } from '@vue/reactivity'
+import { type Ref, isRef } from '@vue/reactivity'
 import { computed } from './apiComputed'
 import {
+  type WatchCallback,
+  type WatchOptions,
+  createPathGetter,
   watch,
-  WatchOptions,
-  WatchCallback,
-  createPathGetter
 } from './apiWatch'
-import { provide, inject } from './apiInject'
+import { inject, provide } from './apiInject'
 import {
+  type DebuggerHook,
+  type ErrorCapturedHook,
+  onActivated,
   onBeforeMount,
-  onMounted,
+  onBeforeUnmount,
   onBeforeUpdate,
-  onUpdated,
+  onDeactivated,
   onErrorCaptured,
+  onMounted,
   onRenderTracked,
-  onBeforeUnmount,
-  onUnmounted,
-  onActivated,
-  onDeactivated,
   onRenderTriggered,
-  DebuggerHook,
-  ErrorCapturedHook,
-  onServerPrefetch
+  onServerPrefetch,
+  onUnmounted,
+  onUpdated,
 } from './apiLifecycle'
 import {
+  type ComputedGetter,
+  type WritableComputedOptions,
   reactive,
-  ComputedGetter,
-  WritableComputedOptions
 } from '@vue/reactivity'
-import {
+import type {
   ComponentObjectPropsOptions,
-  ExtractPropTypes,
+  ComponentPropsOptions,
   ExtractDefaultPropTypes,
-  ComponentPropsOptions
+  ExtractPropTypes,
 } from './componentProps'
-import { EmitsOptions, EmitsToProps } from './componentEmits'
-import { Directive } from './directives'
+import type { EmitsOptions, EmitsToProps } from './componentEmits'
+import type { Directive } from './directives'
 import {
-  CreateComponentPublicInstance,
-  ComponentPublicInstance,
+  type ComponentPublicInstance,
+  type CreateComponentPublicInstance,
+  type IntersectionMixin,
+  type UnwrapMixinsType,
   isReservedPrefix,
-  IntersectionMixin,
-  UnwrapMixinsType
 } from './componentPublicInstance'
 import { warn } from './warning'
-import { VNodeChild } from './vnode'
+import type { VNodeChild } from './vnode'
 import { callWithAsyncErrorHandling } from './errorHandling'
 import { deepMergeData } from './compat/data'
 import { DeprecationTypes } from './compat/compatConfig'
 import {
-  CompatConfig,
+  type CompatConfig,
   isCompatEnabled,
-  softAssertCompatEnabled
+  softAssertCompatEnabled,
 } from './compat/compatConfig'
-import { OptionMergeFunction } from './apiCreateApp'
+import type { OptionMergeFunction } from './apiCreateApp'
 import { LifecycleHooks } from './enums'
-import { SlotsType } from './componentSlots'
+import type { SlotsType } from './componentSlots'
 import { normalizePropsOrEmits } from './apiSetupHelpers'
 
 /**
@@ -111,7 +111,7 @@ export interface ComponentOptionsBase<
   Defaults = {},
   I extends ComponentInjectOptions = {},
   II extends string = string,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 > extends LegacyOptions<Props, D, C, M, Mixin, Extends, I, II>,
     ComponentInternalOptions,
     ComponentCustomOptions {
@@ -126,7 +126,7 @@ export interface ComponentOptionsBase<
           >
         >
     >,
-    ctx: SetupContext<E, S>
+    ctx: SetupContext<E, S>,
   ) => Promise<RawBindings> | RawBindings | RenderFunction | void
   name?: string
   template?: string | object // can be a direct DOM node
@@ -164,7 +164,7 @@ export interface ComponentOptionsBase<
     $props: ComponentInternalInstance['props'],
     $setup: ComponentInternalInstance['setupState'],
     $data: ComponentInternalInstance['data'],
-    $options: ComponentInternalInstance['ctx']
+    $options: ComponentInternalInstance['ctx'],
   ) => void
 
   /**
@@ -224,7 +224,7 @@ export type ComponentOptionsWithoutProps<
   I extends ComponentInjectOptions = {},
   II extends string = string,
   S extends SlotsType = {},
-  PE = Props & EmitsToProps<E>
+  PE = Props & EmitsToProps<E>,
 > = ComponentOptionsBase<
   PE,
   RawBindings,
@@ -272,7 +272,7 @@ export type ComponentOptionsWithArrayProps<
   I extends ComponentInjectOptions = {},
   II extends string = string,
   S extends SlotsType = {},
-  Props = Prettify<Readonly<{ [key in PropNames]?: any } & EmitsToProps<E>>>
+  Props = Prettify<Readonly<{ [key in PropNames]?: any } & EmitsToProps<E>>>,
 > = ComponentOptionsBase<
   Props,
   RawBindings,
@@ -321,7 +321,7 @@ export type ComponentOptionsWithObjectProps<
   II extends string = string,
   S extends SlotsType = {},
   Props = Prettify<Readonly<ExtractPropTypes<PropsOptions> & EmitsToProps<E>>>,
-  Defaults = ExtractDefaultPropTypes<PropsOptions>
+  Defaults = ExtractDefaultPropTypes<PropsOptions>,
 > = ComponentOptionsBase<
   Props,
   RawBindings,
@@ -365,7 +365,7 @@ export type ComponentOptions<
   Mixin extends ComponentOptionsMixin = any,
   Extends extends ComponentOptionsMixin = any,
   E extends EmitsOptions = any,
-  S extends SlotsType = any
+  S extends SlotsType = any,
 > = ComponentOptionsBase<
   Props,
   RawBindings,
@@ -463,7 +463,7 @@ interface LegacyOptions<
   Mixin extends ComponentOptionsMixin,
   Extends extends ComponentOptionsMixin,
   I extends ComponentInjectOptions,
-  II extends string
+  II extends string,
 > {
   compatConfig?: CompatConfig
 
@@ -492,7 +492,7 @@ interface LegacyOptions<
       MethodOptions,
       Mixin,
       Extends
-    >
+    >,
   ) => D
   computed?: C
   methods?: M
@@ -576,7 +576,7 @@ export type OptionTypesType<
   D = {},
   C extends ComputedOptions = {},
   M extends MethodOptions = {},
-  Defaults = {}
+  Defaults = {},
 > = {
   P: P
   B: B
@@ -591,7 +591,7 @@ enum OptionTypes {
   DATA = 'Data',
   COMPUTED = 'Computed',
   METHODS = 'Methods',
-  INJECT = 'Inject'
+  INJECT = 'Inject',
 }
 
 function createDuplicateChecker() {
@@ -652,7 +652,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
     // assets
     components,
     directives,
-    filters
+    filters,
   } = options
 
   const checkDuplicateProperties = __DEV__ ? createDuplicateChecker() : null
@@ -690,7 +690,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
             value: methodHandler.bind(publicThis),
             configurable: true,
             enumerable: true,
-            writable: true
+            writable: true,
           })
         } else {
           ctx[key] = methodHandler.bind(publicThis)
@@ -701,7 +701,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
       } else if (__DEV__) {
         warn(
           `Method "${key}" has type "${typeof methodHandler}" in the component definition. ` +
-            `Did you reference the function correctly?`
+            `Did you reference the function correctly?`,
         )
       }
     }
@@ -711,7 +711,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
     if (__DEV__ && !isFunction(dataOptions)) {
       warn(
         `The data option must be a function. ` +
-          `Plain object usage is no longer supported.`
+          `Plain object usage is no longer supported.`,
       )
     }
     const data = dataOptions.call(publicThis, publicThis)
@@ -719,7 +719,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
       warn(
         `data() returned a Promise - note data() cannot be async; If you ` +
           `intend to perform data fetching before component renders, use ` +
-          `async setup() + <Suspense>.`
+          `async setup() + <Suspense>.`,
       )
     }
     if (!isObject(data)) {
@@ -735,7 +735,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
               configurable: true,
               enumerable: true,
               get: () => data[key],
-              set: NOOP
+              set: NOOP,
             })
           }
         }
@@ -763,19 +763,19 @@ export function applyOptions(instance: ComponentInternalInstance) {
           : __DEV__
             ? () => {
                 warn(
-                  `Write operation failed: computed property "${key}" is readonly.`
+                  `Write operation failed: computed property "${key}" is readonly.`,
                 )
               }
             : NOOP
       const c = computed({
         get,
-        set
+        set,
       })
       Object.defineProperty(ctx, key, {
         enumerable: true,
         configurable: true,
         get: () => c.value,
-        set: v => (c.value = v)
+        set: v => (c.value = v),
       })
       if (__DEV__) {
         checkDuplicateProperties!(OptionTypes.COMPUTED, key)
@@ -804,7 +804,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
 
   function registerLifecycleHook(
     register: Function,
-    hook?: Function | Function[]
+    hook?: Function | Function[],
   ) {
     if (isArray(hook)) {
       hook.forEach(_hook => register(_hook.bind(publicThis)))
@@ -847,7 +847,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
       expose.forEach(key => {
         Object.defineProperty(exposed, key, {
           get: () => publicThis[key],
-          set: val => (publicThis[key] = val)
+          set: val => (publicThis[key] = val),
         })
       })
     } else if (!instance.exposed) {
@@ -879,7 +879,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
 export function resolveInjections(
   injectOptions: ComponentInjectOptions,
   ctx: any,
-  checkDuplicateProperties = NOOP as any
+  checkDuplicateProperties = NOOP as any,
 ) {
   if (isArray(injectOptions)) {
     injectOptions = normalizeInject(injectOptions)!
@@ -892,7 +892,7 @@ export function resolveInjections(
         injected = inject(
           opt.from || key,
           opt.default,
-          true /* treat default function as factory */
+          true /* treat default function as factory */,
         )
       } else {
         injected = inject(opt.from || key)
@@ -906,7 +906,7 @@ export function resolveInjections(
         enumerable: true,
         configurable: true,
         get: () => (injected as Ref).value,
-        set: v => ((injected as Ref).value = v)
+        set: v => ((injected as Ref).value = v),
       })
     } else {
       ctx[key] = injected
@@ -920,14 +920,14 @@ export function resolveInjections(
 function callHook(
   hook: Function,
   instance: ComponentInternalInstance,
-  type: LifecycleHooks
+  type: LifecycleHooks,
 ) {
   callWithAsyncErrorHandling(
     isArray(hook)
       ? hook.map(h => h.bind(instance.proxy!))
       : hook.bind(instance.proxy!),
     instance,
-    type
+    type,
   )
 }
 
@@ -935,7 +935,7 @@ export function createWatcher(
   raw: ComponentWatchOptionItem,
   ctx: Data,
   publicThis: ComponentPublicInstance,
-  key: string
+  key: string,
 ) {
   const getter = key.includes('.')
     ? createPathGetter(publicThis, key)
@@ -973,14 +973,14 @@ export function createWatcher(
  * instances.
  */
 export function resolveMergedOptions(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): MergedComponentOptions {
   const base = instance.type as ComponentOptions
   const { mixins, extends: extendsOptions } = base
   const {
     mixins: globalMixins,
     optionsCache: cache,
-    config: { optionMergeStrategies }
+    config: { optionMergeStrategies },
   } = instance.appContext
   const cached = cache.get(base)
 
@@ -1003,7 +1003,7 @@ export function resolveMergedOptions(
     resolved = {}
     if (globalMixins.length) {
       globalMixins.forEach(m =>
-        mergeOptions(resolved, m, optionMergeStrategies, true)
+        mergeOptions(resolved, m, optionMergeStrategies, true),
       )
     }
     mergeOptions(resolved, base, optionMergeStrategies)
@@ -1018,7 +1018,7 @@ export function mergeOptions(
   to: any,
   from: any,
   strats: Record<string, OptionMergeFunction>,
-  asMixin = false
+  asMixin = false,
 ) {
   if (__COMPAT__ && isFunction(from)) {
     from = from.options
@@ -1031,7 +1031,7 @@ export function mergeOptions(
   }
   if (mixins) {
     mixins.forEach((m: ComponentOptionsMixin) =>
-      mergeOptions(to, m, strats, true)
+      mergeOptions(to, m, strats, true),
     )
   }
 
@@ -1040,7 +1040,7 @@ export function mergeOptions(
       __DEV__ &&
         warn(
           `"expose" option is ignored when declared in mixins or extends. ` +
-            `It should only be declared in the base component itself.`
+            `It should only be declared in the base component itself.`,
         )
     } else {
       const strat = internalOptionMergeStrats[key] || (strats && strats[key])
@@ -1079,7 +1079,7 @@ export const internalOptionMergeStrats: Record<string, Function> = {
   watch: mergeWatchOptions,
   // provide / inject
   provide: mergeDataFn,
-  inject: mergeInject
+  inject: mergeInject,
 }
 
 if (__COMPAT__) {
@@ -1100,20 +1100,20 @@ function mergeDataFn(to: any, from: any) {
         : extend
     )(
       isFunction(to) ? to.call(this, this) : to,
-      isFunction(from) ? from.call(this, this) : from
+      isFunction(from) ? from.call(this, this) : from,
     )
   }
 }
 
 function mergeInject(
   to: ComponentInjectOptions | undefined,
-  from: ComponentInjectOptions
+  from: ComponentInjectOptions,
 ) {
   return mergeObjectOptions(normalizeInject(to), normalizeInject(from))
 }
 
 function normalizeInject(
-  raw: ComponentInjectOptions | undefined
+  raw: ComponentInjectOptions | undefined,
 ): ObjectInjectOptions | undefined {
   if (isArray(raw)) {
     const res: ObjectInjectOptions = {}
@@ -1135,15 +1135,15 @@ function mergeObjectOptions(to: Object | undefined, from: Object | undefined) {
 
 function mergeEmitsOrPropsOptions(
   to: EmitsOptions | undefined,
-  from: EmitsOptions | undefined
+  from: EmitsOptions | undefined,
 ): EmitsOptions | undefined
 function mergeEmitsOrPropsOptions(
   to: ComponentPropsOptions | undefined,
-  from: ComponentPropsOptions | undefined
+  from: ComponentPropsOptions | undefined,
 ): ComponentPropsOptions | undefined
 function mergeEmitsOrPropsOptions(
   to: ComponentPropsOptions | EmitsOptions | undefined,
-  from: ComponentPropsOptions | EmitsOptions | undefined
+  from: ComponentPropsOptions | EmitsOptions | undefined,
 ) {
   if (to) {
     if (isArray(to) && isArray(from)) {
@@ -1152,7 +1152,7 @@ function mergeEmitsOrPropsOptions(
     return extend(
       Object.create(null),
       normalizePropsOrEmits(to),
-      normalizePropsOrEmits(from ?? {})
+      normalizePropsOrEmits(from ?? {}),
     )
   } else {
     return from
@@ -1161,7 +1161,7 @@ function mergeEmitsOrPropsOptions(
 
 function mergeWatchOptions(
   to: ComponentWatchOptions | undefined,
-  from: ComponentWatchOptions | undefined
+  from: ComponentWatchOptions | undefined,
 ) {
   if (!to) return from
   if (!from) return to
index 4b7be8a8e73b9787cf36cb82d7706ee834fb3ae1..2124853f1238f305957071c95437c04e81e94ef1 100644 (file)
@@ -1,42 +1,42 @@
 import {
-  toRaw,
+  TriggerOpTypes,
   shallowReactive,
+  shallowReadonly,
+  toRaw,
   trigger,
-  TriggerOpTypes,
-  shallowReadonly
 } from '@vue/reactivity'
 import {
+  EMPTY_ARR,
   EMPTY_OBJ,
+  type IfAny,
+  PatchFlags,
   camelize,
-  hyphenate,
   capitalize,
-  isString,
-  isFunction,
-  isArray,
-  isObject,
-  hasOwn,
-  toRawType,
-  PatchFlags,
-  makeMap,
-  isReservedProp,
-  EMPTY_ARR,
   def,
   extend,
+  hasOwn,
+  hyphenate,
+  isArray,
+  isFunction,
+  isObject,
   isOn,
-  IfAny
+  isReservedProp,
+  isString,
+  makeMap,
+  toRawType,
 } from '@vue/shared'
 import { warn } from './warning'
 import {
-  Data,
-  ComponentInternalInstance,
-  ComponentOptions,
-  ConcreteComponent,
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type ConcreteComponent,
+  type Data,
   setCurrentInstance,
-  unsetCurrentInstance
+  unsetCurrentInstance,
 } from './component'
 import { isEmitListener } from './componentEmits'
 import { InternalObjectKey } from './vnode'
-import { AppContext } from './apiCreateApp'
+import type { AppContext } from './apiCreateApp'
 import { createPropsDefaultThis } from './compat/props'
 import { isCompatEnabled, softAssertCompatEnabled } from './compat/compatConfig'
 import { DeprecationTypes } from './compat/compatConfig'
@@ -77,7 +77,7 @@ type PropConstructor<T = any> =
   | PropMethod<T>
 
 type PropMethod<T, TConstructor = any> = [T] extends [
-  ((...args: any) => any) | undefined
+  ((...args: any) => any) | undefined,
 ] // if is function with args, allowing non-required functions
   ? { new (): TConstructor; (): T; readonly prototype: TConstructor } // Create Function like constructor
   : never
@@ -167,7 +167,7 @@ export type ExtractPublicPropTypes<O> = {
 
 enum BooleanFlags {
   shouldCast,
-  shouldCastTrue
+  shouldCastTrue,
 }
 
 // extract props which defined with default from prop options
@@ -192,7 +192,7 @@ export function initProps(
   instance: ComponentInternalInstance,
   rawProps: Data | null,
   isStateful: number, // result of bitwise flag comparison
-  isSSR = false
+  isSSR = false,
 ) {
   const props: Data = {}
   const attrs: Data = {}
@@ -240,12 +240,12 @@ export function updateProps(
   instance: ComponentInternalInstance,
   rawProps: Data | null,
   rawPrevProps: Data | null,
-  optimized: boolean
+  optimized: boolean,
 ) {
   const {
     props,
     attrs,
-    vnode: { patchFlag }
+    vnode: { patchFlag },
   } = instance
   const rawCurrentProps = toRaw(props)
   const [options] = instance.propsOptions
@@ -287,7 +287,7 @@ export function updateProps(
               camelizedKey,
               value,
               instance,
-              false /* isAbsent */
+              false /* isAbsent */,
             )
           }
         } else {
@@ -336,7 +336,7 @@ export function updateProps(
               key,
               undefined,
               instance,
-              true /* isAbsent */
+              true /* isAbsent */,
             )
           }
         } else {
@@ -374,7 +374,7 @@ function setFullProps(
   instance: ComponentInternalInstance,
   rawProps: Data | null,
   props: Data,
-  attrs: Data
+  attrs: Data,
 ) {
   const [options, needCastKeys] = instance.propsOptions
   let hasAttrsChanged = false
@@ -391,7 +391,7 @@ function setFullProps(
           softAssertCompatEnabled(
             DeprecationTypes.INSTANCE_EVENT_HOOKS,
             instance,
-            key.slice(2).toLowerCase()
+            key.slice(2).toLowerCase(),
           )
         }
         if (key === 'inline-template') {
@@ -439,7 +439,7 @@ function setFullProps(
         key,
         castValues[key],
         instance,
-        !hasOwn(castValues, key)
+        !hasOwn(castValues, key),
       )
     }
   }
@@ -453,7 +453,7 @@ function resolvePropValue(
   key: string,
   value: unknown,
   instance: ComponentInternalInstance,
-  isAbsent: boolean
+  isAbsent: boolean,
 ) {
   const opt = options[key]
   if (opt != null) {
@@ -476,7 +476,7 @@ function resolvePropValue(
               isCompatEnabled(DeprecationTypes.PROPS_DEFAULT_THIS, instance)
               ? createPropsDefaultThis(instance, props, key)
               : null,
-            props
+            props,
           )
           unsetCurrentInstance()
         }
@@ -502,7 +502,7 @@ function resolvePropValue(
 export function normalizePropsOptions(
   comp: ConcreteComponent,
   appContext: AppContext,
-  asMixin = false
+  asMixin = false,
 ): NormalizedPropsOptions {
   const cache = appContext.propsCache
   const cached = cache.get(comp)
@@ -608,7 +608,7 @@ function isSameType(a: Prop<any>, b: Prop<any>): boolean {
 
 function getTypeIndex(
   type: Prop<any>,
-  expectedTypes: PropType<any> | void | null | true
+  expectedTypes: PropType<any> | void | null | true,
 ): number {
   if (isArray(expectedTypes)) {
     return expectedTypes.findIndex(t => isSameType(t, type))
@@ -624,7 +624,7 @@ function getTypeIndex(
 function validateProps(
   rawProps: Data,
   props: Data,
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ) {
   const resolvedValues = toRaw(props)
   const options = instance.propsOptions[0]
@@ -636,7 +636,7 @@ function validateProps(
       resolvedValues[key],
       opt,
       __DEV__ ? shallowReadonly(resolvedValues) : resolvedValues,
-      !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key))
+      !hasOwn(rawProps, key) && !hasOwn(rawProps, hyphenate(key)),
     )
   }
 }
@@ -649,7 +649,7 @@ function validateProp(
   value: unknown,
   prop: PropOptions,
   props: Data,
-  isAbsent: boolean
+  isAbsent: boolean,
 ) {
   const { type, required, validator, skipCheck } = prop
   // required!
@@ -684,7 +684,7 @@ function validateProp(
 }
 
 const isSimpleType = /*#__PURE__*/ makeMap(
-  'String,Number,Boolean,Function,Symbol,BigInt'
+  'String,Number,Boolean,Function,Symbol,BigInt',
 )
 
 type AssertionResult = {
@@ -716,7 +716,7 @@ function assertType(value: unknown, type: PropConstructor): AssertionResult {
   }
   return {
     valid,
-    expectedType
+    expectedType,
   }
 }
 
@@ -726,7 +726,7 @@ function assertType(value: unknown, type: PropConstructor): AssertionResult {
 function getInvalidTypeMessage(
   name: string,
   value: unknown,
-  expectedTypes: string[]
+  expectedTypes: string[],
 ): string {
   if (expectedTypes.length === 0) {
     return (
index 06e9965094bca20bacfdae83f751a8379769dacd..8cefecc7aea0352f7f3e87b24efa1173a739bc8a 100644 (file)
@@ -1,47 +1,51 @@
 import {
-  ComponentInternalInstance,
-  Data,
+  type ComponentInternalInstance,
+  type Data,
   getExposeProxy,
-  isStatefulComponent
+  isStatefulComponent,
 } from './component'
 import { nextTick, queueJob } from './scheduler'
-import { instanceWatch, WatchOptions, WatchStopHandle } from './apiWatch'
+import {
+  type WatchOptions,
+  type WatchStopHandle,
+  instanceWatch,
+} from './apiWatch'
 import {
   EMPTY_OBJ,
-  hasOwn,
-  isGloballyAllowed,
+  type IfAny,
   NOOP,
+  type Prettify,
+  type UnionToIntersection,
   extend,
-  isString,
+  hasOwn,
   isFunction,
-  UnionToIntersection,
-  Prettify,
-  IfAny
+  isGloballyAllowed,
+  isString,
 } from '@vue/shared'
 import {
-  toRaw,
+  type ShallowUnwrapRef,
+  TrackOpTypes,
+  type UnwrapNestedRefs,
   shallowReadonly,
+  toRaw,
   track,
-  TrackOpTypes,
-  ShallowUnwrapRef,
-  UnwrapNestedRefs
 } from '@vue/reactivity'
 import {
-  ExtractComputedReturns,
-  ComponentOptionsBase,
-  ComputedOptions,
-  MethodOptions,
-  ComponentOptionsMixin,
-  OptionTypesType,
-  OptionTypesKeys,
+  type ComponentInjectOptions,
+  type ComponentOptionsBase,
+  type ComponentOptionsMixin,
+  type ComputedOptions,
+  type ExtractComputedReturns,
+  type InjectToObject,
+  type MergedComponentOptionsOverride,
+  type MethodOptions,
+  type OptionTypesKeys,
+  type OptionTypesType,
   resolveMergedOptions,
   shouldCacheAccess,
-  MergedComponentOptionsOverride,
-  InjectToObject,
-  ComponentInjectOptions
 } from './componentOptions'
-import { EmitsOptions, EmitFn } from './componentEmits'
-import { SlotsType, UnwrapSlotsType } from './componentSlots'
+import type { EmitFn, EmitsOptions } from './componentEmits'
+import type { SlotsType, UnwrapSlotsType } from './componentSlots'
 import { markAttrsAccessed } from './componentRenderUtils'
 import { currentRenderingInstance } from './componentRenderContext'
 import { warn } from './warning'
@@ -111,7 +115,7 @@ export type IntersectionMixin<T> = IsDefaultMixinComponent<T> extends true
 
 export type UnwrapMixinsType<
   T,
-  Type extends OptionTypesKeys
+  Type extends OptionTypesKeys,
 > = T extends OptionTypesType ? T[Type] : never
 
 type EnsureNonVoid<T> = T extends void ? {} : T
@@ -128,7 +132,7 @@ export type ComponentPublicInstanceConstructor<
   RawBindings = any,
   D = any,
   C extends ComputedOptions = ComputedOptions,
-  M extends MethodOptions = MethodOptions
+  M extends MethodOptions = MethodOptions,
 > = {
   __isFragment?: never
   __isTeleport?: never
@@ -159,7 +163,7 @@ export type CreateComponentPublicInstance<
   PublicM extends MethodOptions = UnwrapMixinsType<PublicMixin, 'M'> &
     EnsureNonVoid<M>,
   PublicDefaults = UnwrapMixinsType<PublicMixin, 'Defaults'> &
-    EnsureNonVoid<Defaults>
+    EnsureNonVoid<Defaults>,
 > = ComponentPublicInstance<
   PublicP,
   PublicB,
@@ -202,7 +206,7 @@ export type ComponentPublicInstance<
   MakeDefaultsOptional extends boolean = false,
   Options = ComponentOptionsBase<any, any, any, any, any, any, any, any, any>,
   I extends ComponentInjectOptions = {},
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 > = {
   $: ComponentInternalInstance
   $data: D
@@ -224,7 +228,7 @@ export type ComponentPublicInstance<
     cb: T extends (...args: any) => infer R
       ? (...args: [R, R]) => any
       : (...args: any) => any,
-    options?: WatchOptions
+    options?: WatchOptions,
   ): WatchStopHandle
 } & IfAny<P, P, Omit<P, keyof ShallowUnwrapRef<B>>> &
   ShallowUnwrapRef<B> &
@@ -245,7 +249,7 @@ export type PublicPropertiesMap = Record<
  * public $parent chains, skip functional ones and go to the parent instead.
  */
 const getPublicInstance = (
-  i: ComponentInternalInstance | null
+  i: ComponentInternalInstance | null,
 ): ComponentPublicInstance | ComponentInternalInstance['exposed'] | null => {
   if (!i) return null
   if (isStatefulComponent(i)) return getExposeProxy(i) || i.proxy
@@ -274,7 +278,7 @@ export const publicPropertiesMap: PublicPropertiesMap =
         queueJob(i.update)
       }),
     $nextTick: i => i.n || (i.n = nextTick.bind(i.proxy!)),
-    $watch: i => (__FEATURE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP)
+    $watch: i => (__FEATURE_OPTIONS_API__ ? instanceWatch.bind(i) : NOOP),
   } as PublicPropertiesMap)
 
 if (__COMPAT__) {
@@ -286,7 +290,7 @@ enum AccessTypes {
   SETUP,
   DATA,
   PROPS,
-  CONTEXT
+  CONTEXT,
 }
 
 export interface ComponentRenderContext {
@@ -402,14 +406,14 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
       if (data !== EMPTY_OBJ && isReservedPrefix(key[0]) && hasOwn(data, key)) {
         warn(
           `Property ${JSON.stringify(
-            key
+            key,
           )} must be accessed via $data because it starts with a reserved ` +
-            `character ("$" or "_") and is not proxied on the render context.`
+            `character ("$" or "_") and is not proxied on the render context.`,
         )
       } else if (instance === currentRenderingInstance) {
         warn(
           `Property ${JSON.stringify(key)} was accessed during render ` +
-            `but is not defined on instance.`
+            `but is not defined on instance.`,
         )
       }
     }
@@ -418,7 +422,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
   set(
     { _: instance }: ComponentRenderContext,
     key: string,
-    value: any
+    value: any,
   ): boolean {
     const { data, setupState, ctx } = instance
     if (hasSetupBinding(setupState, key)) {
@@ -442,7 +446,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
       __DEV__ &&
         warn(
           `Attempting to mutate public property "${key}". ` +
-            `Properties starting with $ are reserved and readonly.`
+            `Properties starting with $ are reserved and readonly.`,
         )
       return false
     } else {
@@ -450,7 +454,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
         Object.defineProperty(ctx, key, {
           enumerable: true,
           configurable: true,
-          value
+          value,
         })
       } else {
         ctx[key] = value
@@ -461,9 +465,9 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
 
   has(
     {
-      _: { data, setupState, accessCache, ctx, appContext, propsOptions }
+      _: { data, setupState, accessCache, ctx, appContext, propsOptions },
     }: ComponentRenderContext,
-    key: string
+    key: string,
   ) {
     let normalizedProps
     return (
@@ -480,7 +484,7 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
   defineProperty(
     target: ComponentRenderContext,
     key: string,
-    descriptor: PropertyDescriptor
+    descriptor: PropertyDescriptor,
   ) {
     if (descriptor.get != null) {
       // invalidate key cache of a getter based property #5417
@@ -489,14 +493,14 @@ export const PublicInstanceProxyHandlers: ProxyHandler<any> = {
       this.set!(target, key, descriptor.value, null)
     }
     return Reflect.defineProperty(target, key, descriptor)
-  }
+  },
 }
 
 if (__DEV__ && !__TEST__) {
   PublicInstanceProxyHandlers.ownKeys = (target: ComponentRenderContext) => {
     warn(
       `Avoid app logic that relies on enumerating keys on a component instance. ` +
-        `The keys will be empty in production mode to avoid performance overhead.`
+        `The keys will be empty in production mode to avoid performance overhead.`,
     )
     return Reflect.ownKeys(target)
   }
@@ -518,13 +522,13 @@ export const RuntimeCompiledPublicInstanceProxyHandlers = /*#__PURE__*/ extend(
       if (__DEV__ && !has && PublicInstanceProxyHandlers.has!(_, key)) {
         warn(
           `Property ${JSON.stringify(
-            key
-          )} should not start with _ which is a reserved prefix for Vue internals.`
+            key,
+          )} should not start with _ which is a reserved prefix for Vue internals.`,
         )
       }
       return has
-    }
-  }
+    },
+  },
 )
 
 // dev only
@@ -538,7 +542,7 @@ export function createDevRenderContext(instance: ComponentInternalInstance) {
   Object.defineProperty(target, `_`, {
     configurable: true,
     enumerable: false,
-    get: () => instance
+    get: () => instance,
   })
 
   // expose public properties
@@ -549,7 +553,7 @@ export function createDevRenderContext(instance: ComponentInternalInstance) {
       get: () => publicPropertiesMap[key](instance),
       // intercepted by the proxy so no need for implementation,
       // but needed to prevent set errors
-      set: NOOP
+      set: NOOP,
     })
   })
 
@@ -558,11 +562,11 @@ export function createDevRenderContext(instance: ComponentInternalInstance) {
 
 // dev only
 export function exposePropsOnRenderContext(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ) {
   const {
     ctx,
-    propsOptions: [propsOptions]
+    propsOptions: [propsOptions],
   } = instance
   if (propsOptions) {
     Object.keys(propsOptions).forEach(key => {
@@ -570,7 +574,7 @@ export function exposePropsOnRenderContext(
         enumerable: true,
         configurable: true,
         get: () => instance.props[key],
-        set: NOOP
+        set: NOOP,
       })
     })
   }
@@ -578,7 +582,7 @@ export function exposePropsOnRenderContext(
 
 // dev only
 export function exposeSetupStateOnRenderContext(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ) {
   const { ctx, setupState } = instance
   Object.keys(toRaw(setupState)).forEach(key => {
@@ -586,9 +590,9 @@ export function exposeSetupStateOnRenderContext(
       if (isReservedPrefix(key[0])) {
         warn(
           `setup() return property ${JSON.stringify(
-            key
+            key,
           )} should not start with "$" or "_" ` +
-            `which are reserved prefixes for Vue internals.`
+            `which are reserved prefixes for Vue internals.`,
         )
         return
       }
@@ -596,7 +600,7 @@ export function exposeSetupStateOnRenderContext(
         enumerable: true,
         configurable: true,
         get: () => setupState[key],
-        set: NOOP
+        set: NOOP,
       })
     }
   })
index 8097dc5fe2b89622298f30c72abfdfafc572e06a..d950e89980819c0cc4b9617727b4ddad62b6c41b 100644 (file)
@@ -1,4 +1,4 @@
-import { ComponentInternalInstance } from './component'
+import type { ComponentInternalInstance } from './component'
 import { devtoolsComponentUpdated } from './devtools'
 import { setBlockTracking } from './vnode'
 
@@ -20,7 +20,7 @@ export let currentScopeId: string | null = null
  * ```
  */
 export function setCurrentRenderingInstance(
-  instance: ComponentInternalInstance | null
+  instance: ComponentInternalInstance | null,
 ): ComponentInternalInstance | null {
   const prev = currentRenderingInstance
   currentRenderingInstance = instance
@@ -70,7 +70,7 @@ export type ContextualRenderFn = {
 export function withCtx(
   fn: Function,
   ctx: ComponentInternalInstance | null = currentRenderingInstance,
-  isNonScopedSlot?: boolean // __COMPAT__ only
+  isNonScopedSlot?: boolean, // __COMPAT__ only
 ) {
   if (!ctx) return fn
 
index 2be51a227438f88df45f3b14e99ddde94c899f86..e07a31ee2023430f7e01211cddd986931016e96f 100644 (file)
@@ -1,30 +1,30 @@
 import {
-  ComponentInternalInstance,
-  FunctionalComponent,
-  Data,
-  getComponentName
+  type ComponentInternalInstance,
+  type Data,
+  type FunctionalComponent,
+  getComponentName,
 } from './component'
 import {
-  VNode,
-  normalizeVNode,
-  createVNode,
   Comment,
+  type VNode,
+  type VNodeArrayChildren,
+  blockStack,
   cloneVNode,
-  VNodeArrayChildren,
+  createVNode,
   isVNode,
-  blockStack
+  normalizeVNode,
 } from './vnode'
-import { handleError, ErrorCodes } from './errorHandling'
-import { PatchFlags, ShapeFlags, isOn, isModelListener } from '@vue/shared'
+import { ErrorCodes, handleError } from './errorHandling'
+import { PatchFlags, ShapeFlags, isModelListener, isOn } from '@vue/shared'
 import { warn } from './warning'
 import { isHmrUpdating } from './hmr'
-import { NormalizedProps } from './componentProps'
+import type { NormalizedProps } from './componentProps'
 import { isEmitListener } from './componentEmits'
 import { setCurrentRenderingInstance } from './componentRenderContext'
 import {
   DeprecationTypes,
   isCompatEnabled,
-  warnDeprecation
+  warnDeprecation,
 } from './compat/compatConfig'
 
 /**
@@ -41,7 +41,7 @@ export function markAttrsAccessed() {
 type SetRootFn = ((root: VNode) => void) | undefined
 
 export function renderComponentRoot(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): VNode {
   const {
     type: Component,
@@ -58,7 +58,7 @@ export function renderComponentRoot(
     data,
     setupState,
     ctx,
-    inheritAttrs
+    inheritAttrs,
   } = instance
 
   let result
@@ -81,11 +81,11 @@ export function renderComponentRoot(
               get(target, key, receiver) {
                 warn(
                   `Property '${String(
-                    key
-                  )}' was accessed via 'this'. Avoid using 'this' in templates.`
+                    key,
+                  )}' was accessed via 'this'. Avoid using 'this' in templates.`,
                 )
                 return Reflect.get(target, key, receiver)
-              }
+              },
             })
           : proxyToUse
       result = normalizeVNode(
@@ -96,8 +96,8 @@ export function renderComponentRoot(
           props,
           setupState,
           data,
-          ctx
-        )
+          ctx,
+        ),
       )
       fallthroughAttrs = attrs
     } else {
@@ -118,11 +118,11 @@ export function renderComponentRoot(
                       return attrs
                     },
                     slots,
-                    emit
+                    emit,
                   }
-                : { attrs, slots, emit }
+                : { attrs, slots, emit },
             )
-          : render(props, null as any /* we know it doesn't need it */)
+          : render(props, null as any /* we know it doesn't need it */),
       )
       fallthroughAttrs = Component.props
         ? attrs
@@ -159,7 +159,7 @@ export function renderComponentRoot(
           // related: #1543, #1643, #1989
           fallthroughAttrs = filterModelListeners(
             fallthroughAttrs,
-            propsOptions
+            propsOptions,
           )
         }
         root = cloneVNode(root, fallthroughAttrs)
@@ -185,7 +185,7 @@ export function renderComponentRoot(
             `Extraneous non-props attributes (` +
               `${extraAttrs.join(', ')}) ` +
               `were passed to component but could not be automatically inherited ` +
-              `because component renders fragment or text root nodes.`
+              `because component renders fragment or text root nodes.`,
           )
         }
         if (eventAttrs.length) {
@@ -195,7 +195,7 @@ export function renderComponentRoot(
               `were passed to component but could not be automatically inherited ` +
               `because component renders fragment or text root nodes. ` +
               `If the listener is intended to be a component custom event listener only, ` +
-              `declare it using the "emits" option.`
+              `declare it using the "emits" option.`,
           )
         }
       }
@@ -214,12 +214,12 @@ export function renderComponentRoot(
         warnDeprecation(
           DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE,
           instance,
-          getComponentName(instance.type)
+          getComponentName(instance.type),
         )
       }
       root = cloneVNode(root, {
         class: cls,
-        style: style
+        style: style,
       })
     }
   }
@@ -229,7 +229,7 @@ export function renderComponentRoot(
     if (__DEV__ && !isElementRoot(root)) {
       warn(
         `Runtime directive used on component with non-element root node. ` +
-          `The directives will not function as intended.`
+          `The directives will not function as intended.`,
       )
     }
     // clone before mutating since the root may be a hoisted vnode
@@ -241,7 +241,7 @@ export function renderComponentRoot(
     if (__DEV__ && !isElementRoot(root)) {
       warn(
         `Component inside <Transition> renders non-element root node ` +
-          `that cannot be animated.`
+          `that cannot be animated.`,
       )
     }
     root.transition = vnode.transition
@@ -286,7 +286,7 @@ const getChildRoot = (vnode: VNode): [VNode, SetRootFn] => {
 }
 
 export function filterSingleRoot(
-  children: VNodeArrayChildren
+  children: VNodeArrayChildren,
 ): VNode | undefined {
   let singleRoot
   for (let i = 0; i < children.length; i++) {
@@ -338,7 +338,7 @@ const isElementRoot = (vnode: VNode) => {
 export function shouldUpdateComponent(
   prevVNode: VNode,
   nextVNode: VNode,
-  optimized?: boolean
+  optimized?: boolean,
 ): boolean {
   const { props: prevProps, children: prevChildren, component } = prevVNode
   const { props: nextProps, children: nextChildren, patchFlag } = nextVNode
@@ -406,7 +406,7 @@ export function shouldUpdateComponent(
 function hasPropsChanged(
   prevProps: Data,
   nextProps: Data,
-  emitsOptions: ComponentInternalInstance['emitsOptions']
+  emitsOptions: ComponentInternalInstance['emitsOptions'],
 ): boolean {
   const nextKeys = Object.keys(nextProps)
   if (nextKeys.length !== Object.keys(prevProps).length) {
@@ -426,7 +426,7 @@ function hasPropsChanged(
 
 export function updateHOCHostEl(
   { vnode, parent }: ComponentInternalInstance,
-  el: typeof vnode.el // HostNode
+  el: typeof vnode.el, // HostNode
 ) {
   if (!el) return
   while (parent) {
index 99936f49dec0347891ad73c25ee34097ad9ea553..3214f8cb455738822346e6d144a9cf773c85c6f2 100644 (file)
@@ -1,25 +1,25 @@
-import { ComponentInternalInstance, currentInstance } from './component'
+import { type ComponentInternalInstance, currentInstance } from './component'
 import {
-  VNode,
-  VNodeNormalizedChildren,
+  InternalObjectKey,
+  type VNode,
+  type VNodeChild,
+  type VNodeNormalizedChildren,
   normalizeVNode,
-  VNodeChild,
-  InternalObjectKey
 } from './vnode'
 import {
-  isArray,
-  isFunction,
   EMPTY_OBJ,
+  type IfAny,
+  type Prettify,
   ShapeFlags,
-  extend,
-  def,
   SlotFlags,
-  Prettify,
-  IfAny
+  def,
+  extend,
+  isArray,
+  isFunction,
 } from '@vue/shared'
 import { warn } from './warning'
 import { isKeepAlive } from './components/KeepAlive'
-import { ContextualRenderFn, withCtx } from './componentRenderContext'
+import { type ContextualRenderFn, withCtx } from './componentRenderContext'
 import { isHmrUpdating } from './hmr'
 import { DeprecationTypes, isCompatEnabled } from './compat/compatConfig'
 import { toRaw } from '@vue/reactivity'
@@ -43,12 +43,12 @@ export type SlotsType<T extends Record<string, any> = Record<string, any>> = {
 
 export type StrictUnwrapSlotsType<
   S extends SlotsType,
-  T = NonNullable<S[typeof SlotSymbol]>
+  T = NonNullable<S[typeof SlotSymbol]>,
 > = [keyof S] extends [never] ? Slots : Readonly<T> & T
 
 export type UnwrapSlotsType<
   S extends SlotsType,
-  T = NonNullable<S[typeof SlotSymbol]>
+  T = NonNullable<S[typeof SlotSymbol]>,
 > = [keyof S] extends [never]
   ? Slots
   : Readonly<
@@ -90,7 +90,7 @@ const normalizeSlotValue = (value: unknown): VNode[] =>
 const normalizeSlot = (
   key: string,
   rawSlot: Function,
-  ctx: ComponentInternalInstance | null | undefined
+  ctx: ComponentInternalInstance | null | undefined,
 ): Slot => {
   if ((rawSlot as any)._n) {
     // already normalized - #5353
@@ -101,7 +101,7 @@ const normalizeSlot = (
       warn(
         `Slot "${key}" invoked outside of the render function: ` +
           `this will not track dependencies used in the slot. ` +
-          `Invoke the slot function inside the render function instead.`
+          `Invoke the slot function inside the render function instead.`,
       )
     }
     return normalizeSlotValue(rawSlot(...args))
@@ -114,7 +114,7 @@ const normalizeSlot = (
 const normalizeObjectSlots = (
   rawSlots: RawSlots,
   slots: InternalSlots,
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ) => {
   const ctx = rawSlots._ctx
   for (const key in rawSlots) {
@@ -132,7 +132,7 @@ const normalizeObjectSlots = (
       ) {
         warn(
           `Non-function value encountered for slot "${key}". ` +
-            `Prefer function slots for better performance.`
+            `Prefer function slots for better performance.`,
         )
       }
       const normalized = normalizeSlotValue(value)
@@ -143,7 +143,7 @@ const normalizeObjectSlots = (
 
 const normalizeVNodeSlots = (
   instance: ComponentInternalInstance,
-  children: VNodeNormalizedChildren
+  children: VNodeNormalizedChildren,
 ) => {
   if (
     __DEV__ &&
@@ -152,7 +152,7 @@ const normalizeVNodeSlots = (
   ) {
     warn(
       `Non-function value encountered for default slot. ` +
-        `Prefer function slots for better performance.`
+        `Prefer function slots for better performance.`,
     )
   }
   const normalized = normalizeSlotValue(children)
@@ -161,7 +161,7 @@ const normalizeVNodeSlots = (
 
 export const initSlots = (
   instance: ComponentInternalInstance,
-  children: VNodeNormalizedChildren
+  children: VNodeNormalizedChildren,
 ) => {
   if (instance.vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN) {
     const type = (children as RawSlots)._
@@ -175,7 +175,7 @@ export const initSlots = (
       normalizeObjectSlots(
         children as RawSlots,
         (instance.slots = {}),
-        instance
+        instance,
       )
     }
   } else {
@@ -190,7 +190,7 @@ export const initSlots = (
 export const updateSlots = (
   instance: ComponentInternalInstance,
   children: VNodeNormalizedChildren,
-  optimized: boolean
+  optimized: boolean,
 ) => {
   const { vnode, slots } = instance
   let needDeletionCheck = true
index ecc0c1af22b40f3bb8319ab9fa2d0bcc2a117940..20da25848b61aeb5b076a2257ba6dc60a69d98dd 100644 (file)
@@ -1,24 +1,24 @@
 import {
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type SetupContext,
   getCurrentInstance,
-  SetupContext,
-  ComponentInternalInstance,
-  ComponentOptions
 } from '../component'
 import {
-  cloneVNode,
   Comment,
+  Fragment,
+  type VNode,
+  type VNodeArrayChildren,
+  cloneVNode,
   isSameVNodeType,
-  VNode,
-  VNodeArrayChildren,
-  Fragment
 } from '../vnode'
 import { warn } from '../warning'
 import { isKeepAlive } from './KeepAlive'
 import { toRaw } from '@vue/reactivity'
-import { callWithAsyncErrorHandling, ErrorCodes } from '../errorHandling'
-import { ShapeFlags, PatchFlags, isArray } from '@vue/shared'
+import { ErrorCodes, callWithAsyncErrorHandling } from '../errorHandling'
+import { PatchFlags, ShapeFlags, isArray } from '@vue/shared'
 import { onBeforeUnmount, onMounted } from '../apiLifecycle'
-import { RendererElement } from '../renderer'
+import type { RendererElement } from '../renderer'
 
 type Hook<T = () => void> = T | T[]
 
@@ -67,14 +67,14 @@ export interface TransitionHooks<HostElement = RendererElement> {
   delayLeave?(
     el: HostElement,
     earlyRemove: () => void,
-    delayedLeave: () => void
+    delayedLeave: () => void,
   ): void
   delayedLeave?(): void
 }
 
 export type TransitionHookCaller = <T extends any[] = [el: any]>(
   hook: Hook<(...args: T) => void> | undefined,
-  args?: T
+  args?: T,
 ) => void
 
 export type PendingCallback = (cancelled?: boolean) => void
@@ -101,7 +101,7 @@ export function useTransitionState(): TransitionState {
     isMounted: false,
     isLeaving: false,
     isUnmounting: false,
-    leavingVNodes: new Map()
+    leavingVNodes: new Map(),
   }
   onMounted(() => {
     state.isMounted = true
@@ -132,7 +132,7 @@ export const BaseTransitionPropsValidators = {
   onBeforeAppear: TransitionHookValidator,
   onAppear: TransitionHookValidator,
   onAfterAppear: TransitionHookValidator,
-  onAppearCancelled: TransitionHookValidator
+  onAppearCancelled: TransitionHookValidator,
 }
 
 const BaseTransitionImpl: ComponentOptions = {
@@ -163,7 +163,7 @@ const BaseTransitionImpl: ComponentOptions = {
               // warn more than one non-comment child
               warn(
                 '<transition> can only be used on a single element or component. ' +
-                  'Use <transition-group> for lists.'
+                  'Use <transition-group> for lists.',
               )
               break
             }
@@ -204,7 +204,7 @@ const BaseTransitionImpl: ComponentOptions = {
         innerChild,
         rawProps,
         state,
-        instance
+        instance,
       )
       setTransitionHooks(innerChild, enterHooks)
 
@@ -233,7 +233,7 @@ const BaseTransitionImpl: ComponentOptions = {
           oldInnerChild,
           rawProps,
           state,
-          instance
+          instance,
         )
         // update old tree's hooks in case of dynamic transition
         setTransitionHooks(oldInnerChild, leavingHooks)
@@ -255,11 +255,11 @@ const BaseTransitionImpl: ComponentOptions = {
           leavingHooks.delayLeave = (
             el: TransitionElement,
             earlyRemove,
-            delayedLeave
+            delayedLeave,
           ) => {
             const leavingVNodesCache = getLeavingNodesForType(
               state,
-              oldInnerChild
+              oldInnerChild,
             )
             leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild
             // early removal callback
@@ -275,7 +275,7 @@ const BaseTransitionImpl: ComponentOptions = {
 
       return child
     }
-  }
+  },
 }
 
 if (__COMPAT__) {
@@ -295,7 +295,7 @@ export const BaseTransition = BaseTransitionImpl as unknown as {
 
 function getLeavingNodesForType(
   state: TransitionState,
-  vnode: VNode
+  vnode: VNode,
 ): Record<string, VNode> {
   const { leavingVNodes } = state
   let leavingVNodesCache = leavingVNodes.get(vnode.type)!
@@ -312,7 +312,7 @@ export function resolveTransitionHooks(
   vnode: VNode,
   props: BaseTransitionProps<any>,
   state: TransitionState,
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): TransitionHooks {
   const {
     appear,
@@ -329,7 +329,7 @@ export function resolveTransitionHooks(
     onBeforeAppear,
     onAppear,
     onAfterAppear,
-    onAppearCancelled
+    onAppearCancelled,
   } = props
   const key = String(vnode.key)
   const leavingVNodesCache = getLeavingNodesForType(state, vnode)
@@ -340,13 +340,13 @@ export function resolveTransitionHooks(
         hook,
         instance,
         ErrorCodes.TRANSITION_HOOK,
-        args
+        args,
       )
   }
 
   const callAsyncHook = (
     hook: Hook<(el: any, done: () => void) => void>,
-    args: [TransitionElement, () => void]
+    args: [TransitionElement, () => void],
   ) => {
     const done = args[1]
     callHook(hook, args)
@@ -454,7 +454,7 @@ export function resolveTransitionHooks(
 
     clone(vnode) {
       return resolveTransitionHooks(vnode, props, state, instance)
-    }
+    },
   }
 
   return hooks
@@ -498,7 +498,7 @@ export function setTransitionHooks(vnode: VNode, hooks: TransitionHooks) {
 export function getTransitionRawChildren(
   children: VNode[],
   keepComment: boolean = false,
-  parentKey?: VNode['key']
+  parentKey?: VNode['key'],
 ): VNode[] {
   let ret: VNode[] = []
   let keyedFragmentCount = 0
@@ -513,7 +513,7 @@ export function getTransitionRawChildren(
     if (child.type === Fragment) {
       if (child.patchFlag & PatchFlags.KEYED_FRAGMENT) keyedFragmentCount++
       ret = ret.concat(
-        getTransitionRawChildren(child.children as VNode[], keepComment, key)
+        getTransitionRawChildren(child.children as VNode[], keepComment, key),
       )
     }
     // comment placeholders should be skipped, e.g. v-if
index 8f9a94f1109c1c7455fbeca05439e611cca5ccad..db6088cf5c622bf9fcea76921249734e09536dbf 100644 (file)
@@ -1,47 +1,47 @@
 import {
-  ConcreteComponent,
-  getCurrentInstance,
-  SetupContext,
-  ComponentInternalInstance,
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type ConcreteComponent,
+  type SetupContext,
   currentInstance,
   getComponentName,
-  ComponentOptions
+  getCurrentInstance,
 } from '../component'
 import {
-  VNode,
+  type VNode,
+  type VNodeProps,
   cloneVNode,
-  isVNode,
-  VNodeProps,
   invokeVNodeHook,
-  isSameVNodeType
+  isSameVNodeType,
+  isVNode,
 } from '../vnode'
 import { warn } from '../warning'
 import {
-  onBeforeUnmount,
   injectHook,
-  onUnmounted,
+  onBeforeUnmount,
   onMounted,
-  onUpdated
+  onUnmounted,
+  onUpdated,
 } from '../apiLifecycle'
 import {
-  isString,
+  ShapeFlags,
+  invokeArrayFns,
   isArray,
   isRegExp,
-  ShapeFlags,
+  isString,
   remove,
-  invokeArrayFns
 } from '@vue/shared'
 import { watch } from '../apiWatch'
 import {
-  RendererInternals,
-  queuePostRenderEffect,
+  type ElementNamespace,
   MoveType,
-  RendererElement,
-  RendererNode,
-  ElementNamespace
+  type RendererElement,
+  type RendererInternals,
+  type RendererNode,
+  queuePostRenderEffect,
 } from '../renderer'
 import { setTransitionHooks } from './BaseTransition'
-import { ComponentRenderContext } from '../componentPublicInstance'
+import type { ComponentRenderContext } from '../componentPublicInstance'
 import { devtoolsComponentAdded } from '../devtools'
 import { isAsyncWrapper } from '../apiAsyncComponent'
 import { isSuspense } from './Suspense'
@@ -66,7 +66,7 @@ export interface KeepAliveContext extends ComponentRenderContext {
     container: RendererElement,
     anchor: RendererNode | null,
     namespace: ElementNamespace,
-    optimized: boolean
+    optimized: boolean,
   ) => void
   deactivate: (vnode: VNode) => void
 }
@@ -85,7 +85,7 @@ const KeepAliveImpl: ComponentOptions = {
   props: {
     include: [String, RegExp, Array],
     exclude: [String, RegExp, Array],
-    max: [String, Number]
+    max: [String, Number],
   },
 
   setup(props: KeepAliveProps, { slots }: SetupContext) {
@@ -121,8 +121,8 @@ const KeepAliveImpl: ComponentOptions = {
         p: patch,
         m: move,
         um: _unmount,
-        o: { createElement }
-      }
+        o: { createElement },
+      },
     } = sharedContext
     const storageContainer = createElement('div')
 
@@ -131,7 +131,7 @@ const KeepAliveImpl: ComponentOptions = {
       container,
       anchor,
       namespace,
-      optimized
+      optimized,
     ) => {
       const instance = vnode.component!
       move(vnode, container, anchor, MoveType.ENTER, parentSuspense)
@@ -145,7 +145,7 @@ const KeepAliveImpl: ComponentOptions = {
         parentSuspense,
         namespace,
         vnode.slotScopeIds,
-        optimized
+        optimized,
       )
       queuePostRenderEffect(() => {
         instance.isDeactivated = false
@@ -220,7 +220,7 @@ const KeepAliveImpl: ComponentOptions = {
         exclude && pruneCache(name => !matches(exclude, name))
       },
       // prune post-render after `current` has been updated
-      { flush: 'post', deep: true }
+      { flush: 'post', deep: true },
     )
 
     // cache sub tree after render
@@ -282,7 +282,7 @@ const KeepAliveImpl: ComponentOptions = {
       const name = getComponentName(
         isAsyncWrapper(vnode)
           ? (vnode.type as ComponentOptions).__asyncResolved || {}
-          : comp
+          : comp,
       )
 
       const { include, exclude, max } = props
@@ -338,7 +338,7 @@ const KeepAliveImpl: ComponentOptions = {
       current = vnode
       return isSuspense(rawVNode.type) ? rawVNode : vnode
     }
-  }
+  },
 }
 
 if (__COMPAT__) {
@@ -371,14 +371,14 @@ function matches(pattern: MatchPattern, name: string): boolean {
 
 export function onActivated(
   hook: Function,
-  target?: ComponentInternalInstance | null
+  target?: ComponentInternalInstance | null,
 ) {
   registerKeepAliveHook(hook, LifecycleHooks.ACTIVATED, target)
 }
 
 export function onDeactivated(
   hook: Function,
-  target?: ComponentInternalInstance | null
+  target?: ComponentInternalInstance | null,
 ) {
   registerKeepAliveHook(hook, LifecycleHooks.DEACTIVATED, target)
 }
@@ -386,7 +386,7 @@ export function onDeactivated(
 function registerKeepAliveHook(
   hook: Function & { __wdc?: Function },
   type: LifecycleHooks,
-  target: ComponentInternalInstance | null = currentInstance
+  target: ComponentInternalInstance | null = currentInstance,
 ) {
   // cache the deactivate branch check wrapper for injected hooks so the same
   // hook can be properly deduped by the scheduler. "__wdc" stands for "with
@@ -425,7 +425,7 @@ function injectToKeepAliveRoot(
   hook: Function & { __weh?: Function },
   type: LifecycleHooks,
   target: ComponentInternalInstance,
-  keepAliveRoot: ComponentInternalInstance
+  keepAliveRoot: ComponentInternalInstance,
 ) {
   // injectHook wraps the original for error handling, so make sure to remove
   // the wrapped version.
index 366f4a7bb03c625426c1a3597976b6c40cb51c1d..411ef054ca14493db341fcfd4e3f2358c4bb00b9 100644 (file)
@@ -1,35 +1,35 @@
 import {
-  VNode,
-  normalizeVNode,
-  VNodeProps,
-  isSameVNodeType,
-  openBlock,
-  closeBlock,
-  currentBlock,
   Comment,
+  type VNode,
+  type VNodeProps,
+  closeBlock,
   createVNode,
-  isBlockTreeEnabled
+  currentBlock,
+  isBlockTreeEnabled,
+  isSameVNodeType,
+  normalizeVNode,
+  openBlock,
 } from '../vnode'
-import { isFunction, isArray, ShapeFlags, toNumber } from '@vue/shared'
-import { ComponentInternalInstance, handleSetupResult } from '../component'
-import { Slots } from '../componentSlots'
+import { ShapeFlags, isArray, isFunction, toNumber } from '@vue/shared'
+import { type ComponentInternalInstance, handleSetupResult } from '../component'
+import type { Slots } from '../componentSlots'
 import {
-  RendererInternals,
+  type ElementNamespace,
   MoveType,
-  SetupRenderEffectFn,
-  RendererNode,
-  RendererElement,
-  ElementNamespace
+  type RendererElement,
+  type RendererInternals,
+  type RendererNode,
+  type SetupRenderEffectFn,
 } from '../renderer'
 import { queuePostFlushCb } from '../scheduler'
 import { filterSingleRoot, updateHOCHostEl } from '../componentRenderUtils'
 import {
-  pushWarningContext,
+  assertNumber,
   popWarningContext,
+  pushWarningContext,
   warn,
-  assertNumber
 } from '../warning'
-import { handleError, ErrorCodes } from '../errorHandling'
+import { ErrorCodes, handleError } from '../errorHandling'
 import { NULL_DYNAMIC_COMPONENT } from '../helpers/resolveAssets'
 
 export interface SuspenseProps {
@@ -71,7 +71,7 @@ export const SuspenseImpl = {
     slotScopeIds: string[] | null,
     optimized: boolean,
     // platform-specific impl passed from renderer
-    rendererInternals: RendererInternals
+    rendererInternals: RendererInternals,
   ) {
     if (n1 == null) {
       mountSuspense(
@@ -83,7 +83,7 @@ export const SuspenseImpl = {
         namespace,
         slotScopeIds,
         optimized,
-        rendererInternals
+        rendererInternals,
       )
     } else {
       patchSuspense(
@@ -95,13 +95,13 @@ export const SuspenseImpl = {
         namespace,
         slotScopeIds,
         optimized,
-        rendererInternals
+        rendererInternals,
       )
     }
   },
   hydrate: hydrateSuspense,
   create: createSuspenseBoundary,
-  normalize: normalizeSuspenseChildren
+  normalize: normalizeSuspenseChildren,
 }
 
 // Force-casted public typing for h and TSX props inference
@@ -120,7 +120,7 @@ export const Suspense = (__FEATURE_SUSPENSE__
 
 function triggerEvent(
   vnode: VNode,
-  name: 'onResolve' | 'onPending' | 'onFallback'
+  name: 'onResolve' | 'onPending' | 'onFallback',
 ) {
   const eventListener = vnode.props && vnode.props[name]
   if (isFunction(eventListener)) {
@@ -137,11 +137,11 @@ function mountSuspense(
   namespace: ElementNamespace,
   slotScopeIds: string[] | null,
   optimized: boolean,
-  rendererInternals: RendererInternals
+  rendererInternals: RendererInternals,
 ) {
   const {
     p: patch,
-    o: { createElement }
+    o: { createElement },
   } = rendererInternals
   const hiddenContainer = createElement('div')
   const suspense = (vnode.suspense = createSuspenseBoundary(
@@ -154,7 +154,7 @@ function mountSuspense(
     namespace,
     slotScopeIds,
     optimized,
-    rendererInternals
+    rendererInternals,
   ))
 
   // start mounting the content subtree in an off-dom container
@@ -166,7 +166,7 @@ function mountSuspense(
     parentComponent,
     suspense,
     namespace,
-    slotScopeIds
+    slotScopeIds,
   )
   // now check if we have encountered any async deps
   if (suspense.deps > 0) {
@@ -184,7 +184,7 @@ function mountSuspense(
       parentComponent,
       null, // fallback tree will not have suspense context
       namespace,
-      slotScopeIds
+      slotScopeIds,
     )
     setActiveBranch(suspense, vnode.ssFallback!)
   } else {
@@ -202,7 +202,7 @@ function patchSuspense(
   namespace: ElementNamespace,
   slotScopeIds: string[] | null,
   optimized: boolean,
-  { p: patch, um: unmount, o: { createElement } }: RendererInternals
+  { p: patch, um: unmount, o: { createElement } }: RendererInternals,
 ) {
   const suspense = (n2.suspense = n1.suspense)!
   suspense.vnode = n2
@@ -224,7 +224,7 @@ function patchSuspense(
         suspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
       if (suspense.deps <= 0) {
         suspense.resolve()
@@ -245,7 +245,7 @@ function patchSuspense(
             null, // fallback tree will not have suspense context
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
           setActiveBranch(suspense, newFallback)
         }
@@ -281,7 +281,7 @@ function patchSuspense(
           suspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         if (suspense.deps <= 0) {
           suspense.resolve()
@@ -295,7 +295,7 @@ function patchSuspense(
             null, // fallback tree will not have suspense context
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
           setActiveBranch(suspense, newFallback)
         }
@@ -310,7 +310,7 @@ function patchSuspense(
           suspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         // force resolve
         suspense.resolve(true)
@@ -325,7 +325,7 @@ function patchSuspense(
           suspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         if (suspense.deps <= 0) {
           suspense.resolve()
@@ -344,7 +344,7 @@ function patchSuspense(
         suspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
       setActiveBranch(suspense, newBranch)
     } else {
@@ -367,7 +367,7 @@ function patchSuspense(
         suspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
       if (suspense.deps <= 0) {
         // incoming branch has no async deps, resolve now.
@@ -410,12 +410,12 @@ export interface SuspenseBoundary {
   move(
     container: RendererElement,
     anchor: RendererNode | null,
-    type: MoveType
+    type: MoveType,
   ): void
   next(): RendererNode | null
   registerDep(
     instance: ComponentInternalInstance,
-    setupRenderEffect: SetupRenderEffectFn
+    setupRenderEffect: SetupRenderEffectFn,
   ): void
   unmount(parentSuspense: SuspenseBoundary | null, doRemove?: boolean): void
 }
@@ -433,14 +433,14 @@ function createSuspenseBoundary(
   slotScopeIds: string[] | null,
   optimized: boolean,
   rendererInternals: RendererInternals,
-  isHydrating = false
+  isHydrating = false,
 ): SuspenseBoundary {
   /* istanbul ignore if */
   if (__DEV__ && !__TEST__ && !hasWarned) {
     hasWarned = true
-    // @ts-ignore `console.info` cannot be null error
+    // @ts-expect-error `console.info` cannot be null error
     console[console.info ? 'info' : 'log'](
-      `<Suspense> is an experimental feature and its API will likely change.`
+      `<Suspense> is an experimental feature and its API will likely change.`,
     )
   }
 
@@ -449,7 +449,7 @@ function createSuspenseBoundary(
     m: move,
     um: unmount,
     n: next,
-    o: { parentNode, remove }
+    o: { parentNode, remove },
   } = rendererInternals
 
   // if set `suspensible: true`, set the current suspense as a dep of parent suspense
@@ -489,12 +489,12 @@ function createSuspenseBoundary(
       if (__DEV__) {
         if (!resume && !suspense.pendingBranch) {
           throw new Error(
-            `suspense.resolve() is called without a pending branch.`
+            `suspense.resolve() is called without a pending branch.`,
           )
         }
         if (suspense.isUnmounted) {
           throw new Error(
-            `suspense.resolve() is called on an already unmounted suspense boundary.`
+            `suspense.resolve() is called on an already unmounted suspense boundary.`,
           )
         }
       }
@@ -505,7 +505,7 @@ function createSuspenseBoundary(
         pendingId,
         effects,
         parentComponent,
-        container
+        container,
       } = suspense
 
       // if there's a transition happening we need to wait it to finish.
@@ -524,7 +524,7 @@ function createSuspenseBoundary(
                 pendingBranch!,
                 container,
                 next(activeBranch!),
-                MoveType.ENTER
+                MoveType.ENTER,
               )
               queuePostFlushCb(effects)
             }
@@ -613,7 +613,7 @@ function createSuspenseBoundary(
           null, // fallback tree will not have suspense context
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         setActiveBranch(suspense, fallbackVNode)
       }
@@ -630,7 +630,7 @@ function createSuspenseBoundary(
         activeBranch!,
         parentComponent,
         null, // no suspense so unmount hooks fire now
-        true // shouldRemove
+        true, // shouldRemove
       )
 
       if (!delayEnter) {
@@ -693,7 +693,7 @@ function createSuspenseBoundary(
             hydratedEl ? null : next(instance.subTree),
             suspense,
             namespace,
-            optimized
+            optimized,
           )
           if (placeholder) {
             remove(placeholder)
@@ -716,7 +716,7 @@ function createSuspenseBoundary(
           suspense.activeBranch,
           parentComponent,
           parentSuspense,
-          doRemove
+          doRemove,
         )
       }
       if (suspense.pendingBranch) {
@@ -724,10 +724,10 @@ function createSuspenseBoundary(
           suspense.pendingBranch,
           parentComponent,
           parentSuspense,
-          doRemove
+          doRemove,
         )
       }
-    }
+    },
   }
 
   return suspense
@@ -748,22 +748,22 @@ function hydrateSuspense(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    optimized: boolean
-  ) => Node | null
+    optimized: boolean,
+  ) => Node | null,
 ): Node | null {
-  /* eslint-disable no-restricted-globals */
   const suspense = (vnode.suspense = createSuspenseBoundary(
     vnode,
     parentSuspense,
     parentComponent,
     node.parentNode!,
+    // eslint-disable-next-line no-restricted-globals
     document.createElement('div'),
     null,
     namespace,
     slotScopeIds,
     optimized,
     rendererInternals,
-    true /* hydrating */
+    true /* hydrating */,
   ))
   // there are two possible scenarios for server-rendered suspense:
   // - success: ssr content should be fully resolved
@@ -777,7 +777,7 @@ function hydrateSuspense(
     parentComponent,
     suspense,
     slotScopeIds,
-    optimized
+    optimized,
   )
   if (suspense.deps === 0) {
     suspense.resolve(false, true)
@@ -790,7 +790,7 @@ function normalizeSuspenseChildren(vnode: VNode) {
   const { shapeFlag, children } = vnode
   const isSlotChildren = shapeFlag & ShapeFlags.SLOTS_CHILDREN
   vnode.ssContent = normalizeSuspenseSlot(
-    isSlotChildren ? (children as Slots).default : children
+    isSlotChildren ? (children as Slots).default : children,
   )
   vnode.ssFallback = isSlotChildren
     ? normalizeSuspenseSlot((children as Slots).fallback)
@@ -835,7 +835,7 @@ function normalizeSuspenseSlot(s: any) {
 
 export function queueEffectWithSuspense(
   fn: Function | Function[],
-  suspense: SuspenseBoundary | null
+  suspense: SuspenseBoundary | null,
 ): void {
   if (suspense && suspense.pendingBranch) {
     if (isArray(fn)) {
index aae7deff336956b2e3147ed248352b1197e917ea..0de0ebf787edfeedd033096c3158c32a51aec687 100644 (file)
@@ -1,16 +1,16 @@
-import { ComponentInternalInstance } from '../component'
-import { SuspenseBoundary } from './Suspense'
+import type { ComponentInternalInstance } from '../component'
+import type { SuspenseBoundary } from './Suspense'
 import {
-  RendererInternals,
+  type ElementNamespace,
   MoveType,
-  RendererElement,
-  RendererNode,
-  RendererOptions,
+  type RendererElement,
+  type RendererInternals,
+  type RendererNode,
+  type RendererOptions,
   traverseStaticChildren,
-  ElementNamespace
 } from '../renderer'
-import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
-import { isString, ShapeFlags } from '@vue/shared'
+import type { VNode, VNodeArrayChildren, VNodeProps } from '../vnode'
+import { ShapeFlags, isString } from '@vue/shared'
 import { warn } from '../warning'
 import { isHmrUpdating } from '../hmr'
 
@@ -34,7 +34,7 @@ const isTargetMathML = (target: RendererElement): boolean =>
 
 const resolveTarget = <T = RendererElement>(
   props: TeleportProps | null,
-  select: RendererOptions['querySelector']
+  select: RendererOptions['querySelector'],
 ): T | null => {
   const targetSelector = props && props.to
   if (isString(targetSelector)) {
@@ -42,7 +42,7 @@ const resolveTarget = <T = RendererElement>(
       __DEV__ &&
         warn(
           `Current renderer does not support string target for Teleports. ` +
-            `(missing querySelector renderer option)`
+            `(missing querySelector renderer option)`,
         )
       return null
     } else {
@@ -53,7 +53,7 @@ const resolveTarget = <T = RendererElement>(
             `Failed to locate Teleport target with selector "${targetSelector}". ` +
               `Note the target element must exist before the component is mounted - ` +
               `i.e. the target cannot be rendered by the component itself, and ` +
-              `ideally should be outside of the entire Vue component tree.`
+              `ideally should be outside of the entire Vue component tree.`,
           )
       }
       return target as T
@@ -79,13 +79,13 @@ export const TeleportImpl = {
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
     optimized: boolean,
-    internals: RendererInternals
+    internals: RendererInternals,
   ) {
     const {
       mc: mountChildren,
       pc: patchChildren,
       pbc: patchBlockChildren,
-      o: { insert, querySelector, createText, createComment }
+      o: { insert, querySelector, createText, createComment },
     } = internals
 
     const disabled = isTeleportDisabled(n2.props)
@@ -134,7 +134,7 @@ export const TeleportImpl = {
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
         }
       }
@@ -169,7 +169,7 @@ export const TeleportImpl = {
           parentComponent,
           parentSuspense,
           namespace,
-          slotScopeIds
+          slotScopeIds,
         )
         // even in block tree mode we need to make sure all root-level nodes
         // in the teleport inherit previous DOM references so that they can
@@ -185,7 +185,7 @@ export const TeleportImpl = {
           parentSuspense,
           namespace,
           slotScopeIds,
-          false
+          false,
         )
       }
 
@@ -198,7 +198,7 @@ export const TeleportImpl = {
             container,
             mainAnchor,
             internals,
-            TeleportMoveTypes.TOGGLE
+            TeleportMoveTypes.TOGGLE,
           )
         } else {
           // #7835
@@ -213,7 +213,7 @@ export const TeleportImpl = {
         if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
           const nextTarget = (n2.target = resolveTarget(
             n2.props,
-            querySelector
+            querySelector,
           ))
           if (nextTarget) {
             moveTeleport(
@@ -221,13 +221,13 @@ export const TeleportImpl = {
               nextTarget,
               null,
               internals,
-              TeleportMoveTypes.TARGET_CHANGE
+              TeleportMoveTypes.TARGET_CHANGE,
             )
           } else if (__DEV__) {
             warn(
               'Invalid Teleport target on update:',
               target,
-              `(${typeof target})`
+              `(${typeof target})`,
             )
           }
         } else if (wasDisabled) {
@@ -238,7 +238,7 @@ export const TeleportImpl = {
             target,
             targetAnchor,
             internals,
-            TeleportMoveTypes.TOGGLE
+            TeleportMoveTypes.TOGGLE,
           )
         }
       }
@@ -253,7 +253,7 @@ export const TeleportImpl = {
     parentSuspense: SuspenseBoundary | null,
     optimized: boolean,
     { um: unmount, o: { remove: hostRemove } }: RendererInternals,
-    doRemove: boolean
+    doRemove: boolean,
   ) {
     const { shapeFlag, children, anchor, targetAnchor, target, props } = vnode
 
@@ -272,20 +272,20 @@ export const TeleportImpl = {
           parentComponent,
           parentSuspense,
           shouldRemove,
-          !!child.dynamicChildren
+          !!child.dynamicChildren,
         )
       }
     }
   },
 
   move: moveTeleport,
-  hydrate: hydrateTeleport
+  hydrate: hydrateTeleport,
 }
 
 export enum TeleportMoveTypes {
   TARGET_CHANGE,
   TOGGLE, // enable / disable
-  REORDER // moved in the main view
+  REORDER, // moved in the main view
 }
 
 function moveTeleport(
@@ -293,7 +293,7 @@ function moveTeleport(
   container: RendererElement,
   parentAnchor: RendererNode | null,
   { o: { insert }, m: move }: RendererInternals,
-  moveType: TeleportMoveTypes = TeleportMoveTypes.REORDER
+  moveType: TeleportMoveTypes = TeleportMoveTypes.REORDER,
 ) {
   // move target anchor if this is a target change.
   if (moveType === TeleportMoveTypes.TARGET_CHANGE) {
@@ -316,7 +316,7 @@ function moveTeleport(
           (children as VNode[])[i],
           container,
           parentAnchor,
-          MoveType.REORDER
+          MoveType.REORDER,
         )
       }
     }
@@ -340,7 +340,7 @@ function hydrateTeleport(
   slotScopeIds: string[] | null,
   optimized: boolean,
   {
-    o: { nextSibling, parentNode, querySelector }
+    o: { nextSibling, parentNode, querySelector },
   }: RendererInternals<Node, Element>,
   hydrateChildren: (
     node: Node | null,
@@ -349,12 +349,12 @@ function hydrateTeleport(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    optimized: boolean
-  ) => Node | null
+    optimized: boolean,
+  ) => Node | null,
 ): Node | null {
   const target = (vnode.target = resolveTarget<Element>(
     vnode.props,
-    querySelector
+    querySelector,
   ))
   if (target) {
     // if multiple teleports rendered to the same target element, we need to
@@ -370,7 +370,7 @@ function hydrateTeleport(
           parentComponent,
           parentSuspense,
           slotScopeIds,
-          optimized
+          optimized,
         )
         vnode.targetAnchor = targetNode
       } else {
@@ -401,7 +401,7 @@ function hydrateTeleport(
           parentComponent,
           parentSuspense,
           slotScopeIds,
-          optimized
+          optimized,
         )
       }
     }
index b30a876d92223abb739dcc8438ff275fc9a8a0b6..d2510c09c257a894f1aa6439b8f69db14136195f 100644 (file)
@@ -1,8 +1,8 @@
-import { isReactive, isReadonly, isRef, Ref, toRaw } from '@vue/reactivity'
+import { type Ref, isReactive, isReadonly, isRef, toRaw } from '@vue/reactivity'
 import { EMPTY_OBJ, extend, isArray, isFunction, isObject } from '@vue/shared'
 import { isShallow } from '../../reactivity/src/reactive'
-import { ComponentInternalInstance, ComponentOptions } from './component'
-import { ComponentPublicInstance } from './componentPublicInstance'
+import type { ComponentInternalInstance, ComponentOptions } from './component'
+import type { ComponentPublicInstance } from './componentPublicInstance'
 
 export function initCustomFormatter() {
   /* eslint-disable no-restricted-globals */
@@ -33,7 +33,7 @@ export function initCustomFormatter() {
           ['span', vueStyle, genRefFlag(obj)],
           '<',
           formatValue(obj.value),
-          `>`
+          `>`,
         ]
       } else if (isReactive(obj)) {
         return [
@@ -42,7 +42,7 @@ export function initCustomFormatter() {
           ['span', vueStyle, isShallow(obj) ? 'ShallowReactive' : 'Reactive'],
           '<',
           formatValue(obj),
-          `>${isReadonly(obj) ? ` (readonly)` : ``}`
+          `>${isReadonly(obj) ? ` (readonly)` : ``}`,
         ]
       } else if (isReadonly(obj)) {
         return [
@@ -51,7 +51,7 @@ export function initCustomFormatter() {
           ['span', vueStyle, isShallow(obj) ? 'ShallowReadonly' : 'Readonly'],
           '<',
           formatValue(obj),
-          '>'
+          '>',
         ]
       }
       return null
@@ -64,10 +64,10 @@ export function initCustomFormatter() {
         return [
           'div',
           {},
-          ...formatInstance((obj as ComponentPublicInstance).$)
+          ...formatInstance((obj as ComponentPublicInstance).$),
         ]
       }
-    }
+    },
   }
 
   function formatInstance(instance: ComponentInternalInstance) {
@@ -96,11 +96,11 @@ export function initCustomFormatter() {
       [
         'span',
         {
-          style: keywordStyle.style + ';opacity:0.66'
+          style: keywordStyle.style + ';opacity:0.66',
         },
-        '$ (internal): '
+        '$ (internal): ',
       ],
-      ['object', { object: instance }]
+      ['object', { object: instance }],
     ])
     return blocks
   }
@@ -116,24 +116,24 @@ export function initCustomFormatter() {
       [
         'div',
         {
-          style: 'color:#476582'
+          style: 'color:#476582',
         },
-        type
+        type,
       ],
       [
         'div',
         {
-          style: 'padding-left:1.25em'
+          style: 'padding-left:1.25em',
         },
         ...Object.keys(target).map(key => {
           return [
             'div',
             {},
             ['span', keywordStyle, key + ': '],
-            formatValue(target[key], false)
+            formatValue(target[key], false),
           ]
-        })
-      ]
+        }),
+      ],
     ]
   }
 
index bf6f09f32676328c4f3726d3462a6fd4d512ed70..870cb4748bd77e8b894d9015ccb07c18742ca99e 100644 (file)
@@ -1,7 +1,7 @@
 /* eslint-disable no-restricted-globals */
-import { App } from './apiCreateApp'
-import { Fragment, Text, Comment, Static } from './vnode'
-import { ComponentInternalInstance } from './component'
+import type { App } from './apiCreateApp'
+import { Comment, Fragment, Static, Text } from './vnode'
+import type { ComponentInternalInstance } from './component'
 
 interface AppRecord {
   id: number
@@ -18,7 +18,7 @@ enum DevtoolsHooks {
   COMPONENT_REMOVED = 'component:removed',
   COMPONENT_EMIT = 'component:emit',
   PERFORMANCE_START = 'perf:start',
-  PERFORMANCE_END = 'perf:end'
+  PERFORMANCE_END = 'perf:end',
 }
 
 export interface DevtoolsHook {
@@ -91,7 +91,7 @@ export function devtoolsInitApp(app: App, version: string) {
     Fragment,
     Text,
     Comment,
-    Static
+    Static,
   })
 }
 
@@ -100,18 +100,18 @@ export function devtoolsUnmountApp(app: App) {
 }
 
 export const devtoolsComponentAdded = /*#__PURE__*/ createDevtoolsComponentHook(
-  DevtoolsHooks.COMPONENT_ADDED
+  DevtoolsHooks.COMPONENT_ADDED,
 )
 
 export const devtoolsComponentUpdated =
   /*#__PURE__*/ createDevtoolsComponentHook(DevtoolsHooks.COMPONENT_UPDATED)
 
 const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
-  DevtoolsHooks.COMPONENT_REMOVED
+  DevtoolsHooks.COMPONENT_REMOVED,
 )
 
 export const devtoolsComponentRemoved = (
-  component: ComponentInternalInstance
+  component: ComponentInternalInstance,
 ) => {
   if (
     devtools &&
@@ -130,17 +130,17 @@ function createDevtoolsComponentHook(hook: DevtoolsHooks) {
       component.appContext.app,
       component.uid,
       component.parent ? component.parent.uid : undefined,
-      component
+      component,
     )
   }
 }
 
 export const devtoolsPerfStart = /*#__PURE__*/ createDevtoolsPerformanceHook(
-  DevtoolsHooks.PERFORMANCE_START
+  DevtoolsHooks.PERFORMANCE_START,
 )
 
 export const devtoolsPerfEnd = /*#__PURE__*/ createDevtoolsPerformanceHook(
-  DevtoolsHooks.PERFORMANCE_END
+  DevtoolsHooks.PERFORMANCE_END,
 )
 
 function createDevtoolsPerformanceHook(hook: DevtoolsHooks) {
@@ -152,13 +152,13 @@ function createDevtoolsPerformanceHook(hook: DevtoolsHooks) {
 export function devtoolsComponentEmit(
   component: ComponentInternalInstance,
   event: string,
-  params: any[]
+  params: any[],
 ) {
   emit(
     DevtoolsHooks.COMPONENT_EMIT,
     component.appContext.app,
     component,
     event,
-    params
+    params,
   )
 }
index 18c3352b002a72a59f7123719bfe9e9994b2c3ad..a3b44d4c8faf6a659ce7153ed62f93bde531d28b 100644 (file)
@@ -11,13 +11,17 @@ return withDirectives(h(comp), [
 ])
 */
 
-import { VNode } from './vnode'
-import { isFunction, EMPTY_OBJ, isBuiltInDirective } from '@vue/shared'
+import type { VNode } from './vnode'
+import { EMPTY_OBJ, isBuiltInDirective, isFunction } from '@vue/shared'
 import { warn } from './warning'
-import { ComponentInternalInstance, Data, getExposeProxy } from './component'
+import {
+  type ComponentInternalInstance,
+  type Data,
+  getExposeProxy,
+} from './component'
 import { currentRenderingInstance } from './componentRenderContext'
-import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling'
-import { ComponentPublicInstance } from './componentPublicInstance'
+import { ErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
+import type { ComponentPublicInstance } from './componentPublicInstance'
 import { mapCompatDirectiveHook } from './compat/customDirective'
 import { pauseTracking, resetTracking } from '@vue/reactivity'
 import { traverse } from './apiWatch'
@@ -35,12 +39,12 @@ export type DirectiveHook<T = any, Prev = VNode<any, T> | null, V = any> = (
   el: T,
   binding: DirectiveBinding<V>,
   vnode: VNode<any, T>,
-  prevVNode: Prev
+  prevVNode: Prev,
 ) => void
 
 export type SSRDirectiveHook = (
   binding: DirectiveBinding,
-  vnode: VNode
+  vnode: VNode,
 ) => Data | undefined
 
 export interface ObjectDirective<T = any, V = any> {
@@ -82,7 +86,7 @@ export type DirectiveArguments = Array<
  */
 export function withDirectives<T extends VNode>(
   vnode: T,
-  directives: DirectiveArguments
+  directives: DirectiveArguments,
 ): T {
   const internalInstance = currentRenderingInstance
   if (internalInstance === null) {
@@ -99,7 +103,7 @@ export function withDirectives<T extends VNode>(
       if (isFunction(dir)) {
         dir = {
           mounted: dir,
-          updated: dir
+          updated: dir,
         } as ObjectDirective
       }
       if (dir.deep) {
@@ -111,7 +115,7 @@ export function withDirectives<T extends VNode>(
         value,
         oldValue: void 0,
         arg,
-        modifiers
+        modifiers,
       })
     }
   }
@@ -122,7 +126,7 @@ export function invokeDirectiveHook(
   vnode: VNode,
   prevVNode: VNode | null,
   instance: ComponentInternalInstance | null,
-  name: keyof ObjectDirective
+  name: keyof ObjectDirective,
 ) {
   const bindings = vnode.dirs!
   const oldBindings = prevVNode && prevVNode.dirs!
@@ -143,7 +147,7 @@ export function invokeDirectiveHook(
         vnode.el,
         binding,
         vnode,
-        prevVNode
+        prevVNode,
       ])
       resetTracking()
     }
index 829e2555d32736cdc164fb9d1ecbd746680e3084..aeb41adfcd6a6c6278344fc1dee99511c85c75f4 100644 (file)
@@ -12,5 +12,5 @@ export enum LifecycleHooks {
   RENDER_TRIGGERED = 'rtg',
   RENDER_TRACKED = 'rtc',
   ERROR_CAPTURED = 'ec',
-  SERVER_PREFETCH = 'sp'
+  SERVER_PREFETCH = 'sp',
 }
index d2438ba8d568a08a9c53f276b29d3a153ab8e252..11d44a1ced156e77103f91c1a2046bb706f07f1b 100644 (file)
@@ -1,7 +1,7 @@
-import { VNode } from './vnode'
-import { ComponentInternalInstance } from './component'
-import { warn, pushWarningContext, popWarningContext } from './warning'
-import { isPromise, isFunction } from '@vue/shared'
+import type { VNode } from './vnode'
+import type { ComponentInternalInstance } from './component'
+import { popWarningContext, pushWarningContext, warn } from './warning'
+import { isFunction, isPromise } from '@vue/shared'
 import { LifecycleHooks } from './enums'
 
 // contexts where user provided function may be executed, in addition to
@@ -21,7 +21,7 @@ export enum ErrorCodes {
   APP_WARN_HANDLER,
   FUNCTION_REF,
   ASYNC_COMPONENT_LOADER,
-  SCHEDULER
+  SCHEDULER,
 }
 
 export const ErrorTypeStrings: Record<LifecycleHooks | ErrorCodes, string> = {
@@ -55,7 +55,7 @@ export const ErrorTypeStrings: Record<LifecycleHooks | ErrorCodes, string> = {
   [ErrorCodes.ASYNC_COMPONENT_LOADER]: 'async component loader',
   [ErrorCodes.SCHEDULER]:
     'scheduler flush. This is likely a Vue internals bug. ' +
-    'Please open an issue at https://github.com/vuejs/core .'
+    'Please open an issue at https://github.com/vuejs/core .',
 }
 
 export type ErrorTypes = LifecycleHooks | ErrorCodes
@@ -64,7 +64,7 @@ export function callWithErrorHandling(
   fn: Function,
   instance: ComponentInternalInstance | null,
   type: ErrorTypes,
-  args?: unknown[]
+  args?: unknown[],
 ) {
   let res
   try {
@@ -79,7 +79,7 @@ export function callWithAsyncErrorHandling(
   fn: Function | Function[],
   instance: ComponentInternalInstance | null,
   type: ErrorTypes,
-  args?: unknown[]
+  args?: unknown[],
 ): any[] {
   if (isFunction(fn)) {
     const res = callWithErrorHandling(fn, instance, type, args)
@@ -102,7 +102,7 @@ export function handleError(
   err: unknown,
   instance: ComponentInternalInstance | null,
   type: ErrorTypes,
-  throwInDev = true
+  throwInDev = true,
 ) {
   const contextVNode = instance ? instance.vnode : null
   if (instance) {
@@ -133,7 +133,7 @@ export function handleError(
         appErrorHandler,
         null,
         ErrorCodes.APP_ERROR_HANDLER,
-        [err, exposedInstance, errorInfo]
+        [err, exposedInstance, errorInfo],
       )
       return
     }
@@ -145,7 +145,7 @@ function logError(
   err: unknown,
   type: ErrorTypes,
   contextVNode: VNode | null,
-  throwInDev = true
+  throwInDev = true,
 ) {
   if (__DEV__) {
     const info = ErrorTypeStrings[type]
index 267e69eef5ce5dacde6d2ea0502fcc2c9177a9ae..6dd136277bd27a5164335a64e81a56d4944fdaca 100644 (file)
@@ -34,7 +34,7 @@ export function initFeatureFlags() {
         `which expects these compile-time feature flags to be globally injected ` +
         `via the bundler config in order to get better tree-shaking in the ` +
         `production bundle.\n\n` +
-        `For more details, see https://link.vuejs.org/feature-flags.`
+        `For more details, see https://link.vuejs.org/feature-flags.`,
     )
   }
 }
index 038d8d2fbc70afadac79afe9d698187f5708bf13..d683a288c26d09e3db285167a10fa7f853733f86 100644 (file)
@@ -1,25 +1,25 @@
 import {
-  VNode,
-  VNodeProps,
+  type Comment,
+  type Fragment,
+  type Text,
+  type VNode,
+  type VNodeArrayChildren,
+  type VNodeProps,
   createVNode,
-  VNodeArrayChildren,
-  Fragment,
-  Text,
-  Comment,
-  isVNode
+  isVNode,
 } from './vnode'
-import { Teleport, TeleportProps } from './components/Teleport'
-import { Suspense, SuspenseProps } from './components/Suspense'
-import { isObject, isArray } from '@vue/shared'
-import { RawSlots } from './componentSlots'
-import {
-  FunctionalComponent,
+import type { Teleport, TeleportProps } from './components/Teleport'
+import type { Suspense, SuspenseProps } from './components/Suspense'
+import { isArray, isObject } from '@vue/shared'
+import type { RawSlots } from './componentSlots'
+import type {
   Component,
   ComponentOptions,
-  ConcreteComponent
+  ConcreteComponent,
+  FunctionalComponent,
 } from './component'
-import { EmitsOptions } from './componentEmits'
-import { DefineComponent } from './apiDefineComponent'
+import type { EmitsOptions } from './componentEmits'
+import type { DefineComponent } from './apiDefineComponent'
 
 // `h` is a more user-friendly version of `createVNode` that allows omitting the
 // props when possible. It is intended for manually written render functions.
@@ -77,7 +77,7 @@ interface Constructor<P = any> {
 
 type HTMLElementEventHandler = {
   [K in keyof HTMLElementEventMap as `on${Capitalize<K>}`]?: (
-    ev: HTMLElementEventMap[K]
+    ev: HTMLElementEventMap[K],
   ) => any
 }
 
@@ -87,12 +87,12 @@ type HTMLElementEventHandler = {
 // element
 export function h<K extends keyof HTMLElementTagNameMap>(
   type: K,
-  children?: RawChildren
+  children?: RawChildren,
 ): VNode
 export function h<K extends keyof HTMLElementTagNameMap>(
   type: K,
   props?: (RawProps & HTMLElementEventHandler) | null,
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // custom element
@@ -100,32 +100,32 @@ export function h(type: string, children?: RawChildren): VNode
 export function h(
   type: string,
   props?: RawProps | null,
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // text/comment
 export function h(
   type: typeof Text | typeof Comment,
-  children?: string | number | boolean
+  children?: string | number | boolean,
 ): VNode
 export function h(
   type: typeof Text | typeof Comment,
   props?: null,
-  children?: string | number | boolean
+  children?: string | number | boolean,
 ): VNode
 // fragment
 export function h(type: typeof Fragment, children?: VNodeArrayChildren): VNode
 export function h(
   type: typeof Fragment,
   props?: RawProps | null,
-  children?: VNodeArrayChildren
+  children?: VNodeArrayChildren,
 ): VNode
 
 // teleport (target prop is required)
 export function h(
   type: typeof Teleport,
   props: RawProps & TeleportProps,
-  children: RawChildren | RawSlots
+  children: RawChildren | RawSlots,
 ): VNode
 
 // suspense
@@ -133,18 +133,18 @@ export function h(type: typeof Suspense, children?: RawChildren): VNode
 export function h(
   type: typeof Suspense,
   props?: (RawProps & SuspenseProps) | null,
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // functional component
 export function h<
   P,
   E extends EmitsOptions = {},
-  S extends Record<string, any> = {}
+  S extends Record<string, any> = {},
 >(
   type: FunctionalComponent<P, E, S>,
   props?: (RawProps & P) | ({} extends P ? null : never),
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // catch-all for generic component types
@@ -153,26 +153,26 @@ export function h(type: Component, children?: RawChildren): VNode
 // concrete component
 export function h<P>(
   type: ConcreteComponent | string,
-  children?: RawChildren
+  children?: RawChildren,
 ): VNode
 export function h<P>(
   type: ConcreteComponent<P> | string,
   props?: (RawProps & P) | ({} extends P ? null : never),
-  children?: RawChildren
+  children?: RawChildren,
 ): VNode
 
 // component without props
 export function h<P>(
   type: Component<P>,
   props?: (RawProps & P) | null,
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // exclude `defineComponent` constructors
 export function h<P>(
   type: ComponentOptions<P>,
   props?: (RawProps & P) | ({} extends P ? null : never),
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // fake constructor type returned by `defineComponent` or class component
@@ -180,7 +180,7 @@ export function h(type: Constructor, children?: RawChildren): VNode
 export function h<P>(
   type: Constructor<P>,
   props?: (RawProps & P) | ({} extends P ? null : never),
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // fake constructor type returned by `defineComponent`
@@ -188,7 +188,7 @@ export function h(type: DefineComponent, children?: RawChildren): VNode
 export function h<P>(
   type: DefineComponent<P>,
   props?: (RawProps & P) | ({} extends P ? null : never),
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // catch all types
@@ -196,7 +196,7 @@ export function h(type: string | Component, children?: RawChildren): VNode
 export function h<P>(
   type: string | Component<P>,
   props?: (RawProps & P) | ({} extends P ? null : never),
-  children?: RawChildren | RawSlots
+  children?: RawChildren | RawSlots,
 ): VNode
 
 // Actual implementation
index f370f5ca8038d45e38e2844a0d11ab5931525882..f7d6e9d073be9aa06e838fd81d45c3e6c775d3e2 100644 (file)
@@ -1,5 +1,5 @@
 import { isArray } from '@vue/shared'
-import { VNode } from '../vnode'
+import type { VNode } from '../vnode'
 
 // #6651 res can be undefined in SSR in string push mode
 type SSRSlot = (...args: any[]) => VNode[] | undefined
@@ -20,7 +20,7 @@ export function createSlots(
     | CompiledSlotDescriptor
     | CompiledSlotDescriptor[]
     | undefined
-  )[]
+  )[],
 ): Record<string, SSRSlot> {
   for (let i = 0; i < dynamicSlots.length; i++) {
     const slot = dynamicSlots[i]
index 1655d555fb33cbd1d8e5f284751aa682c1ac01e0..655435fdd7a539cef64bf1410241de6c0065db60 100644 (file)
@@ -1,5 +1,5 @@
-import { VNode, VNodeChild } from '../vnode'
-import { isArray, isString, isObject } from '@vue/shared'
+import type { VNode, VNodeChild } from '../vnode'
+import { isArray, isObject, isString } from '@vue/shared'
 import { warn } from '../warning'
 
 /**
@@ -8,7 +8,7 @@ import { warn } from '../warning'
  */
 export function renderList(
   source: string,
-  renderItem: (value: string, index: number) => VNodeChild
+  renderItem: (value: string, index: number) => VNodeChild,
 ): VNodeChild[]
 
 /**
@@ -16,7 +16,7 @@ export function renderList(
  */
 export function renderList(
   source: number,
-  renderItem: (value: number, index: number) => VNodeChild
+  renderItem: (value: number, index: number) => VNodeChild,
 ): VNodeChild[]
 
 /**
@@ -24,7 +24,7 @@ export function renderList(
  */
 export function renderList<T>(
   source: T[],
-  renderItem: (value: T, index: number) => VNodeChild
+  renderItem: (value: T, index: number) => VNodeChild,
 ): VNodeChild[]
 
 /**
@@ -32,7 +32,7 @@ export function renderList<T>(
  */
 export function renderList<T>(
   source: Iterable<T>,
-  renderItem: (value: T, index: number) => VNodeChild
+  renderItem: (value: T, index: number) => VNodeChild,
 ): VNodeChild[]
 
 /**
@@ -43,8 +43,8 @@ export function renderList<T>(
   renderItem: <K extends keyof T>(
     value: T[K],
     key: K,
-    index: number
-  ) => VNodeChild
+    index: number,
+  ) => VNodeChild,
 ): VNodeChild[]
 
 /**
@@ -54,7 +54,7 @@ export function renderList(
   source: any,
   renderItem: (...args: any[]) => VNodeChild,
   cache?: any[],
-  index?: number
+  index?: number,
 ): VNodeChild[] {
   let ret: VNodeChild[]
   const cached = (cache && cache[index!]) as VNode[] | undefined
@@ -75,7 +75,7 @@ export function renderList(
   } else if (isObject(source)) {
     if (source[Symbol.iterator as any]) {
       ret = Array.from(source as Iterable<any>, (item, i) =>
-        renderItem(item, i, undefined, cached && cached[i])
+        renderItem(item, i, undefined, cached && cached[i]),
       )
     } else {
       const keys = Object.keys(source)
index 452fc8272692bfdde360f88222ad066a1b3870ed..8a7608219d9d1dbdf05b54d0ca15de089ab1572f 100644 (file)
@@ -1,17 +1,17 @@
-import { Data } from '../component'
-import { Slots, RawSlots } from '../componentSlots'
+import type { Data } from '../component'
+import type { RawSlots, Slots } from '../componentSlots'
 import {
-  ContextualRenderFn,
-  currentRenderingInstance
+  type ContextualRenderFn,
+  currentRenderingInstance,
 } from '../componentRenderContext'
 import {
   Comment,
+  Fragment,
+  type VNode,
+  type VNodeArrayChildren,
+  createBlock,
   isVNode,
-  VNodeArrayChildren,
   openBlock,
-  createBlock,
-  Fragment,
-  VNode
 } from '../vnode'
 import { PatchFlags, SlotFlags } from '@vue/shared'
 import { warn } from '../warning'
@@ -29,7 +29,7 @@ export function renderSlot(
   // this is not a user-facing function, so the fallback is always generated by
   // the compiler and guaranteed to be a function returning an array
   fallback?: () => VNodeArrayChildren,
-  noSlotted?: boolean
+  noSlotted?: boolean,
 ): VNode {
   if (
     currentRenderingInstance!.isCE ||
@@ -47,7 +47,7 @@ export function renderSlot(
     warn(
       `SSR-optimized slot function detected in a non-SSR-optimized render ` +
         `function. You need to mark this component with $dynamic-slots in the ` +
-        `parent template.`
+        `parent template.`,
     )
     slot = () => []
   }
@@ -69,12 +69,12 @@ export function renderSlot(
         // slot content array of a dynamic conditional slot may have a branch
         // key attached in the `createSlots` helper, respect that
         (validSlotContent && (validSlotContent as any).key) ||
-        `_${name}`
+        `_${name}`,
     },
     validSlotContent || (fallback ? fallback() : []),
     validSlotContent && (slots as RawSlots)._ === SlotFlags.STABLE
       ? PatchFlags.STABLE_FRAGMENT
-      : PatchFlags.BAIL
+      : PatchFlags.BAIL,
   )
   if (!noSlotted && rendered.scopeId) {
     rendered.slotScopeIds = [rendered.scopeId + '-s']
index 3aedcee47eeb42b7c2ebfcdf62a50ba7468a4edd..f44e9c530e2cf983213c560be1cc909274eec2c4 100644 (file)
@@ -1,14 +1,14 @@
 import {
+  type ComponentOptions,
+  type ConcreteComponent,
   currentInstance,
-  ConcreteComponent,
-  ComponentOptions,
-  getComponentName
+  getComponentName,
 } from '../component'
 import { currentRenderingInstance } from '../componentRenderContext'
-import { Directive } from '../directives'
+import type { Directive } from '../directives'
 import { camelize, capitalize, isString } from '@vue/shared'
 import { warn } from '../warning'
-import { VNodeTypes } from '../vnode'
+import type { VNodeTypes } from '../vnode'
 
 export const COMPONENTS = 'components'
 export const DIRECTIVES = 'directives'
@@ -21,7 +21,7 @@ export type AssetTypes = typeof COMPONENTS | typeof DIRECTIVES | typeof FILTERS
  */
 export function resolveComponent(
   name: string,
-  maybeSelfReference?: boolean
+  maybeSelfReference?: boolean,
 ): ConcreteComponent | string {
   return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name
 }
@@ -63,12 +63,12 @@ function resolveAsset(
   type: typeof COMPONENTS,
   name: string,
   warnMissing?: boolean,
-  maybeSelfReference?: boolean
+  maybeSelfReference?: boolean,
 ): ConcreteComponent | undefined
 // overload 2: directives
 function resolveAsset(
   type: typeof DIRECTIVES,
-  name: string
+  name: string,
 ): Directive | undefined
 // implementation
 // overload 3: filters (compat only)
@@ -78,7 +78,7 @@ function resolveAsset(
   type: AssetTypes,
   name: string,
   warnMissing = true,
-  maybeSelfReference = false
+  maybeSelfReference = false,
 ) {
   const instance = currentRenderingInstance || currentInstance
   if (instance) {
@@ -88,7 +88,7 @@ function resolveAsset(
     if (type === COMPONENTS) {
       const selfName = getComponentName(
         Component,
-        false /* do not include inferred name to avoid breaking existing code */
+        false /* do not include inferred name to avoid breaking existing code */,
       )
       if (
         selfName &&
@@ -125,7 +125,7 @@ function resolveAsset(
   } else if (__DEV__) {
     warn(
       `resolve${capitalize(type.slice(0, -1))} ` +
-        `can only be used in render() or setup().`
+        `can only be used in render() or setup().`,
     )
   }
 }
index 78ad164d7c02017e35ea8e12572f416da0b274d6..3e7dcb327f59bb5a0e4eb21bf503c9d3e30f4407 100644 (file)
@@ -1,4 +1,4 @@
-import { toHandlerKey, isObject } from '@vue/shared'
+import { isObject, toHandlerKey } from '@vue/shared'
 import { warn } from '../warning'
 
 /**
@@ -7,7 +7,7 @@ import { warn } from '../warning'
  */
 export function toHandlers(
   obj: Record<string, any>,
-  preserveCaseIfNecessary?: boolean
+  preserveCaseIfNecessary?: boolean,
 ): Record<string, any> {
   const ret: Record<string, any> = {}
   if (__DEV__ && !isObject(obj)) {
index 501a18e3bb5a3c16f979e325b78519745b4c4da2..3ff4a097b12a4aa7a287d119af9f9da59695784b 100644 (file)
@@ -10,7 +10,7 @@ export const useSSRContext = <T = Record<string, any>>() => {
       __DEV__ &&
         warn(
           `Server rendering context not provided. Make sure to only call ` +
-            `useSSRContext() conditionally in the server build.`
+            `useSSRContext() conditionally in the server build.`,
         )
     }
     return ctx
index 76b0f055f39a8ad6b93999831cd750eef36b21d5..97fbad31fb99e49982cc223a1a0e8d98c0ecd6f5 100644 (file)
@@ -1,11 +1,11 @@
 import { hasChanged } from '@vue/shared'
-import { currentBlock, isBlockTreeEnabled, VNode } from '../vnode'
+import { type VNode, currentBlock, isBlockTreeEnabled } from '../vnode'
 
 export function withMemo(
   memo: any[],
   render: () => VNode<any, any>,
   cache: any[],
-  index: number
+  index: number,
 ) {
   const cached = cache[index] as VNode | undefined
   if (cached && isMemoSame(cached, memo)) {
index cdf291989bda29f0614457c6f87ada8b1f099dc2..b5904a4fc5baf40cbbeb95d57f1a8d3b8c6b93f7 100644 (file)
@@ -1,11 +1,11 @@
 /* eslint-disable no-restricted-globals */
 import {
-  ConcreteComponent,
-  ComponentInternalInstance,
-  ComponentOptions,
-  InternalRenderFunction,
-  ClassComponent,
-  isClassComponent
+  type ClassComponent,
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type ConcreteComponent,
+  type InternalRenderFunction,
+  isClassComponent,
 } from './component'
 import { queueJob, queuePostFlushCb } from './scheduler'
 import { extend, getGlobalThis } from '@vue/shared'
@@ -31,7 +31,7 @@ if (__DEV__) {
   getGlobalThis().__VUE_HMR_RUNTIME__ = {
     createRecord: tryWrap(createRecord),
     rerender: tryWrap(rerender),
-    reload: tryWrap(reload)
+    reload: tryWrap(reload),
   } as HMRRuntime
 }
 
@@ -66,7 +66,7 @@ function createRecord(id: string, initialDef: HMRComponent): boolean {
   }
   map.set(id, {
     initialDef: normalizeClassComponent(initialDef),
-    instances: new Set()
+    instances: new Set(),
   })
   return true
 }
@@ -148,7 +148,7 @@ function reload(id: string, newComp: HMRComponent) {
       window.location.reload()
     } else {
       console.warn(
-        '[HMR] Root or manually mounted instance modified. Full reload required.'
+        '[HMR] Root or manually mounted instance modified. Full reload required.',
       )
     }
   }
@@ -157,7 +157,7 @@ function reload(id: string, newComp: HMRComponent) {
   queuePostFlushCb(() => {
     for (const instance of instances) {
       hmrDirtyComponents.delete(
-        normalizeClassComponent(instance.type as HMRComponent)
+        normalizeClassComponent(instance.type as HMRComponent),
       )
     }
   })
@@ -165,7 +165,7 @@ function reload(id: string, newComp: HMRComponent) {
 
 function updateComponentDef(
   oldComp: ComponentOptions,
-  newComp: ComponentOptions
+  newComp: ComponentOptions,
 ) {
   extend(oldComp, newComp)
   for (const key in oldComp) {
@@ -183,7 +183,7 @@ function tryWrap(fn: (id: string, arg: any) => any): Function {
       console.error(e)
       console.warn(
         `[HMR] Something went wrong during Vue component hot-reload. ` +
-          `Full reload required.`
+          `Full reload required.`,
       )
     }
   }
index d42a9952f25145aec1128374399961dc8e00fb66..c2086af8f4eb218d9be0045aa046b167519ab4e7 100644 (file)
@@ -1,52 +1,52 @@
 import {
-  VNode,
-  normalizeVNode,
-  Text,
   Comment,
-  Static,
   Fragment,
-  VNodeHook,
-  createVNode,
+  Static,
+  Text,
+  type VNode,
+  type VNodeHook,
   createTextVNode,
-  invokeVNodeHook
+  createVNode,
+  invokeVNodeHook,
+  normalizeVNode,
 } from './vnode'
 import { flushPostFlushCbs } from './scheduler'
-import { ComponentInternalInstance } from './component'
+import type { ComponentInternalInstance } from './component'
 import { invokeDirectiveHook } from './directives'
 import { warn } from './warning'
 import {
   PatchFlags,
   ShapeFlags,
-  isReservedProp,
+  includeBooleanAttr,
+  isBooleanAttr,
+  isKnownHtmlAttr,
+  isKnownSvgAttr,
   isOn,
+  isReservedProp,
+  isString,
   normalizeClass,
   normalizeStyle,
   stringifyStyle,
-  isBooleanAttr,
-  isString,
-  includeBooleanAttr,
-  isKnownHtmlAttr,
-  isKnownSvgAttr
 } from '@vue/shared'
-import { needTransition, RendererInternals } from './renderer'
+import { type RendererInternals, needTransition } from './renderer'
 import { setRef } from './rendererTemplateRef'
 import {
-  SuspenseImpl,
-  SuspenseBoundary,
-  queueEffectWithSuspense
+  type SuspenseBoundary,
+  type SuspenseImpl,
+  queueEffectWithSuspense,
 } from './components/Suspense'
-import { TeleportImpl, TeleportVNode } from './components/Teleport'
+import type { TeleportImpl, TeleportVNode } from './components/Teleport'
 import { isAsyncWrapper } from './apiAsyncComponent'
 
 export type RootHydrateFunction = (
   vnode: VNode<Node, Element>,
-  container: (Element | ShadowRoot) & { _vnode?: VNode }
+  container: (Element | ShadowRoot) & { _vnode?: VNode },
 ) => void
 
 enum DOMNodeTypes {
   ELEMENT = 1,
   TEXT = 3,
-  COMMENT = 8
+  COMMENT = 8,
 }
 
 let hasMismatch = false
@@ -73,7 +73,7 @@ const isComment = (node: Node): node is Comment =>
 // Hydration also depends on some renderer internal logic which needs to be
 // passed in via arguments.
 export function createHydrationFunctions(
-  rendererInternals: RendererInternals<Node, Element>
+  rendererInternals: RendererInternals<Node, Element>,
 ) {
   const {
     mt: mountComponent,
@@ -85,8 +85,8 @@ export function createHydrationFunctions(
       parentNode,
       remove,
       insert,
-      createComment
-    }
+      createComment,
+    },
   } = rendererInternals
 
   const hydrate: RootHydrateFunction = (vnode, container) => {
@@ -94,7 +94,7 @@ export function createHydrationFunctions(
       ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) &&
         warn(
           `Attempting to hydrate existing markup but container is empty. ` +
-            `Performing full mount instead.`
+            `Performing full mount instead.`,
         )
       patch(null, vnode, container)
       flushPostFlushCbs()
@@ -117,7 +117,7 @@ export function createHydrationFunctions(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    optimized = false
+    optimized = false,
   ): Node | null => {
     const isFragmentStart = isComment(node) && node.data === '['
     const onMismatch = () =>
@@ -127,7 +127,7 @@ export function createHydrationFunctions(
         parentComponent,
         parentSuspense,
         slotScopeIds,
-        isFragmentStart
+        isFragmentStart,
       )
 
     const { type, ref, shapeFlag, patchFlag } = vnode
@@ -138,13 +138,13 @@ export function createHydrationFunctions(
       if (!('__vnode' in node)) {
         Object.defineProperty(node, '__vnode', {
           value: vnode,
-          enumerable: false
+          enumerable: false,
         })
       }
       if (!('__vueParentComponent' in node)) {
         Object.defineProperty(node, '__vueParentComponent', {
           value: parentComponent,
-          enumerable: false
+          enumerable: false,
         })
       }
     }
@@ -174,9 +174,9 @@ export function createHydrationFunctions(
                 `Hydration text mismatch in`,
                 node.parentNode,
                 `\n  - rendered on server: ${JSON.stringify(
-                  (node as Text).data
+                  (node as Text).data,
                 )}` +
-                  `\n  - expected on client: ${JSON.stringify(vnode.children)}`
+                  `\n  - expected on client: ${JSON.stringify(vnode.children)}`,
               )
             ;(node as Text).data = vnode.children as string
           }
@@ -191,7 +191,7 @@ export function createHydrationFunctions(
           replaceNode(
             (vnode.el = node.content.firstChild!),
             node,
-            parentComponent
+            parentComponent,
           )
         } else if (domType !== DOMNodeTypes.COMMENT || isFragmentStart) {
           nextNode = onMismatch()
@@ -237,7 +237,7 @@ export function createHydrationFunctions(
             parentComponent,
             parentSuspense,
             slotScopeIds,
-            optimized
+            optimized,
           )
         }
         break
@@ -257,7 +257,7 @@ export function createHydrationFunctions(
               parentComponent,
               parentSuspense,
               slotScopeIds,
-              optimized
+              optimized,
             )
           }
         } else if (shapeFlag & ShapeFlags.COMPONENT) {
@@ -288,7 +288,7 @@ export function createHydrationFunctions(
             parentComponent,
             parentSuspense,
             getContainerType(container),
-            optimized
+            optimized,
           )
 
           // #3787
@@ -321,7 +321,7 @@ export function createHydrationFunctions(
               slotScopeIds,
               optimized,
               rendererInternals,
-              hydrateChildren
+              hydrateChildren,
             )
           }
         } else if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) {
@@ -334,7 +334,7 @@ export function createHydrationFunctions(
             slotScopeIds,
             optimized,
             rendererInternals,
-            hydrateNode
+            hydrateNode,
           )
         } else if (__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) {
           warn('Invalid HostVNode type:', type, `(${typeof type})`)
@@ -354,7 +354,7 @@ export function createHydrationFunctions(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     optimized = optimized || !!vnode.dynamicChildren
     const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode
@@ -403,7 +403,7 @@ export function createHydrationFunctions(
           parentComponent,
           parentSuspense,
           slotScopeIds,
-          optimized
+          optimized,
         )
         let hasWarned = false
         while (next) {
@@ -415,7 +415,7 @@ export function createHydrationFunctions(
             warn(
               `Hydration children mismatch on`,
               el,
-              `\nServer rendered element contains more child nodes than client vdom.`
+              `\nServer rendered element contains more child nodes than client vdom.`,
             )
             hasWarned = true
           }
@@ -432,7 +432,7 @@ export function createHydrationFunctions(
               `Hydration text content mismatch on`,
               el,
               `\n  - rendered on server: ${el.textContent}` +
-                `\n  - expected on client: ${vnode.children as string}`
+                `\n  - expected on client: ${vnode.children as string}`,
             )
           el.textContent = vnode.children as string
         }
@@ -465,7 +465,7 @@ export function createHydrationFunctions(
                 props[key],
                 undefined,
                 undefined,
-                parentComponent
+                parentComponent,
               )
             }
           }
@@ -479,7 +479,7 @@ export function createHydrationFunctions(
             props.onClick,
             undefined,
             undefined,
-            parentComponent
+            parentComponent,
           )
         }
       }
@@ -515,7 +515,7 @@ export function createHydrationFunctions(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ): Node | null => {
     optimized = optimized || !!parentVNode.dynamicChildren
     const children = parentVNode.children as VNode[]
@@ -532,7 +532,7 @@ export function createHydrationFunctions(
           parentComponent,
           parentSuspense,
           slotScopeIds,
-          optimized
+          optimized,
         )
       } else if (vnode.type === Text && !vnode.children) {
         continue
@@ -545,7 +545,7 @@ export function createHydrationFunctions(
           warn(
             `Hydration children mismatch on`,
             container,
-            `\nServer rendered element contains fewer child nodes than client vdom.`
+            `\nServer rendered element contains fewer child nodes than client vdom.`,
           )
           hasWarned = true
         }
@@ -558,7 +558,7 @@ export function createHydrationFunctions(
           parentComponent,
           parentSuspense,
           getContainerType(container),
-          slotScopeIds
+          slotScopeIds,
         )
       }
     }
@@ -571,7 +571,7 @@ export function createHydrationFunctions(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     const { slotScopeIds: fragmentSlotScopeIds } = vnode
     if (fragmentSlotScopeIds) {
@@ -588,7 +588,7 @@ export function createHydrationFunctions(
       parentComponent,
       parentSuspense,
       slotScopeIds,
-      optimized
+      optimized,
     )
     if (next && isComment(next) && next.data === ']') {
       return nextSibling((vnode.anchor = next))
@@ -608,7 +608,7 @@ export function createHydrationFunctions(
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
     slotScopeIds: string[] | null,
-    isFragment: boolean
+    isFragment: boolean,
   ): Node | null => {
     hasMismatch = true
     ;(__DEV__ || __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__) &&
@@ -621,7 +621,7 @@ export function createHydrationFunctions(
             ? `(start of fragment)`
             : ``,
         `\n- expected on client:`,
-        vnode.type
+        vnode.type,
       )
     vnode.el = null
 
@@ -650,7 +650,7 @@ export function createHydrationFunctions(
       parentComponent,
       parentSuspense,
       getContainerType(container),
-      slotScopeIds
+      slotScopeIds,
     )
     return next
   }
@@ -659,7 +659,7 @@ export function createHydrationFunctions(
   const locateClosingAnchor = (
     node: Node | null,
     open = '[',
-    close = ']'
+    close = ']',
   ): Node | null => {
     let match = 0
     while (node) {
@@ -681,7 +681,7 @@ export function createHydrationFunctions(
   const replaceNode = (
     newNode: Node,
     oldNode: Node,
-    parentComponent: ComponentInternalInstance | null
+    parentComponent: ComponentInternalInstance | null,
   ): void => {
     // replace node
     const parentNode = oldNode.parentNode
@@ -761,7 +761,7 @@ function propHasMismatch(el: Element, key: string, clientValue: any): boolean {
         `\n  - expected on client: ${format(expected)}` +
         `\n  Note: this mismatch is check-only. The DOM will not be rectified ` +
         `in production due to performance overhead.` +
-        `\n  You should fix the source of the mismatch.`
+        `\n  You should fix the source of the mismatch.`,
     )
     return true
   }
index fc20b37162de531cb82095c34d204fd335354ea9..b69344d7ce7d27134e16c243fdf9ef4ed7fcecec 100644 (file)
@@ -33,14 +33,14 @@ export {
   effectScope,
   EffectScope,
   getCurrentScope,
-  onScopeDispose
+  onScopeDispose,
 } from '@vue/reactivity'
 export { computed } from './apiComputed'
 export {
   watch,
   watchEffect,
   watchPostEffect,
-  watchSyncEffect
+  watchSyncEffect,
 } from './apiWatch'
 export {
   onBeforeMount,
@@ -54,7 +54,7 @@ export {
   onRenderTracked,
   onRenderTriggered,
   onErrorCaptured,
-  onServerPrefetch
+  onServerPrefetch,
 } from './apiLifecycle'
 export { provide, inject, hasInjectionContext } from './apiInject'
 export { nextTick } from './scheduler'
@@ -73,7 +73,7 @@ export {
   defineSlots,
   defineModel,
   withDefaults,
-  useModel
+  useModel,
 } from './apiSetupHelpers'
 
 /**
@@ -83,7 +83,7 @@ export {
   mergeDefaults,
   mergeModels,
   createPropsRestProxy,
-  withAsyncContext
+  withAsyncContext,
 } from './apiSetupHelpers'
 
 // Advanced API ----------------------------------------------------------------
@@ -105,7 +105,7 @@ export { KeepAlive, type KeepAliveProps } from './components/KeepAlive'
 export {
   BaseTransition,
   BaseTransitionPropsValidators,
-  type BaseTransitionProps
+  type BaseTransitionProps,
 } from './components/BaseTransition'
 // For using custom directives
 export { withDirectives } from './directives'
@@ -125,12 +125,12 @@ export {
   handleError,
   callWithErrorHandling,
   callWithAsyncErrorHandling,
-  ErrorCodes
+  ErrorCodes,
 } from './errorHandling'
 export {
   resolveComponent,
   resolveDirective,
-  resolveDynamicComponent
+  resolveDynamicComponent,
 } from './helpers/resolveAssets'
 // For integration with runtime compiler
 export { registerRuntimeCompiler, isRuntimeOnly } from './component'
@@ -138,7 +138,7 @@ export {
   useTransitionState,
   resolveTransitionHooks,
   setTransitionHooks,
-  getTransitionRawChildren
+  getTransitionRawChildren,
 } from './components/BaseTransition'
 export { initCustomFormatter } from './customFormatter'
 
@@ -153,9 +153,9 @@ export const ErrorTypeStrings = (
 
 // For devtools
 import {
+  type DevtoolsHook,
   devtools as _devtools,
   setDevtoolsHook as _setDevtoolsHook,
-  DevtoolsHook
 } from './devtools'
 
 export const devtools = (
@@ -167,8 +167,8 @@ export const setDevtoolsHook = (
 
 // Types -------------------------------------------------------------------------
 
-import { VNode } from './vnode'
-import { ComponentInternalInstance } from './component'
+import type { VNode } from './vnode'
+import type { ComponentInternalInstance } from './component'
 
 // Augment Ref unwrap bail types.
 declare module '@vue/reactivity' {
@@ -209,7 +209,7 @@ export type {
   DebuggerOptions,
   DebuggerEvent,
   DebuggerEventExtraInfo,
-  Raw
+  Raw,
 } from '@vue/reactivity'
 export type {
   WatchEffect,
@@ -217,7 +217,7 @@ export type {
   WatchOptionsBase,
   WatchCallback,
   WatchSource,
-  WatchStopHandle
+  WatchStopHandle,
 } from './apiWatch'
 export type { InjectionKey } from './apiInject'
 export type {
@@ -228,7 +228,7 @@ export type {
   ObjectPlugin,
   FunctionPlugin,
   CreateAppFunction,
-  OptionMergeFunction
+  OptionMergeFunction,
 } from './apiCreateApp'
 export type {
   VNode,
@@ -236,7 +236,7 @@ export type {
   VNodeTypes,
   VNodeProps,
   VNodeArrayChildren,
-  VNodeNormalizedChildren
+  VNodeNormalizedChildren,
 } from './vnode'
 export type {
   Component,
@@ -246,7 +246,7 @@ export type {
   SetupContext,
   ComponentCustomProps,
   AllowedComponentProps,
-  ComponentInstance
+  ComponentInstance,
 } from './component'
 export type { DefineComponent, PublicProps } from './apiDefineComponent'
 export type {
@@ -262,13 +262,13 @@ export type {
   MethodOptions,
   ComputedOptions,
   RuntimeCompilerOptions,
-  ComponentInjectOptions
+  ComponentInjectOptions,
 } from './componentOptions'
 export type { EmitsOptions, ObjectEmitsOptions } from './componentEmits'
 export type {
   ComponentPublicInstance,
   ComponentCustomProperties,
-  CreateComponentPublicInstance
+  CreateComponentPublicInstance,
 } from './componentPublicInstance'
 export type {
   Renderer,
@@ -277,7 +277,7 @@ export type {
   HydrationRenderer,
   RendererOptions,
   RootRenderFunction,
-  ElementNamespace
+  ElementNamespace,
 } from './renderer'
 export type { RootHydrateFunction } from './hydration'
 export type { Slot, Slots, SlotsType } from './componentSlots'
@@ -288,7 +288,7 @@ export type {
   ComponentObjectPropsOptions,
   ExtractPropTypes,
   ExtractPublicPropTypes,
-  ExtractDefaultPropTypes
+  ExtractDefaultPropTypes,
 } from './componentProps'
 export type {
   Directive,
@@ -296,16 +296,16 @@ export type {
   DirectiveHook,
   ObjectDirective,
   FunctionDirective,
-  DirectiveArguments
+  DirectiveArguments,
 } from './directives'
 export type { SuspenseBoundary } from './components/Suspense'
 export type {
   TransitionState,
-  TransitionHooks
+  TransitionHooks,
 } from './components/BaseTransition'
 export type {
   AsyncComponentOptions,
-  AsyncComponentLoader
+  AsyncComponentLoader,
 } from './apiAsyncComponent'
 export type { HMRRuntime } from './hmr'
 
@@ -320,7 +320,7 @@ export {
   withCtx,
   pushScopeId,
   popScopeId,
-  withScopeId
+  withScopeId,
 } from './componentRenderContext'
 export { renderList } from './helpers/renderList'
 export { toHandlers } from './helpers/toHandlers'
@@ -336,7 +336,7 @@ export {
   createStaticVNode,
   createElementVNode,
   createElementBlock,
-  guardReactiveProps
+  guardReactiveProps,
 } from './vnode'
 export {
   toDisplayString,
@@ -345,7 +345,7 @@ export {
   toHandlerKey,
   normalizeProps,
   normalizeClass,
-  normalizeStyle
+  normalizeStyle,
 } from '@vue/shared'
 
 // For test-utils
@@ -367,7 +367,7 @@ const _ssrUtils = {
   renderComponentRoot,
   setCurrentRenderingInstance,
   isVNode,
-  normalizeVNode
+  normalizeVNode,
 }
 
 /**
@@ -385,9 +385,9 @@ export type { LegacyConfig } from './compat/globalConfig'
 import { warnDeprecation } from './compat/compatConfig'
 import { createCompatVue } from './compat/global'
 import {
-  isCompatEnabled,
   checkCompatEnabled,
-  softAssertCompatEnabled
+  isCompatEnabled,
+  softAssertCompatEnabled,
 } from './compat/compatConfig'
 import { resolveFilter as _resolveFilter } from './helpers/resolveAssets'
 import { NOOP } from '@vue/shared'
@@ -402,7 +402,7 @@ const _compatUtils = {
   createCompatVue,
   isCompatEnabled,
   checkCompatEnabled,
-  softAssertCompatEnabled
+  softAssertCompatEnabled,
 }
 
 /**
index 9b0f985262239d24e5ef5f0aef326fd45dfa7ef9..f87b7f472a90a892c916b63387dc7c5702bd54a8 100644 (file)
@@ -1,5 +1,8 @@
 /* eslint-disable no-restricted-globals */
-import { ComponentInternalInstance, formatComponentName } from './component'
+import {
+  type ComponentInternalInstance,
+  formatComponentName,
+} from './component'
 import { devtoolsPerfEnd, devtoolsPerfStart } from './devtools'
 
 let supported: boolean
@@ -7,7 +10,7 @@ let perf: Performance
 
 export function startMeasure(
   instance: ComponentInternalInstance,
-  type: string
+  type: string,
 ) {
   if (instance.appContext.config.performance && isSupported()) {
     perf.mark(`vue-${type}-${instance.uid}`)
@@ -26,7 +29,7 @@ export function endMeasure(instance: ComponentInternalInstance, type: string) {
     perf.measure(
       `<${formatComponentName(instance, instance.type)}> ${type}`,
       startTag,
-      endTag
+      endTag,
     )
     perf.clearMarks(startTag)
     perf.clearMarks(endTag)
index 62b215eea883b51870bd66cffa43c48846a7eca5..fa1f08c3c9c8a03ee5cbea6ca67e40f92bd1d0a3 100644 (file)
@@ -1,78 +1,78 @@
 import {
-  Text,
-  Fragment,
   Comment,
+  Fragment,
+  Static,
+  Text,
+  type VNode,
+  type VNodeArrayChildren,
+  type VNodeHook,
+  type VNodeProps,
   cloneIfMounted,
-  normalizeVNode,
-  VNode,
-  VNodeArrayChildren,
   createVNode,
+  invokeVNodeHook,
   isSameVNodeType,
-  Static,
-  VNodeHook,
-  VNodeProps,
-  invokeVNodeHook
+  normalizeVNode,
 } from './vnode'
 import {
-  ComponentInternalInstance,
-  ComponentOptions,
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type Data,
   createComponentInstance,
-  Data,
-  setupComponent
+  setupComponent,
 } from './component'
 import {
   filterSingleRoot,
   renderComponentRoot,
   shouldUpdateComponent,
-  updateHOCHostEl
+  updateHOCHostEl,
 } from './componentRenderUtils'
 import {
-  EMPTY_OBJ,
   EMPTY_ARR,
-  isReservedProp,
+  EMPTY_OBJ,
+  NOOP,
   PatchFlags,
   ShapeFlags,
-  NOOP,
+  getGlobalThis,
   invokeArrayFns,
   isArray,
-  getGlobalThis
+  isReservedProp,
 } from '@vue/shared'
 import {
-  queueJob,
-  queuePostFlushCb,
+  type SchedulerJob,
   flushPostFlushCbs,
-  invalidateJob,
   flushPreFlushCbs,
-  SchedulerJob
+  invalidateJob,
+  queueJob,
+  queuePostFlushCb,
 } from './scheduler'
-import { pauseTracking, resetTracking, ReactiveEffect } from '@vue/reactivity'
+import { ReactiveEffect, pauseTracking, resetTracking } from '@vue/reactivity'
 import { updateProps } from './componentProps'
 import { updateSlots } from './componentSlots'
-import { pushWarningContext, popWarningContext, warn } from './warning'
-import { createAppAPI, CreateAppFunction } from './apiCreateApp'
+import { popWarningContext, pushWarningContext, warn } from './warning'
+import { type CreateAppFunction, createAppAPI } from './apiCreateApp'
 import { setRef } from './rendererTemplateRef'
 import {
-  SuspenseBoundary,
+  type SuspenseBoundary,
+  type SuspenseImpl,
   queueEffectWithSuspense,
-  SuspenseImpl
 } from './components/Suspense'
-import { TeleportImpl, TeleportVNode } from './components/Teleport'
-import { isKeepAlive, KeepAliveContext } from './components/KeepAlive'
-import { registerHMR, unregisterHMR, isHmrUpdating } from './hmr'
-import { createHydrationFunctions, RootHydrateFunction } from './hydration'
+import type { TeleportImpl, TeleportVNode } from './components/Teleport'
+import { type KeepAliveContext, isKeepAlive } from './components/KeepAlive'
+import { isHmrUpdating, registerHMR, unregisterHMR } from './hmr'
+import { type RootHydrateFunction, createHydrationFunctions } from './hydration'
 import { invokeDirectiveHook } from './directives'
-import { startMeasure, endMeasure } from './profiling'
+import { endMeasure, startMeasure } from './profiling'
 import {
   devtoolsComponentAdded,
   devtoolsComponentRemoved,
   devtoolsComponentUpdated,
-  setDevtoolsHook
+  setDevtoolsHook,
 } from './devtools'
 import { initFeatureFlags } from './featureFlags'
 import { isAsyncWrapper } from './apiAsyncComponent'
 import { isCompatEnabled } from './compat/compatConfig'
 import { DeprecationTypes } from './compat/compatConfig'
-import { TransitionHooks } from './components/BaseTransition'
+import type { TransitionHooks } from './components/BaseTransition'
 
 export interface Renderer<HostElement = RendererElement> {
   render: RootRenderFunction<HostElement>
@@ -88,12 +88,12 @@ export type ElementNamespace = 'svg' | 'mathml' | undefined
 export type RootRenderFunction<HostElement = RendererElement> = (
   vnode: VNode | null,
   container: HostElement,
-  namespace?: ElementNamespace
+  namespace?: ElementNamespace,
 ) => void
 
 export interface RendererOptions<
   HostNode = RendererNode,
-  HostElement = RendererElement
+  HostElement = RendererElement,
 > {
   patchProp(
     el: HostElement,
@@ -104,7 +104,7 @@ export interface RendererOptions<
     prevChildren?: VNode<HostNode, HostElement>[],
     parentComponent?: ComponentInternalInstance | null,
     parentSuspense?: SuspenseBoundary | null,
-    unmountChildren?: UnmountChildrenFn
+    unmountChildren?: UnmountChildrenFn,
   ): void
   insert(el: HostNode, parent: HostElement, anchor?: HostNode | null): void
   remove(el: HostNode): void
@@ -112,7 +112,7 @@ export interface RendererOptions<
     type: string,
     namespace?: ElementNamespace,
     isCustomizedBuiltIn?: string,
-    vnodeProps?: (VNodeProps & { [key: string]: any }) | null
+    vnodeProps?: (VNodeProps & { [key: string]: any }) | null,
   ): HostElement
   createText(text: string): HostNode
   createComment(text: string): HostNode
@@ -129,7 +129,7 @@ export interface RendererOptions<
     anchor: HostNode | null,
     namespace: ElementNamespace,
     start?: HostNode | null,
-    end?: HostNode | null
+    end?: HostNode | null,
   ): [HostNode, HostNode]
 }
 
@@ -148,7 +148,7 @@ export interface RendererElement extends RendererNode {}
 // to optimize bundle size.
 export interface RendererInternals<
   HostNode = RendererNode,
-  HostElement = RendererElement
+  HostElement = RendererElement,
 > {
   p: PatchFn
   um: UnmountFn
@@ -174,7 +174,7 @@ type PatchFn = (
   parentSuspense?: SuspenseBoundary | null,
   namespace?: ElementNamespace,
   slotScopeIds?: string[] | null,
-  optimized?: boolean
+  optimized?: boolean,
 ) => void
 
 type MountChildrenFn = (
@@ -186,7 +186,7 @@ type MountChildrenFn = (
   namespace: ElementNamespace,
   slotScopeIds: string[] | null,
   optimized: boolean,
-  start?: number
+  start?: number,
 ) => void
 
 type PatchChildrenFn = (
@@ -198,7 +198,7 @@ type PatchChildrenFn = (
   parentSuspense: SuspenseBoundary | null,
   namespace: ElementNamespace,
   slotScopeIds: string[] | null,
-  optimized: boolean
+  optimized: boolean,
 ) => void
 
 type PatchBlockChildrenFn = (
@@ -208,7 +208,7 @@ type PatchBlockChildrenFn = (
   parentComponent: ComponentInternalInstance | null,
   parentSuspense: SuspenseBoundary | null,
   namespace: ElementNamespace,
-  slotScopeIds: string[] | null
+  slotScopeIds: string[] | null,
 ) => void
 
 type MoveFn = (
@@ -216,7 +216,7 @@ type MoveFn = (
   container: RendererElement,
   anchor: RendererNode | null,
   type: MoveType,
-  parentSuspense?: SuspenseBoundary | null
+  parentSuspense?: SuspenseBoundary | null,
 ) => void
 
 type NextFn = (vnode: VNode) => RendererNode | null
@@ -226,7 +226,7 @@ type UnmountFn = (
   parentComponent: ComponentInternalInstance | null,
   parentSuspense: SuspenseBoundary | null,
   doRemove?: boolean,
-  optimized?: boolean
+  optimized?: boolean,
 ) => void
 
 type RemoveFn = (vnode: VNode) => void
@@ -237,7 +237,7 @@ type UnmountChildrenFn = (
   parentSuspense: SuspenseBoundary | null,
   doRemove?: boolean,
   optimized?: boolean,
-  start?: number
+  start?: number,
 ) => void
 
 export type MountComponentFn = (
@@ -247,14 +247,14 @@ export type MountComponentFn = (
   parentComponent: ComponentInternalInstance | null,
   parentSuspense: SuspenseBoundary | null,
   namespace: ElementNamespace,
-  optimized: boolean
+  optimized: boolean,
 ) => void
 
 type ProcessTextOrCommentFn = (
   n1: VNode | null,
   n2: VNode,
   container: RendererElement,
-  anchor: RendererNode | null
+  anchor: RendererNode | null,
 ) => void
 
 export type SetupRenderEffectFn = (
@@ -264,13 +264,13 @@ export type SetupRenderEffectFn = (
   anchor: RendererNode | null,
   parentSuspense: SuspenseBoundary | null,
   namespace: ElementNamespace,
-  optimized: boolean
+  optimized: boolean,
 ) => void
 
 export enum MoveType {
   ENTER,
   LEAVE,
-  REORDER
+  REORDER,
 }
 
 export const queuePostRenderEffect = __FEATURE_SUSPENSE__
@@ -298,7 +298,7 @@ export const queuePostRenderEffect = __FEATURE_SUSPENSE__
  */
 export function createRenderer<
   HostNode = RendererNode,
-  HostElement = RendererElement
+  HostElement = RendererElement,
 >(options: RendererOptions<HostNode, HostElement>) {
   return baseCreateRenderer<HostNode, HostElement>(options)
 }
@@ -307,7 +307,7 @@ export function createRenderer<
 // Hydration logic is only used when calling this function, making it
 // tree-shakable.
 export function createHydrationRenderer(
-  options: RendererOptions<Node, Element>
+  options: RendererOptions<Node, Element>,
 ) {
   return baseCreateRenderer(options, createHydrationFunctions)
 }
@@ -315,19 +315,19 @@ export function createHydrationRenderer(
 // overload 1: no hydration
 function baseCreateRenderer<
   HostNode = RendererNode,
-  HostElement = RendererElement
+  HostElement = RendererElement,
 >(options: RendererOptions<HostNode, HostElement>): Renderer<HostElement>
 
 // overload 2: with hydration
 function baseCreateRenderer(
   options: RendererOptions<Node, Element>,
-  createHydrationFns: typeof createHydrationFunctions
+  createHydrationFns: typeof createHydrationFunctions,
 ): HydrationRenderer
 
 // implementation
 function baseCreateRenderer(
   options: RendererOptions,
-  createHydrationFns?: typeof createHydrationFunctions
+  createHydrationFns?: typeof createHydrationFunctions,
 ): any {
   // compile-time feature flags check
   if (__ESM_BUNDLER__ && !__TEST__) {
@@ -352,7 +352,7 @@ function baseCreateRenderer(
     parentNode: hostParentNode,
     nextSibling: hostNextSibling,
     setScopeId: hostSetScopeId = NOOP,
-    insertStaticContent: hostInsertStaticContent
+    insertStaticContent: hostInsertStaticContent,
   } = options
 
   // Note: functions inside this closure should use `const xxx = () => {}`
@@ -366,7 +366,7 @@ function baseCreateRenderer(
     parentSuspense = null,
     namespace = undefined,
     slotScopeIds = null,
-    optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren
+    optimized = __DEV__ && isHmrUpdating ? false : !!n2.dynamicChildren,
   ) => {
     if (n1 === n2) {
       return
@@ -409,7 +409,7 @@ function baseCreateRenderer(
           parentSuspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         break
       default:
@@ -423,7 +423,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
         } else if (shapeFlag & ShapeFlags.COMPONENT) {
           processComponent(
@@ -435,7 +435,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
         } else if (shapeFlag & ShapeFlags.TELEPORT) {
           ;(type as typeof TeleportImpl).process(
@@ -448,7 +448,7 @@ function baseCreateRenderer(
             namespace,
             slotScopeIds,
             optimized,
-            internals
+            internals,
           )
         } else if (__FEATURE_SUSPENSE__ && shapeFlag & ShapeFlags.SUSPENSE) {
           ;(type as typeof SuspenseImpl).process(
@@ -461,7 +461,7 @@ function baseCreateRenderer(
             namespace,
             slotScopeIds,
             optimized,
-            internals
+            internals,
           )
         } else if (__DEV__) {
           warn('Invalid VNode type:', type, `(${typeof type})`)
@@ -479,7 +479,7 @@ function baseCreateRenderer(
       hostInsert(
         (n2.el = hostCreateText(n2.children as string)),
         container,
-        anchor
+        anchor,
       )
     } else {
       const el = (n2.el = n1.el!)
@@ -493,13 +493,13 @@ function baseCreateRenderer(
     n1,
     n2,
     container,
-    anchor
+    anchor,
   ) => {
     if (n1 == null) {
       hostInsert(
         (n2.el = hostCreateComment((n2.children as string) || '')),
         container,
-        anchor
+        anchor,
       )
     } else {
       // there's no support for dynamic comments
@@ -511,7 +511,7 @@ function baseCreateRenderer(
     n2: VNode,
     container: RendererElement,
     anchor: RendererNode | null,
-    namespace: ElementNamespace
+    namespace: ElementNamespace,
   ) => {
     // static nodes are only present when used with compiler-dom/runtime-dom
     // which guarantees presence of hostInsertStaticContent.
@@ -521,7 +521,7 @@ function baseCreateRenderer(
       anchor,
       namespace,
       n2.el,
-      n2.anchor
+      n2.anchor,
     )
   }
 
@@ -532,7 +532,7 @@ function baseCreateRenderer(
     n1: VNode,
     n2: VNode,
     container: RendererElement,
-    namespace: ElementNamespace
+    namespace: ElementNamespace,
   ) => {
     // static nodes are only patched during dev for HMR
     if (n2.children !== n1.children) {
@@ -544,7 +544,7 @@ function baseCreateRenderer(
         n2.children as string,
         container,
         anchor,
-        namespace
+        namespace,
       )
     } else {
       n2.el = n1.el
@@ -555,7 +555,7 @@ function baseCreateRenderer(
   const moveStaticNode = (
     { el, anchor }: VNode,
     container: RendererElement,
-    nextSibling: RendererNode | null
+    nextSibling: RendererNode | null,
   ) => {
     let next
     while (el && el !== anchor) {
@@ -585,7 +585,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     if (n2.type === 'svg') {
       namespace = 'svg'
@@ -602,7 +602,7 @@ function baseCreateRenderer(
         parentSuspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
     } else {
       patchElement(
@@ -612,7 +612,7 @@ function baseCreateRenderer(
         parentSuspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
     }
   }
@@ -625,7 +625,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     let el: RendererElement
     let vnodeHook: VNodeHook | undefined | null
@@ -635,7 +635,7 @@ function baseCreateRenderer(
       vnode.type as string,
       namespace,
       props && props.is,
-      props
+      props,
     )
 
     // mount children first, since some props may rely on child content
@@ -651,7 +651,7 @@ function baseCreateRenderer(
         parentSuspense,
         resolveChildrenNamespace(vnode, namespace),
         slotScopeIds,
-        optimized
+        optimized,
       )
     }
 
@@ -673,7 +673,7 @@ function baseCreateRenderer(
             vnode.children as VNode[],
             parentComponent,
             parentSuspense,
-            unmountChildren
+            unmountChildren,
           )
         }
       }
@@ -697,11 +697,11 @@ function baseCreateRenderer(
     if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
       Object.defineProperty(el, '__vnode', {
         value: vnode,
-        enumerable: false
+        enumerable: false,
       })
       Object.defineProperty(el, '__vueParentComponent', {
         value: parentComponent,
-        enumerable: false
+        enumerable: false,
       })
     }
     if (dirs) {
@@ -732,7 +732,7 @@ function baseCreateRenderer(
     vnode: VNode,
     scopeId: string | null,
     slotScopeIds: string[] | null,
-    parentComponent: ComponentInternalInstance | null
+    parentComponent: ComponentInternalInstance | null,
   ) => {
     if (scopeId) {
       hostSetScopeId(el, scopeId)
@@ -759,7 +759,7 @@ function baseCreateRenderer(
           parentVNode,
           parentVNode.scopeId,
           parentVNode.slotScopeIds,
-          parentComponent.parent
+          parentComponent.parent,
         )
       }
     }
@@ -774,7 +774,7 @@ function baseCreateRenderer(
     namespace: ElementNamespace,
     slotScopeIds,
     optimized,
-    start = 0
+    start = 0,
   ) => {
     for (let i = start; i < children.length; i++) {
       const child = (children[i] = optimized
@@ -789,7 +789,7 @@ function baseCreateRenderer(
         parentSuspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
     }
   }
@@ -801,7 +801,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     const el = (n2.el = n1.el!)
     let { patchFlag, dynamicChildren, dirs } = n2
@@ -837,7 +837,7 @@ function baseCreateRenderer(
         parentComponent,
         parentSuspense,
         resolveChildrenNamespace(n2, namespace),
-        slotScopeIds
+        slotScopeIds,
       )
       if (__DEV__) {
         // necessary for HMR
@@ -854,7 +854,7 @@ function baseCreateRenderer(
         parentSuspense,
         resolveChildrenNamespace(n2, namespace),
         slotScopeIds,
-        false
+        false,
       )
     }
 
@@ -872,7 +872,7 @@ function baseCreateRenderer(
           newProps,
           parentComponent,
           parentSuspense,
-          namespace
+          namespace,
         )
       } else {
         // class
@@ -913,7 +913,7 @@ function baseCreateRenderer(
                 n1.children as VNode[],
                 parentComponent,
                 parentSuspense,
-                unmountChildren
+                unmountChildren,
               )
             }
           }
@@ -936,7 +936,7 @@ function baseCreateRenderer(
         newProps,
         parentComponent,
         parentSuspense,
-        namespace
+        namespace,
       )
     }
 
@@ -956,7 +956,7 @@ function baseCreateRenderer(
     parentComponent,
     parentSuspense,
     namespace: ElementNamespace,
-    slotScopeIds
+    slotScopeIds,
   ) => {
     for (let i = 0; i < newChildren.length; i++) {
       const oldVNode = oldChildren[i]
@@ -987,7 +987,7 @@ function baseCreateRenderer(
         parentSuspense,
         namespace,
         slotScopeIds,
-        true
+        true,
       )
     }
   }
@@ -999,7 +999,7 @@ function baseCreateRenderer(
     newProps: Data,
     parentComponent: ComponentInternalInstance | null,
     parentSuspense: SuspenseBoundary | null,
-    namespace: ElementNamespace
+    namespace: ElementNamespace,
   ) => {
     if (oldProps !== newProps) {
       if (oldProps !== EMPTY_OBJ) {
@@ -1014,7 +1014,7 @@ function baseCreateRenderer(
               vnode.children as VNode[],
               parentComponent,
               parentSuspense,
-              unmountChildren
+              unmountChildren,
             )
           }
         }
@@ -1035,7 +1035,7 @@ function baseCreateRenderer(
             vnode.children as VNode[],
             parentComponent,
             parentSuspense,
-            unmountChildren
+            unmountChildren,
           )
         }
       }
@@ -1054,7 +1054,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     const fragmentStartAnchor = (n2.el = n1 ? n1.el : hostCreateText(''))!
     const fragmentEndAnchor = (n2.anchor = n1 ? n1.anchor : hostCreateText(''))!
@@ -1093,7 +1093,7 @@ function baseCreateRenderer(
         parentSuspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
     } else {
       if (
@@ -1113,7 +1113,7 @@ function baseCreateRenderer(
           parentComponent,
           parentSuspense,
           namespace,
-          slotScopeIds
+          slotScopeIds,
         )
         if (__DEV__) {
           // necessary for HMR
@@ -1142,7 +1142,7 @@ function baseCreateRenderer(
           parentSuspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
       }
     }
@@ -1157,7 +1157,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     n2.slotScopeIds = slotScopeIds
     if (n1 == null) {
@@ -1167,7 +1167,7 @@ function baseCreateRenderer(
           container,
           anchor,
           namespace,
-          optimized
+          optimized,
         )
       } else {
         mountComponent(
@@ -1177,7 +1177,7 @@ function baseCreateRenderer(
           parentComponent,
           parentSuspense,
           namespace,
-          optimized
+          optimized,
         )
       }
     } else {
@@ -1192,7 +1192,7 @@ function baseCreateRenderer(
     parentComponent,
     parentSuspense,
     namespace: ElementNamespace,
-    optimized
+    optimized,
   ) => {
     // 2.x compat may pre-create the component instance before actually
     // mounting
@@ -1203,7 +1203,7 @@ function baseCreateRenderer(
       (initialVNode.component = createComponentInstance(
         initialVNode,
         parentComponent,
-        parentSuspense
+        parentSuspense,
       ))
 
     if (__DEV__ && instance.type.__hmrId) {
@@ -1250,7 +1250,7 @@ function baseCreateRenderer(
         anchor,
         parentSuspense,
         namespace,
-        optimized
+        optimized,
       )
     }
 
@@ -1302,7 +1302,7 @@ function baseCreateRenderer(
     anchor,
     parentSuspense,
     namespace: ElementNamespace,
-    optimized
+    optimized,
   ) => {
     const componentUpdateFn = () => {
       if (!instance.isMounted) {
@@ -1349,7 +1349,7 @@ function baseCreateRenderer(
               instance.subTree,
               instance,
               parentSuspense,
-              null
+              null,
             )
             if (__DEV__) {
               endMeasure(instance, `hydrate`)
@@ -1362,7 +1362,7 @@ function baseCreateRenderer(
               // which means it won't track dependencies - but it's ok because
               // a server-rendered async wrapper is already in resolved state
               // and it will never need to change.
-              () => !instance.isUnmounted && hydrateSubTree()
+              () => !instance.isUnmounted && hydrateSubTree(),
             )
           } else {
             hydrateSubTree()
@@ -1385,7 +1385,7 @@ function baseCreateRenderer(
             anchor,
             instance,
             parentSuspense,
-            namespace
+            namespace,
           )
           if (__DEV__) {
             endMeasure(instance, `patch`)
@@ -1404,7 +1404,7 @@ function baseCreateRenderer(
           const scopedInitialVNode = initialVNode
           queuePostRenderEffect(
             () => invokeVNodeHook(vnodeHook!, parent, scopedInitialVNode),
-            parentSuspense
+            parentSuspense,
           )
         }
         if (
@@ -1413,7 +1413,7 @@ function baseCreateRenderer(
         ) {
           queuePostRenderEffect(
             () => instance.emit('hook:mounted'),
-            parentSuspense
+            parentSuspense,
           )
         }
 
@@ -1433,7 +1433,7 @@ function baseCreateRenderer(
           ) {
             queuePostRenderEffect(
               () => instance.emit('hook:activated'),
-              parentSuspense
+              parentSuspense,
             )
           }
         }
@@ -1526,7 +1526,7 @@ function baseCreateRenderer(
           getNextHostNode(prevTree),
           instance,
           parentSuspense,
-          namespace
+          namespace,
         )
         if (__DEV__) {
           endMeasure(instance, `patch`)
@@ -1546,7 +1546,7 @@ function baseCreateRenderer(
         if ((vnodeHook = next.props && next.props.onVnodeUpdated)) {
           queuePostRenderEffect(
             () => invokeVNodeHook(vnodeHook!, parent, next!, vnode),
-            parentSuspense
+            parentSuspense,
           )
         }
         if (
@@ -1555,7 +1555,7 @@ function baseCreateRenderer(
         ) {
           queuePostRenderEffect(
             () => instance.emit('hook:updated'),
-            parentSuspense
+            parentSuspense,
           )
         }
 
@@ -1574,7 +1574,7 @@ function baseCreateRenderer(
       componentUpdateFn,
       NOOP,
       () => queueJob(update),
-      instance.scope // track it in component's effect scope
+      instance.scope, // track it in component's effect scope
     ))
 
     const update: SchedulerJob = (instance.update = () => {
@@ -1603,7 +1603,7 @@ function baseCreateRenderer(
   const updateComponentPreRender = (
     instance: ComponentInternalInstance,
     nextVNode: VNode,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     nextVNode.component = instance
     const prevProps = instance.vnode.props
@@ -1628,7 +1628,7 @@ function baseCreateRenderer(
     parentSuspense,
     namespace: ElementNamespace,
     slotScopeIds,
-    optimized = false
+    optimized = false,
   ) => {
     const c1 = n1 && n1.children
     const prevShapeFlag = n1 ? n1.shapeFlag : 0
@@ -1649,7 +1649,7 @@ function baseCreateRenderer(
           parentSuspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         return
       } else if (patchFlag & PatchFlags.UNKEYED_FRAGMENT) {
@@ -1663,7 +1663,7 @@ function baseCreateRenderer(
           parentSuspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
         return
       }
@@ -1692,7 +1692,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
         } else {
           // no new children, just unmount old
@@ -1714,7 +1714,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
         }
       }
@@ -1730,7 +1730,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     c1 = c1 || EMPTY_ARR
     c2 = c2 || EMPTY_ARR
@@ -1751,7 +1751,7 @@ function baseCreateRenderer(
         parentSuspense,
         namespace,
         slotScopeIds,
-        optimized
+        optimized,
       )
     }
     if (oldLength > newLength) {
@@ -1762,7 +1762,7 @@ function baseCreateRenderer(
         parentSuspense,
         true,
         false,
-        commonLength
+        commonLength,
       )
     } else {
       // mount new
@@ -1775,7 +1775,7 @@ function baseCreateRenderer(
         namespace,
         slotScopeIds,
         optimized,
-        commonLength
+        commonLength,
       )
     }
   }
@@ -1790,7 +1790,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     namespace: ElementNamespace,
     slotScopeIds: string[] | null,
-    optimized: boolean
+    optimized: boolean,
   ) => {
     let i = 0
     const l2 = c2.length
@@ -1815,7 +1815,7 @@ function baseCreateRenderer(
           parentSuspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
       } else {
         break
@@ -1841,7 +1841,7 @@ function baseCreateRenderer(
           parentSuspense,
           namespace,
           slotScopeIds,
-          optimized
+          optimized,
         )
       } else {
         break
@@ -1873,7 +1873,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
           i++
         }
@@ -1913,7 +1913,7 @@ function baseCreateRenderer(
             warn(
               `Duplicate keys found during update:`,
               JSON.stringify(nextChild.key),
-              `Make sure keys are unique.`
+              `Make sure keys are unique.`,
             )
           }
           keyToNewIndexMap.set(nextChild.key, i)
@@ -1976,7 +1976,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
           patched++
         }
@@ -2005,7 +2005,7 @@ function baseCreateRenderer(
             parentSuspense,
             namespace,
             slotScopeIds,
-            optimized
+            optimized,
           )
         } else if (moved) {
           // move if:
@@ -2026,7 +2026,7 @@ function baseCreateRenderer(
     container,
     anchor,
     moveType,
-    parentSuspense = null
+    parentSuspense = null,
   ) => {
     const { el, type, transition, children, shapeFlag } = vnode
     if (shapeFlag & ShapeFlags.COMPONENT) {
@@ -2093,7 +2093,7 @@ function baseCreateRenderer(
     parentComponent,
     parentSuspense,
     doRemove = false,
-    optimized = false
+    optimized = false,
   ) => {
     const {
       type,
@@ -2103,7 +2103,7 @@ function baseCreateRenderer(
       dynamicChildren,
       shapeFlag,
       patchFlag,
-      dirs
+      dirs,
     } = vnode
     // unset ref
     if (ref != null) {
@@ -2145,7 +2145,7 @@ function baseCreateRenderer(
           parentSuspense,
           optimized,
           internals,
-          doRemove
+          doRemove,
         )
       } else if (
         dynamicChildren &&
@@ -2159,7 +2159,7 @@ function baseCreateRenderer(
           parentComponent,
           parentSuspense,
           false,
-          true
+          true,
         )
       } else if (
         (type === Fragment &&
@@ -2255,7 +2255,7 @@ function baseCreateRenderer(
   const unmountComponent = (
     instance: ComponentInternalInstance,
     parentSuspense: SuspenseBoundary | null,
-    doRemove?: boolean
+    doRemove?: boolean,
   ) => {
     if (__DEV__ && instance.type.__hmrId) {
       unregisterHMR(instance)
@@ -2295,7 +2295,7 @@ function baseCreateRenderer(
     ) {
       queuePostRenderEffect(
         () => instance.emit('hook:destroyed'),
-        parentSuspense
+        parentSuspense,
       )
     }
     queuePostRenderEffect(() => {
@@ -2331,7 +2331,7 @@ function baseCreateRenderer(
     parentSuspense,
     doRemove = false,
     optimized = false,
-    start = 0
+    start = 0,
   ) => {
     for (let i = start; i < children.length; i++) {
       unmount(children[i], parentComponent, parentSuspense, doRemove, optimized)
@@ -2361,7 +2361,7 @@ function baseCreateRenderer(
         null,
         null,
         null,
-        namespace
+        namespace,
       )
     }
     flushPreFlushCbs()
@@ -2379,27 +2379,27 @@ function baseCreateRenderer(
     pc: patchChildren,
     pbc: patchBlockChildren,
     n: getNextHostNode,
-    o: options
+    o: options,
   }
 
   let hydrate: ReturnType<typeof createHydrationFunctions>[0] | undefined
   let hydrateNode: ReturnType<typeof createHydrationFunctions>[1] | undefined
   if (createHydrationFns) {
     ;[hydrate, hydrateNode] = createHydrationFns(
-      internals as RendererInternals<Node, Element>
+      internals as RendererInternals<Node, Element>,
     )
   }
 
   return {
     render,
     hydrate,
-    createApp: createAppAPI(render, hydrate)
+    createApp: createAppAPI(render, hydrate),
   }
 }
 
 function resolveChildrenNamespace(
   { type, props }: VNode,
-  currentNamespace: ElementNamespace
+  currentNamespace: ElementNamespace,
 ): ElementNamespace {
   return (currentNamespace === 'svg' && type === 'foreignObject') ||
     (currentNamespace === 'mathml' &&
@@ -2413,14 +2413,14 @@ function resolveChildrenNamespace(
 
 function toggleRecurse(
   { effect, update }: ComponentInternalInstance,
-  allowed: boolean
+  allowed: boolean,
 ) {
   effect.allowRecurse = update.allowRecurse = allowed
 }
 
 export function needTransition(
   parentSuspense: SuspenseBoundary | null,
-  transition: TransitionHooks | null
+  transition: TransitionHooks | null,
 ) {
   return (
     (!parentSuspense || (parentSuspense && !parentSuspense.pendingBranch)) &&
@@ -2512,7 +2512,7 @@ function getSequence(arr: number[]): number[] {
 }
 
 function locateNonHydratedAsyncRoot(
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): ComponentInternalInstance | undefined {
   const subComponent = instance.subTree.component
   if (subComponent) {
index 30f96228d1fcdeb58d4a8689c118af3a3a6b6f20..b652edeac4c96a3dea6ba02a6ccdbfc2128e9023 100644 (file)
@@ -1,20 +1,20 @@
-import { SuspenseBoundary } from './components/Suspense'
-import { VNode, VNodeNormalizedRef, VNodeNormalizedRefAtom } from './vnode'
+import type { SuspenseBoundary } from './components/Suspense'
+import type { VNode, VNodeNormalizedRef, VNodeNormalizedRefAtom } from './vnode'
 import {
   EMPTY_OBJ,
+  ShapeFlags,
   hasOwn,
   isArray,
   isFunction,
   isString,
   remove,
-  ShapeFlags
 } from '@vue/shared'
 import { isAsyncWrapper } from './apiAsyncComponent'
 import { getExposeProxy } from './component'
 import { warn } from './warning'
 import { isRef } from '@vue/reactivity'
-import { callWithErrorHandling, ErrorCodes } from './errorHandling'
-import { SchedulerJob } from './scheduler'
+import { ErrorCodes, callWithErrorHandling } from './errorHandling'
+import type { SchedulerJob } from './scheduler'
 import { queuePostRenderEffect } from './renderer'
 
 /**
@@ -25,7 +25,7 @@ export function setRef(
   oldRawRef: VNodeNormalizedRef | null,
   parentSuspense: SuspenseBoundary | null,
   vnode: VNode,
-  isUnmount = false
+  isUnmount = false,
 ) {
   if (isArray(rawRef)) {
     rawRef.forEach((r, i) =>
@@ -34,8 +34,8 @@ export function setRef(
         oldRawRef && (isArray(oldRawRef) ? oldRawRef[i] : oldRawRef),
         parentSuspense,
         vnode,
-        isUnmount
-      )
+        isUnmount,
+      ),
     )
     return
   }
@@ -56,7 +56,7 @@ export function setRef(
   if (__DEV__ && !owner) {
     warn(
       `Missing ref owner context. ref cannot be used on hoisted vnodes. ` +
-        `A vnode with ref must be created inside the render function.`
+        `A vnode with ref must be created inside the render function.`,
     )
     return
   }
index 0b3175810631bb50a701d34c5df076b869aff62b..7c4524c7106e8926e7f8f922c1f1038ff08c3c8c 100644 (file)
@@ -1,6 +1,6 @@
 import { ErrorCodes, callWithErrorHandling, handleError } from './errorHandling'
-import { Awaited, isArray, NOOP } from '@vue/shared'
-import { ComponentInternalInstance, getComponentName } from './component'
+import { type Awaited, NOOP, isArray } from '@vue/shared'
+import { type ComponentInternalInstance, getComponentName } from './component'
 
 export interface SchedulerJob extends Function {
   id?: number
@@ -51,7 +51,7 @@ type CountMap = Map<SchedulerJob, number>
 
 export function nextTick<T = void, R = void>(
   this: T,
-  fn?: (this: T) => R
+  fn?: (this: T) => R,
 ): Promise<Awaited<R>> {
   const p = currentFlushPromise || resolvedPromise
   return fn ? p.then(this ? fn.bind(this) : fn) : p
@@ -91,7 +91,7 @@ export function queueJob(job: SchedulerJob) {
     !queue.length ||
     !queue.includes(
       job,
-      isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex
+      isFlushing && job.allowRecurse ? flushIndex + 1 : flushIndex,
     )
   ) {
     if (job.id == null) {
@@ -123,7 +123,7 @@ export function queuePostFlushCb(cb: SchedulerJobs) {
       !activePostFlushCbs ||
       !activePostFlushCbs.includes(
         cb,
-        cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex
+        cb.allowRecurse ? postFlushIndex + 1 : postFlushIndex,
       )
     ) {
       pendingPostFlushCbs.push(cb)
@@ -141,7 +141,7 @@ export function flushPreFlushCbs(
   instance?: ComponentInternalInstance,
   seen?: CountMap,
   // if currently flushing, skip the current job itself
-  i = isFlushing ? flushIndex + 1 : 0
+  i = isFlushing ? flushIndex + 1 : 0,
 ) {
   if (__DEV__) {
     seen = seen || new Map()
@@ -279,7 +279,7 @@ function checkRecursiveUpdates(seen: CountMap, fn: SchedulerJob) {
           `include component template, render function, updated hook or ` +
           `watcher source function.`,
         null,
-        ErrorCodes.APP_ERROR_HANDLER
+        ErrorCodes.APP_ERROR_HANDLER,
       )
       return true
     } else {
index 7a271f54047d51eccf03bbbacf0eeae5b2252991..178ceec41bd1f28cec11a0da3d61f7544da869e2 100644 (file)
@@ -1,50 +1,60 @@
 import {
+  EMPTY_ARR,
+  PatchFlags,
+  ShapeFlags,
+  SlotFlags,
+  extend,
   isArray,
   isFunction,
-  isString,
   isObject,
-  EMPTY_ARR,
-  extend,
+  isOn,
+  isString,
   normalizeClass,
   normalizeStyle,
-  PatchFlags,
-  ShapeFlags,
-  SlotFlags,
-  isOn
 } from '@vue/shared'
 import {
-  ComponentInternalInstance,
-  Data,
-  ConcreteComponent,
-  ClassComponent,
-  Component,
-  isClassComponent
+  type ClassComponent,
+  type Component,
+  type ComponentInternalInstance,
+  type ConcreteComponent,
+  type Data,
+  isClassComponent,
 } from './component'
-import { RawSlots } from './componentSlots'
-import { isProxy, Ref, toRaw, ReactiveFlags, isRef } from '@vue/reactivity'
-import { AppContext } from './apiCreateApp'
+import type { RawSlots } from './componentSlots'
+import {
+  type ReactiveFlags,
+  type Ref,
+  isProxy,
+  isRef,
+  toRaw,
+} from '@vue/reactivity'
+import type { AppContext } from './apiCreateApp'
 import {
-  Suspense,
-  SuspenseImpl,
+  type Suspense,
+  type SuspenseBoundary,
+  type SuspenseImpl,
   isSuspense,
-  SuspenseBoundary
 } from './components/Suspense'
-import { DirectiveBinding } from './directives'
-import { TransitionHooks } from './components/BaseTransition'
+import type { DirectiveBinding } from './directives'
+import type { TransitionHooks } from './components/BaseTransition'
 import { warn } from './warning'
-import { Teleport, TeleportImpl, isTeleport } from './components/Teleport'
+import {
+  type Teleport,
+  type TeleportImpl,
+  isTeleport,
+} from './components/Teleport'
 import {
   currentRenderingInstance,
-  currentScopeId
+  currentScopeId,
 } from './componentRenderContext'
-import { RendererNode, RendererElement } from './renderer'
+import type { RendererElement, RendererNode } from './renderer'
 import { NULL_DYNAMIC_COMPONENT } from './helpers/resolveAssets'
 import { hmrDirtyComponents } from './hmr'
 import { convertLegacyComponent } from './compat/component'
 import { convertLegacyVModelProps } from './compat/componentVModel'
 import { defineLegacyVNodeProperties } from './compat/renderFn'
-import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling'
-import { ComponentPublicInstance } from './componentPublicInstance'
+import { ErrorCodes, callWithAsyncErrorHandling } from './errorHandling'
+import type { ComponentPublicInstance } from './componentPublicInstance'
 
 export const Fragment = Symbol.for('v-fgt') as any as {
   __isFragment: true
@@ -74,7 +84,7 @@ export type VNodeRef =
   | Ref
   | ((
       ref: Element | ComponentPublicInstance | null,
-      refs: Record<string, any>
+      refs: Record<string, any>,
     ) => void)
 
 export type VNodeNormalizedRefAtom = {
@@ -134,7 +144,7 @@ export type VNodeNormalizedChildren =
 export interface VNode<
   HostNode = RendererNode,
   HostElement = RendererElement,
-  ExtraProps = { [key: string]: any }
+  ExtraProps = { [key: string]: any },
 > {
   /**
    * @internal
@@ -306,7 +316,7 @@ export function createElementBlock(
   children?: any,
   patchFlag?: number,
   dynamicProps?: string[],
-  shapeFlag?: number
+  shapeFlag?: number,
 ) {
   return setupBlock(
     createBaseVNode(
@@ -316,8 +326,8 @@ export function createElementBlock(
       patchFlag,
       dynamicProps,
       shapeFlag,
-      true /* isBlock */
-    )
+      true /* isBlock */,
+    ),
   )
 }
 
@@ -333,7 +343,7 @@ export function createBlock(
   props?: Record<string, any> | null,
   children?: any,
   patchFlag?: number,
-  dynamicProps?: string[]
+  dynamicProps?: string[],
 ): VNode {
   return setupBlock(
     createVNode(
@@ -342,8 +352,8 @@ export function createBlock(
       children,
       patchFlag,
       dynamicProps,
-      true /* isBlock: prevent a block from tracking itself */
-    )
+      true /* isBlock: prevent a block from tracking itself */,
+    ),
   )
 }
 
@@ -370,7 +380,7 @@ export function isSameVNodeType(n1: VNode, n2: VNode): boolean {
 let vnodeArgsTransformer:
   | ((
       args: Parameters<typeof _createVNode>,
-      instance: ComponentInternalInstance | null
+      instance: ComponentInternalInstance | null,
     ) => Parameters<typeof _createVNode>)
   | undefined
 
@@ -390,7 +400,7 @@ const createVNodeWithArgsTransform = (
   return _createVNode(
     ...(vnodeArgsTransformer
       ? vnodeArgsTransformer(args, currentRenderingInstance)
-      : args)
+      : args),
   )
 }
 
@@ -402,7 +412,7 @@ const normalizeKey = ({ key }: VNodeProps): VNode['key'] =>
 const normalizeRef = ({
   ref,
   ref_key,
-  ref_for
+  ref_for,
 }: VNodeProps): VNodeNormalizedRefAtom | null => {
   if (typeof ref === 'number') {
     ref = '' + ref
@@ -424,7 +434,7 @@ function createBaseVNode(
   dynamicProps: string[] | null = null,
   shapeFlag = type === Fragment ? 0 : ShapeFlags.ELEMENT,
   isBlockNode = false,
-  needFullChildrenNormalization = false
+  needFullChildrenNormalization = false,
 ) {
   const vnode = {
     __v_isVNode: true,
@@ -452,7 +462,7 @@ function createBaseVNode(
     dynamicProps,
     dynamicChildren: null,
     appContext: null,
-    ctx: currentRenderingInstance
+    ctx: currentRenderingInstance,
   } as VNode
 
   if (needFullChildrenNormalization) {
@@ -513,7 +523,7 @@ function _createVNode(
   children: unknown = null,
   patchFlag: number = 0,
   dynamicProps: string[] | null = null,
-  isBlockNode = false
+  isBlockNode = false,
 ): VNode {
   if (!type || type === NULL_DYNAMIC_COMPONENT) {
     if (__DEV__ && !type) {
@@ -590,7 +600,7 @@ function _createVNode(
         `marking the component with \`markRaw\` or using \`shallowRef\` ` +
         `instead of \`ref\`.`,
       `\nComponent that was made reactive: `,
-      type
+      type,
     )
   }
 
@@ -602,7 +612,7 @@ function _createVNode(
     dynamicProps,
     shapeFlag,
     isBlockNode,
-    true
+    true,
   )
 }
 
@@ -616,7 +626,7 @@ export function guardReactiveProps(props: (Data & VNodeProps) | null) {
 export function cloneVNode<T, U>(
   vnode: VNode<T, U>,
   extraProps?: (Data & VNodeProps) | null,
-  mergeRef = false
+  mergeRef = false,
 ): VNode<T, U> {
   // This is intentionally NOT using spread or extend to avoid the runtime
   // key enumeration cost.
@@ -676,7 +686,7 @@ export function cloneVNode<T, U>(
     el: vnode.el,
     anchor: vnode.anchor,
     ctx: vnode.ctx,
-    ce: vnode.ce
+    ce: vnode.ce,
   }
   if (__COMPAT__) {
     defineLegacyVNodeProperties(cloned as VNode)
@@ -708,7 +718,7 @@ export function createTextVNode(text: string = ' ', flag: number = 0): VNode {
  */
 export function createStaticVNode(
   content: string,
-  numberOfNodes: number
+  numberOfNodes: number,
 ): VNode {
   // A static vnode can contain multiple stringified elements, and the number
   // of elements is necessary for hydration.
@@ -724,7 +734,7 @@ export function createCommentVNode(
   text: string = '',
   // when used as the v-else branch, the comment node must be created as a
   // block to ensure correct updates.
-  asBlock: boolean = false
+  asBlock: boolean = false,
 ): VNode {
   return asBlock
     ? (openBlock(), createBlock(Comment, null, text))
@@ -741,7 +751,7 @@ export function normalizeVNode(child: VNodeChild): VNode {
       Fragment,
       null,
       // #3666, avoid reference pollution when reusing vnode
-      child.slice()
+      child.slice(),
     )
   } else if (typeof child === 'object') {
     // already vnode, this should be the most common since compiled templates
@@ -851,10 +861,10 @@ export function invokeVNodeHook(
   hook: VNodeHook,
   instance: ComponentInternalInstance | null,
   vnode: VNode,
-  prevVNode: VNode | null = null
+  prevVNode: VNode | null = null,
 ) {
   callWithAsyncErrorHandling(hook, instance, ErrorCodes.VNODE_HOOK, [
     vnode,
-    prevVNode
+    prevVNode,
   ])
 }
index 45284fc70c7b233bf0b0cd4a659007594c31d09c..16928387dfb290a6be74740bd7f18dd45c7c9a57 100644 (file)
@@ -1,13 +1,13 @@
-import { VNode } from './vnode'
+import type { VNode } from './vnode'
 import {
-  Data,
-  ComponentInternalInstance,
-  ConcreteComponent,
-  formatComponentName
+  type ComponentInternalInstance,
+  type ConcreteComponent,
+  type Data,
+  formatComponentName,
 } from './component'
-import { isString, isFunction } from '@vue/shared'
-import { toRaw, isRef, pauseTracking, resetTracking } from '@vue/reactivity'
-import { callWithErrorHandling, ErrorCodes } from './errorHandling'
+import { isFunction, isString } from '@vue/shared'
+import { isRef, pauseTracking, resetTracking, toRaw } from '@vue/reactivity'
+import { ErrorCodes, callWithErrorHandling } from './errorHandling'
 
 type ComponentVNode = VNode & {
   type: ConcreteComponent
@@ -49,11 +49,11 @@ export function warn(msg: string, ...args: any[]) {
         instance && instance.proxy,
         trace
           .map(
-            ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
+            ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`,
           )
           .join('\n'),
-        trace
-      ]
+        trace,
+      ],
     )
   } else {
     const warnArgs = [`[Vue warn]: ${msg}`, ...args]
@@ -89,7 +89,7 @@ export function getComponentTrace(): ComponentTraceStack {
     } else {
       normalizedStack.push({
         vnode: currentVNode as ComponentVNode,
-        recurseCount: 0
+        recurseCount: 0,
       })
     }
     const parentInstance: ComponentInternalInstance | null =
@@ -116,7 +116,7 @@ function formatTraceEntry({ vnode, recurseCount }: TraceEntry): any[] {
   const open = ` at <${formatComponentName(
     vnode.component,
     vnode.type,
-    isRoot
+    isRoot,
   )}`
   const close = `>` + postfix
   return vnode.props
index 0857d7ab2c3ecb55c461c423a82c32c0c42dcd51..9a8d05df2df7ca9f53f6867e8171156e3f6f32b9 100644 (file)
@@ -7,7 +7,7 @@ describe('createApp for dom', () => {
     createApp({
       render() {
         return h('g')
-      }
+      },
     }).mount(root)
     expect(root.children.length).toBe(1)
     expect(root.children[0]).toBeInstanceOf(SVGElement)
@@ -18,9 +18,9 @@ describe('createApp for dom', () => {
     const originalObj = {
       data() {
         return {
-          counter: 0
+          counter: 0,
         }
-      }
+      },
     }
 
     const handler = vi.fn(msg => {
index 6ccf02c4fa60d7ad6da330d0f1e79d7213eb0749..bb08fb1557effd0228fecca575631bb9fe4fae3b 100644 (file)
@@ -1,14 +1,14 @@
 import {
+  type Ref,
+  type VueElement,
   defineAsyncComponent,
   defineComponent,
   defineCustomElement,
   h,
   inject,
   nextTick,
-  Ref,
   ref,
   renderSlot,
-  VueElement
 } from '../src'
 
 describe('defineCustomElement', () => {
@@ -24,12 +24,12 @@ describe('defineCustomElement', () => {
       props: {
         msg: {
           type: String,
-          default: 'hello'
-        }
+          default: 'hello',
+        },
       },
       render() {
         return h('div', this.msg)
-      }
+      },
     })
     customElements.define('my-element', E)
 
@@ -92,9 +92,9 @@ describe('defineCustomElement', () => {
       render() {
         return [
           h('div', null, this.foo),
-          h('div', null, this.bazQux || (this.bar && this.bar.x))
+          h('div', null, this.bazQux || (this.bar && this.bar.x)),
         ]
-      }
+      },
     })
     customElements.define('my-el-props', E)
 
@@ -112,7 +112,7 @@ describe('defineCustomElement', () => {
       e.setAttribute('baz-qux', 'changed')
       await nextTick()
       expect(e.shadowRoot!.innerHTML).toBe(
-        '<div>changed</div><div>changed</div>'
+        '<div>changed</div><div>changed</div>',
       )
     })
 
@@ -150,7 +150,7 @@ describe('defineCustomElement', () => {
         props: {
           fooBar: Number, // test casting of camelCase prop names
           bar: Boolean,
-          baz: String
+          baz: String,
         },
         render() {
           return [
@@ -159,15 +159,15 @@ describe('defineCustomElement', () => {
             this.bar,
             typeof this.bar,
             this.baz,
-            typeof this.baz
+            typeof this.baz,
           ].join(' ')
-        }
+        },
       })
       customElements.define('my-el-props-cast', E)
       container.innerHTML = `<my-el-props-cast foo-bar="1" baz="12345"></my-el-props-cast>`
       const e = container.childNodes[0] as VueElement
       expect(e.shadowRoot!.innerHTML).toBe(
-        `1 number false boolean 12345 string`
+        `1 number false boolean 12345 string`,
       )
 
       e.setAttribute('bar', '')
@@ -177,7 +177,7 @@ describe('defineCustomElement', () => {
       e.setAttribute('foo-bar', '2e1')
       await nextTick()
       expect(e.shadowRoot!.innerHTML).toBe(
-        `20 number true boolean 12345 string`
+        `20 number true boolean 12345 string`,
       )
 
       e.setAttribute('baz', '2e1')
@@ -189,11 +189,11 @@ describe('defineCustomElement', () => {
     test('attr casting w/ programmatic creation', () => {
       const E = defineCustomElement({
         props: {
-          foo: Number
+          foo: Number,
         },
         render() {
           return `foo type: ${typeof this.foo}`
-        }
+        },
       })
       customElements.define('my-element-programmatic', E)
       const el = document.createElement('my-element-programmatic') as any
@@ -206,7 +206,7 @@ describe('defineCustomElement', () => {
       const E = defineCustomElement({
         props: {
           foo: String,
-          dataAge: Number
+          dataAge: Number,
         },
         setup(props) {
           expect(props.foo).toBe('hello')
@@ -214,7 +214,7 @@ describe('defineCustomElement', () => {
         },
         render() {
           return h('div', `foo: ${this.foo}`)
-        }
+        },
       })
       const el = document.createElement('my-el-upgrade') as any
       el.foo = 'hello'
@@ -232,7 +232,7 @@ describe('defineCustomElement', () => {
       const E = defineCustomElement({
         props: {
           foo: String,
-          post: Object
+          post: Object,
         },
         setup(props) {
           expect(props.foo).toBe('hello')
@@ -240,7 +240,7 @@ describe('defineCustomElement', () => {
         },
         render() {
           return JSON.stringify(this.post)
-        }
+        },
       })
       customElements.define('my-el-preconnect', E)
       const el = document.createElement('my-el-preconnect') as any
@@ -256,7 +256,7 @@ describe('defineCustomElement', () => {
       const E = defineCustomElement({
         render() {
           return h('div', 'foo')
-        }
+        },
       })
       customElements.define('my-element-noprops', E)
       const el = document.createElement('my-element-noprops')
@@ -269,12 +269,12 @@ describe('defineCustomElement', () => {
     test('set number value in dom property', () => {
       const E = defineCustomElement({
         props: {
-          'max-age': Number
+          'max-age': Number,
         },
         render() {
-          // @ts-ignore
+          // @ts-expect-error
           return `max age: ${this.maxAge}/type: ${typeof this.maxAge}`
-        }
+        },
       })
       customElements.define('my-element-number-property', E)
       const el = document.createElement('my-element-number-property') as any
@@ -289,7 +289,7 @@ describe('defineCustomElement', () => {
     const E = defineCustomElement({
       render() {
         return [h('div', null, this.$attrs.foo as string)]
-      }
+      },
     })
     customElements.define('my-el-attrs', E)
 
@@ -305,7 +305,7 @@ describe('defineCustomElement', () => {
 
     test('non-declared properties should not show up in $attrs', () => {
       const e = new E()
-      // @ts-ignore
+      // @ts-expect-error
       e.foo = '123'
       container.appendChild(e)
       expect(e.shadowRoot!.innerHTML).toBe('<div></div>')
@@ -323,9 +323,9 @@ describe('defineCustomElement', () => {
             },
             onMousedown: () => {
               emit('myEvent', 1) // validate hyphenation
-            }
+            },
           })
-      }
+      },
     })
     const E = defineCustomElement(CompDef)
     customElements.define('my-el-emits', E)
@@ -346,7 +346,7 @@ describe('defineCustomElement', () => {
       e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
       expect(spy).toHaveBeenCalledTimes(1)
       expect(spy.mock.calls[0][0]).toMatchObject({
-        detail: [1]
+        detail: [1],
       })
     })
 
@@ -380,15 +380,15 @@ describe('defineCustomElement', () => {
       e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
       expect(spy).toHaveBeenCalled()
       expect(spy.mock.calls[0][0]).toMatchObject({
-        detail: [1]
+        detail: [1],
       })
     })
     // #7293
     test('emit in an async component wrapper with properties bound', async () => {
       const E = defineCustomElement(
         defineAsyncComponent(
-          () => new Promise<typeof CompDef>(res => res(CompDef as any))
-        )
+          () => new Promise<typeof CompDef>(res => res(CompDef as any)),
+        ),
       )
       customElements.define('my-async-el-props-emits', E)
       container.innerHTML = `<my-async-el-props-emits id="my_async_el_props_emits"></my-async-el-props-emits>`
@@ -401,7 +401,7 @@ describe('defineCustomElement', () => {
       e.shadowRoot!.childNodes[0].dispatchEvent(new CustomEvent('click'))
       expect(spy).toHaveBeenCalled()
       expect(spy.mock.calls[0][0]).toMatchObject({
-        detail: [1]
+        detail: [1],
       })
     })
   })
@@ -412,12 +412,12 @@ describe('defineCustomElement', () => {
         return [
           h('div', null, [
             renderSlot(this.$slots, 'default', undefined, () => [
-              h('div', 'fallback')
-            ])
+              h('div', 'fallback'),
+            ]),
           ]),
-          h('div', null, renderSlot(this.$slots, 'named'))
+          h('div', null, renderSlot(this.$slots, 'named')),
         ]
-      }
+      },
     })
     customElements.define('my-el-slots', E)
 
@@ -427,7 +427,7 @@ describe('defineCustomElement', () => {
       // native slots allocation does not affect innerHTML, so we just
       // verify that we've rendered the correct native slots here...
       expect(e.shadowRoot!.innerHTML).toBe(
-        `<div><slot><div>fallback</div></slot></div><div><slot name="named"></slot></div>`
+        `<div><slot><div>fallback</div></slot></div><div><slot name="named"></slot></div>`,
       )
     })
   })
@@ -437,7 +437,7 @@ describe('defineCustomElement', () => {
       setup() {
         const foo = inject<Ref>('foo')!
         return () => h('div', foo.value)
-      }
+      },
     })
     customElements.define('my-consumer', Consumer)
 
@@ -445,11 +445,11 @@ describe('defineCustomElement', () => {
       const foo = ref('injected!')
       const Provider = defineCustomElement({
         provide: {
-          foo
+          foo,
         },
         render() {
           return h('my-consumer')
-        }
+        },
       })
       customElements.define('my-provider', Provider)
       container.innerHTML = `<my-provider><my-provider>`
@@ -467,11 +467,11 @@ describe('defineCustomElement', () => {
       const foo = ref('injected!')
       const Provider = defineCustomElement({
         provide: {
-          foo
+          foo,
         },
         render() {
           return renderSlot(this.$slots, 'default')
-        }
+        },
       })
       customElements.define('my-provider-2', Provider)
 
@@ -490,19 +490,19 @@ describe('defineCustomElement', () => {
       const fooB = ref('FooB!')
       const ProviderA = defineCustomElement({
         provide: {
-          fooA
+          fooA,
         },
         render() {
           return h('provider-b')
-        }
+        },
       })
       const ProviderB = defineCustomElement({
         provide: {
-          fooB
+          fooB,
         },
         render() {
           return h('my-multi-consumer')
-        }
+        },
       })
 
       const Consumer = defineCustomElement({
@@ -510,7 +510,7 @@ describe('defineCustomElement', () => {
           const fooA = inject<Ref>('fooA')!
           const fooB = inject<Ref>('fooB')!
           return () => h('div', `${fooA.value} ${fooB.value}`)
-        }
+        },
       })
 
       customElements.define('provider-a', ProviderA)
@@ -527,7 +527,7 @@ describe('defineCustomElement', () => {
       fooB.value = 'changedB!'
       await nextTick()
       expect(consumer.shadowRoot!.innerHTML).toBe(
-        `<div>changedA! changedB!</div>`
+        `<div>changedA! changedB!</div>`,
       )
     })
   })
@@ -538,7 +538,7 @@ describe('defineCustomElement', () => {
         styles: [`div { color: red; }`],
         render() {
           return h('div', 'hello')
-        }
+        },
       })
       customElements.define('my-el-with-styles', Foo)
       container.innerHTML = `<my-el-with-styles></my-el-with-styles>`
@@ -559,9 +559,9 @@ describe('defineCustomElement', () => {
             styles: [`div { color: red }`],
             render(this: any) {
               return h('div', null, this.msg)
-            }
+            },
           })
-        })
+        }),
       )
       customElements.define('my-el-async', E)
       container.innerHTML =
@@ -578,10 +578,10 @@ describe('defineCustomElement', () => {
 
       // should inject styles
       expect(e1.shadowRoot!.innerHTML).toBe(
-        `<style>div { color: red }</style><div>hello</div>`
+        `<style>div { color: red }</style><div>hello</div>`,
       )
       expect(e2.shadowRoot!.innerHTML).toBe(
-        `<style>div { color: red }</style><div>world</div>`
+        `<style>div { color: red }</style><div>world</div>`,
       )
 
       // attr
@@ -589,7 +589,7 @@ describe('defineCustomElement', () => {
       await nextTick()
       expect((e1 as any).msg).toBe('attr')
       expect(e1.shadowRoot!.innerHTML).toBe(
-        `<style>div { color: red }</style><div>attr</div>`
+        `<style>div { color: red }</style><div>attr</div>`,
       )
 
       // props
@@ -597,7 +597,7 @@ describe('defineCustomElement', () => {
       ;(e1 as any).msg = 'prop'
       expect(e1.getAttribute('msg')).toBe('prop')
       expect(e1.shadowRoot!.innerHTML).toBe(
-        `<style>div { color: red }</style><div>prop</div>`
+        `<style>div { color: red }</style><div>prop</div>`,
       )
     })
 
@@ -611,9 +611,9 @@ describe('defineCustomElement', () => {
             },
             render(this: any) {
               return h('div', this.msg)
-            }
+            },
           })
-        })
+        }),
       )
       customElements.define('my-el-async-2', E)
 
@@ -652,9 +652,9 @@ describe('defineCustomElement', () => {
             },
             render(this: any) {
               return h('div', this.n + ',' + typeof this.n)
-            }
+            },
           })
-        })
+        }),
       )
       customElements.define('my-el-async-3', E)
       container.innerHTML = `<my-el-async-3 n="2e1"></my-el-async-3>`
@@ -673,14 +673,14 @@ describe('defineCustomElement', () => {
               return [
                 h('div', null, [
                   renderSlot(this.$slots, 'default', undefined, () => [
-                    h('div', 'fallback')
-                  ])
+                    h('div', 'fallback'),
+                  ]),
                 ]),
-                h('div', null, renderSlot(this.$slots, 'named'))
+                h('div', null, renderSlot(this.$slots, 'named')),
               ]
-            }
+            },
           })
-        })
+        }),
       )
       customElements.define('my-el-async-slots', E)
       container.innerHTML = `<my-el-async-slots><span>hi</span></my-el-async-slots>`
@@ -689,7 +689,7 @@ describe('defineCustomElement', () => {
 
       const e = container.childNodes[0] as VueElement
       expect(e.shadowRoot!.innerHTML).toBe(
-        `<div><slot><div>fallback</div></slot></div><div><slot name="named"></slot></div>`
+        `<div><slot><div>fallback</div></slot></div><div><slot name="named"></slot></div>`,
       )
     })
   })
index 09542a3555d32e78f074ef029fbf150556725e2e..a02cf0f7807e210dab12367f94fb3b36c7dfac46 100644 (file)
@@ -1,5 +1,5 @@
-import { type MockInstance } from 'vitest'
-import { render, h } from '@vue/runtime-dom'
+import type { MockInstance } from 'vitest'
+import { h, render } from '@vue/runtime-dom'
 
 describe('customized built-in elements support', () => {
   let createElement: MockInstance
@@ -13,7 +13,7 @@ describe('customized built-in elements support', () => {
     render(h('button', { is: 'plastic-button' }), root)
     expect(createElement.mock.calls[0]).toMatchObject([
       'button',
-      { is: 'plastic-button' }
+      { is: 'plastic-button' },
     ])
     // should also render the attribute
     expect(root.innerHTML).toBe(`<button is="plastic-button"></button>`)
index 813147cc332ee3deee7d2b779144917d21777429..845bb540adbe538ca805d5f7490739c19418aefa 100644 (file)
@@ -5,7 +5,7 @@ describe('vCloak', () => {
     const root = document.createElement('div')
     root.setAttribute('v-cloak', '')
     createApp({
-      render() {}
+      render() {},
     }).mount(root)
     expect(root.hasAttribute('v-cloak')).toBe(false)
   })
index acf1b40b6969f0995b34b7fc64fc815a50970cb8..05ee59d90108fbd11b2349f6a19e376a2fc9c8d0 100644 (file)
@@ -1,12 +1,12 @@
 import {
+  type VNode,
+  defineComponent,
   h,
-  render,
   nextTick,
-  defineComponent,
+  ref,
+  render,
   vModelDynamic,
   withDirectives,
-  VNode,
-  ref
 } from '@vue/runtime-dom'
 
 const triggerEvent = (type: string, el: Element) => {
@@ -41,12 +41,12 @@ describe('vModel', () => {
               'onUpdate:modelValue': setValue.bind(this),
               onInput: () => {
                 manualListener(data.value)
-              }
+              },
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -80,12 +80,12 @@ describe('vModel', () => {
           withVModel(
             h('input', {
               type: 'number',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -119,20 +119,20 @@ describe('vModel', () => {
             h('input', {
               id: 'input_num1',
               type: 'number',
-              'onUpdate:modelValue': setValue1.bind(this)
+              'onUpdate:modelValue': setValue1.bind(this),
             }),
-            this.value1
+            this.value1,
           ),
           withVModel(
             h('input', {
               id: 'input_num2',
               type: 'number',
-              'onUpdate:modelValue': setValue2.bind(this)
+              'onUpdate:modelValue': setValue2.bind(this),
             }),
-            this.value2
-          )
+            this.value2,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
     const data = root._vnode.component.data
@@ -166,12 +166,12 @@ describe('vModel', () => {
         return [
           withVModel(
             h('input', {
-              'onUpdate:modelValue': [setValue.bind(this), spy]
+              'onUpdate:modelValue': [setValue.bind(this), spy],
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -195,12 +195,12 @@ describe('vModel', () => {
         return [
           withVModel(
             h('input', {
-              'onUpdate:modelValue': toggle.value ? spy1 : spy2
+              'onUpdate:modelValue': toggle.value ? spy1 : spy2,
             }),
-            'foo'
-          )
+            'foo',
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -231,12 +231,12 @@ describe('vModel', () => {
         return [
           withVModel(
             h('textarea', {
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -265,52 +265,52 @@ describe('vModel', () => {
               class: 'number',
               'onUpdate:modelValue': (val: any) => {
                 this.number = val
-              }
+              },
             }),
             this.number,
             {
-              number: true
-            }
+              number: true,
+            },
           ),
           withVModel(
             h('input', {
               class: 'trim',
               'onUpdate:modelValue': (val: any) => {
                 this.trim = val
-              }
+              },
             }),
             this.trim,
             {
-              trim: true
-            }
+              trim: true,
+            },
           ),
           withVModel(
             h('input', {
               class: 'trim-number',
               'onUpdate:modelValue': (val: any) => {
                 this.trimNumber = val
-              }
+              },
             }),
             this.trimNumber,
             {
               trim: true,
-              number: true
-            }
+              number: true,
+            },
           ),
           withVModel(
             h('input', {
               class: 'lazy',
               'onUpdate:modelValue': (val: any) => {
                 this.lazy = val
-              }
+              },
             }),
             this.lazy,
             {
-              lazy: true
-            }
-          )
+              lazy: true,
+            },
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -359,12 +359,12 @@ describe('vModel', () => {
               min: 1,
               max: 100,
               class: 'foo',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
             this.value,
             {
-              number: true
-            }
+              number: true,
+            },
           ),
           withVModel(
             h('input', {
@@ -372,15 +372,15 @@ describe('vModel', () => {
               min: 1,
               max: 100,
               class: 'bar',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
             this.value,
             {
-              lazy: true
-            }
-          )
+              lazy: true,
+            },
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -444,12 +444,12 @@ describe('vModel', () => {
           withVModel(
             h('input', {
               type: 'checkbox',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -487,12 +487,12 @@ describe('vModel', () => {
               type: 'checkbox',
               'true-value': 'yes',
               'false-value': 'no',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -533,12 +533,12 @@ describe('vModel', () => {
               type: 'checkbox',
               'true-value': { yes: 'yes' },
               'false-value': { no: 'no' },
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -576,21 +576,21 @@ describe('vModel', () => {
               type: 'checkbox',
               class: 'foo',
               value: 'foo',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
+            this.value,
           ),
           withVModel(
             h('input', {
               type: 'checkbox',
               class: 'bar',
               value: 'bar',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -646,21 +646,21 @@ describe('vModel', () => {
               type: 'checkbox',
               class: 'foo',
               value: 'foo',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
+            this.value,
           ),
           withVModel(
             h('input', {
               type: 'checkbox',
               class: 'bar',
               value: 'bar',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -716,21 +716,21 @@ describe('vModel', () => {
               type: 'radio',
               class: 'foo',
               value: 'foo',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
+            this.value,
           ),
           withVModel(
             h('input', {
               type: 'radio',
               class: 'bar',
               value: 'bar',
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -776,14 +776,14 @@ describe('vModel', () => {
               'select',
               {
                 value: null,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
-              [h('option', { value: 'foo' }), h('option', { value: 'bar' })]
+              [h('option', { value: 'foo' }), h('option', { value: 'bar' })],
             ),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -833,14 +833,14 @@ describe('vModel', () => {
               {
                 value: null,
                 multiple: true,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
-              [h('option', { value: 'foo' }), h('option', { value: 'bar' })]
+              [h('option', { value: 'foo' }), h('option', { value: 'bar' })],
             ),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -894,17 +894,17 @@ describe('vModel', () => {
               'select',
               {
                 value: null,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
-              [h('option', { value: '1' }), h('option', { value: '2' })]
+              [h('option', { value: '1' }), h('option', { value: '2' })],
             ),
             this.value,
             {
-              number: true
-            }
-          )
+              number: true,
+            },
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -932,17 +932,17 @@ describe('vModel', () => {
               {
                 value: null,
                 multiple: true,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
-              [h('option', { value: '1' }), h('option', { value: '2' })]
+              [h('option', { value: '1' }), h('option', { value: '2' })],
             ),
             this.value,
             {
-              number: true
-            }
-          )
+              number: true,
+            },
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -1000,17 +1000,17 @@ describe('vModel', () => {
               {
                 value: null,
                 multiple: true,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
               [
                 h('option', { value: fooValue }),
-                h('option', { value: barValue })
-              ]
+                h('option', { value: barValue }),
+              ],
             ),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -1066,14 +1066,14 @@ describe('vModel', () => {
               {
                 value: null,
                 multiple: true,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
-              [h('option', { value: 'foo' }), h('option', { value: 'bar' })]
+              [h('option', { value: 'foo' }), h('option', { value: 'bar' })],
             ),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -1134,17 +1134,17 @@ describe('vModel', () => {
               {
                 value: null,
                 multiple: true,
-                'onUpdate:modelValue': setValue.bind(this)
+                'onUpdate:modelValue': setValue.bind(this),
               },
               [
                 h('option', { value: fooValue }),
-                h('option', { value: barValue })
-              ]
+                h('option', { value: barValue }),
+              ],
             ),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -1196,12 +1196,12 @@ describe('vModel', () => {
         return [
           withVModel(
             h('input', {
-              'onUpdate:modelValue': setValue.bind(this)
+              'onUpdate:modelValue': setValue.bind(this),
             }),
-            this.value
-          )
+            this.value,
+          ),
         ]
-      }
+      },
     })
     render(h(component), root)
 
index 33ffec637df22ab6a8cef6317c72bbdf86badb55..03620f747e7abe897990510630db3294433087f4 100644 (file)
@@ -1,14 +1,14 @@
 import { patchEvent } from '../../src/modules/events'
-import { withModifiers, withKeys } from '@vue/runtime-dom'
+import { withKeys, withModifiers } from '@vue/runtime-dom'
 
 function triggerEvent(
   target: Element,
   event: string,
-  process?: (e: any) => any
+  process?: (e: any) => any,
 ) {
   const e = new Event(event, {
     bubbles: true,
-    cancelable: true
+    cancelable: true,
   })
   if (event === 'click') {
     ;(e as any).button = 0
@@ -51,7 +51,7 @@ describe('runtime-dom: v-on directive', () => {
       // <div @keyup[keyName].esc="test"/>
       const nextValue = withKeys(withModifiers(fn, [keyName]), [
         'esc',
-        'arrow-left'
+        'arrow-left',
       ])
       patchEvent(el, 'onKeyup', null, nextValue, null)
 
index 545e22b9c75cb937c7c806884dd6f2da7ebcd4db..e2e5baac45eae593624c1dd267489de81e3d01ae 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  withDirectives,
+  type VNode,
   defineComponent,
   h,
   nextTick,
-  VNode,
   ref,
-  watch
+  watch,
+  withDirectives,
 } from '@vue/runtime-core'
-import { render, Transition, vShow } from '@vue/runtime-dom'
+import { Transition, render, vShow } from '@vue/runtime-dom'
 
 const withVShow = (node: VNode, exp: any) =>
   withDirectives(node, [[vShow, exp]])
@@ -26,7 +26,7 @@ describe('runtime-dom: v-show directive', () => {
       },
       render() {
         return [withVShow(h('div'), this.value)]
-      }
+      },
     })
     render(h(component), root)
 
@@ -42,7 +42,7 @@ describe('runtime-dom: v-show directive', () => {
       },
       render() {
         return [withVShow(h('div'), this.value)]
-      }
+      },
     })
     render(h(component), root)
 
@@ -58,7 +58,7 @@ describe('runtime-dom: v-show directive', () => {
       },
       render() {
         return [withVShow(h('div'), this.value)]
-      }
+      },
     })
     render(h(component), root)
 
@@ -107,9 +107,9 @@ describe('runtime-dom: v-show directive', () => {
       },
       render() {
         return [
-          withVShow(h('div', { style: { display: 'block' } }), this.value)
+          withVShow(h('div', { style: { display: 'block' } }), this.value),
         ]
-      }
+      },
     })
     render(h(component), root)
 
@@ -134,7 +134,7 @@ describe('runtime-dom: v-show directive', () => {
     const component = defineComponent({
       render() {
         return withVShow(h('div', { style: style.value }), display.value)
-      }
+      },
     })
     render(h(component), root)
 
@@ -165,11 +165,11 @@ describe('runtime-dom: v-show directive', () => {
           return h(Transition, () =>
             withVShow(
               h('div', { style: style.value }, innerValue.value),
-              display.value
-            )
+              display.value,
+            ),
           )
         }
-      }
+      },
     })
     render(h(component), root)
 
index bb65082add1255a1dd252d37c347f70d0f9399c3..53868e74dc24e245327d9b39e2db52274a0e8c92 100644 (file)
@@ -1,4 +1,4 @@
-import { render, h, nodeOps } from '@vue/runtime-test'
+import { h, nodeOps, render } from '@vue/runtime-test'
 import { useCssModule } from '../../src/helpers/useCssModule'
 
 describe('useCssModule', () => {
@@ -10,9 +10,9 @@ describe('useCssModule', () => {
         __cssModules: modules,
         setup() {
           res = useCssModule(name)
-        }
+        },
       }),
-      nodeOps.createElement('div')
+      nodeOps.createElement('div'),
     )
     return res
   }
@@ -20,8 +20,8 @@ describe('useCssModule', () => {
   test('basic usage', () => {
     const modules = {
       $style: {
-        red: 'red'
-      }
+        red: 'red',
+      },
     }
     expect(mountWithModule(modules)).toMatchObject(modules.$style)
   })
@@ -29,8 +29,8 @@ describe('useCssModule', () => {
   test('basic usage', () => {
     const modules = {
       foo: {
-        red: 'red'
-      }
+        red: 'red',
+      },
     }
     expect(mountWithModule(modules, 'foo')).toMatchObject(modules.foo)
   })
index 0d8b8d0d26e90d51396833e403162210b90b490e..e26b9dfb45e0916dd06124498a53849d3795ea49 100644 (file)
@@ -1,15 +1,15 @@
 import {
-  ref,
-  render,
-  useCssVars,
+  type ComponentOptions,
+  type FunctionalComponent,
+  Suspense,
+  Teleport,
   createStaticVNode,
   h,
-  reactive,
   nextTick,
-  ComponentOptions,
-  Suspense,
-  Teleport,
-  FunctionalComponent
+  reactive,
+  ref,
+  render,
+  useCssVars,
 } from '@vue/runtime-dom'
 
 describe('useCssVars', () => {
@@ -36,13 +36,13 @@ describe('useCssVars', () => {
       setup() {
         // test receiving render context
         useCssVars((ctx: any) => ({
-          color: ctx.color
+          color: ctx.color,
         }))
         return state
       },
       render() {
         return h('div')
-      }
+      },
     }))
   })
 
@@ -51,7 +51,7 @@ describe('useCssVars', () => {
       setup() {
         useCssVars(() => state)
         return () => [h('div'), h('div')]
-      }
+      },
     }))
   })
 
@@ -62,7 +62,7 @@ describe('useCssVars', () => {
       setup() {
         useCssVars(() => state)
         return () => h(Child)
-      }
+      },
     }))
   })
 
@@ -81,7 +81,7 @@ describe('useCssVars', () => {
           }
         })
         return asyncPromise
-      }
+      },
     }
 
     const App = {
@@ -90,9 +90,9 @@ describe('useCssVars', () => {
         return () =>
           h(Suspense, null, {
             default: h(AsyncComp),
-            fallback: h('div', 'fallback')
+            fallback: h('div', 'fallback'),
           })
-      }
+      },
     }
 
     render(h(App), root)
@@ -127,7 +127,7 @@ describe('useCssVars', () => {
       setup() {
         useCssVars(() => state)
         return () => (value.value ? [h('div')] : [h('div'), h('div')])
-      }
+      },
     }
 
     render(h(App), root)
@@ -157,9 +157,9 @@ describe('useCssVars', () => {
         useCssVars(() => state)
         return () =>
           h(Child, null, () =>
-            value.value ? [h('div')] : [h('div'), h('div')]
+            value.value ? [h('div')] : [h('div'), h('div')],
           )
-      }
+      },
     }
 
     render(h(App), root)
@@ -186,9 +186,9 @@ describe('useCssVars', () => {
         return () => [
           h('div'),
           createStaticVNode('<div>1</div><div><span>2</span></div>', 2),
-          h('div')
+          h('div'),
         ]
-      }
+      },
     }
 
     render(h(App), root)
@@ -208,7 +208,7 @@ describe('useCssVars', () => {
       setup() {
         useCssVars(() => state)
         return () => [h(Teleport, { to: target }, [h('div')])]
-      }
+      },
     }
 
     render(h(App), root)
@@ -232,7 +232,7 @@ describe('useCssVars', () => {
       setup() {
         useCssVars(() => state)
         return () => h(Child, () => [h(Teleport, { to: target }, [h('div')])])
-      }
+      },
     }
 
     render(h(App), root)
@@ -255,10 +255,10 @@ describe('useCssVars', () => {
         return () => [
           h(Teleport, { to: target }, [
             h('div'),
-            toggle.value ? h('div') : null
-          ])
+            toggle.value ? h('div') : null,
+          ]),
         ]
-      }
+      },
     }
 
     render(h(App), root)
@@ -286,7 +286,7 @@ describe('useCssVars', () => {
       setup() {
         useCssVars(() => state)
         return () => [h(Teleport, { to: target, disabled: true }, [h('div')])]
-      }
+      },
     }
 
     expect(() => render(h(App), root)).not.toThrow(TypeError)
@@ -307,10 +307,10 @@ describe('useCssVars', () => {
           h(
             'div',
             { style: disabled.value ? 'pointer-events: none' : undefined },
-            'foo'
-          )
+            'foo',
+          ),
         ]
-      }
+      },
     }
     render(h(App), root)
     await nextTick()
index 87adafd6696d4974bf28c5dce73fee82e3ba8018..e185f14d8dd414b13fdc9198f958eef42886b2d6 100644 (file)
@@ -3,7 +3,7 @@ import { nodeOps, svgNS } from '../src/nodeOps'
 describe('runtime-dom: node-ops', () => {
   test("the <select>'s multiple attr should be set in createElement", () => {
     const el = nodeOps.createElement('select', undefined, undefined, {
-      multiple: ''
+      multiple: '',
     }) as HTMLSelectElement
     const option1 = nodeOps.createElement('option') as HTMLOptionElement
     const option2 = nodeOps.createElement('option') as HTMLOptionElement
@@ -25,7 +25,7 @@ describe('runtime-dom: node-ops', () => {
         content,
         parent,
         null,
-        undefined
+        undefined,
       )
       expect(parent.innerHTML).toBe(content)
       expect(nodes[0]).toBe(parent.firstChild)
@@ -42,7 +42,7 @@ describe('runtime-dom: node-ops', () => {
         content,
         parent,
         anchor,
-        undefined
+        undefined,
       )
       expect(parent.innerHTML).toBe(content + existing)
       expect(nodes[0]).toBe(parent.firstChild)
@@ -56,7 +56,7 @@ describe('runtime-dom: node-ops', () => {
         content,
         parent,
         null,
-        'svg'
+        'svg',
       )
       expect(parent.innerHTML).toBe(content)
       expect(first).toBe(parent.firstChild)
@@ -75,7 +75,7 @@ describe('runtime-dom: node-ops', () => {
         content,
         parent,
         anchor,
-        'svg'
+        'svg',
       )
       expect(parent.innerHTML).toBe(content + existing)
       expect(first).toBe(parent.firstChild)
@@ -100,7 +100,7 @@ describe('runtime-dom: node-ops', () => {
         anchor,
         undefined,
         cached.firstChild,
-        cached.lastChild
+        cached.lastChild,
       )
       expect(parent.innerHTML).toBe(content + existing)
       expect(nodes[0]).toBe(parent.firstChild)
index 7af4c885cbedcd7f310d399033b9ac6e7bb5a6a9..8651d12eb7e2c6e1eb503b5653d1305eb2e0607b 100644 (file)
@@ -1,5 +1,8 @@
 import { patchProp } from '../src/patchProp'
-import { ElementWithTransition, vtcKey } from '../src/components/Transition'
+import {
+  type ElementWithTransition,
+  vtcKey,
+} from '../src/components/Transition'
 import { svgNS } from '../src/nodeOps'
 
 describe('runtime-dom: class patching', () => {
index d332977df960fa17e78c0856821f24df3471cd08..1b08f85caa47d5b14266647d5280e0474499e79f 100644 (file)
@@ -176,7 +176,7 @@ describe(`runtime-dom: events patching`, () => {
     }
     window.customElements.define('test-element', TestElement)
     const testElement = document.createElement('test-element', {
-      is: 'test-element'
+      is: 'test-element',
     })
     const fn1 = vi.fn()
     const fn2 = vi.fn()
index f5542c17d8ccfdac6755e528e0308ad040291e2a..7c356f1a66cb01d8f34f4ca9da4483c9a1b3013d 100644 (file)
@@ -1,5 +1,5 @@
 import { patchProp } from '../src/patchProp'
-import { render, h } from '../src'
+import { h, render } from '../src'
 
 describe('runtime-dom: props patching', () => {
   test('basic', () => {
@@ -106,7 +106,7 @@ describe('runtime-dom: props patching', () => {
     const fn = vi.fn()
     const comp = {
       render: () => 'foo',
-      unmounted: fn
+      unmounted: fn,
     }
     const root = document.createElement('div')
     render(h('div', null, [h(comp)]), root)
@@ -122,7 +122,7 @@ describe('runtime-dom: props patching', () => {
     const fn = vi.fn()
     const comp = {
       render: () => 'foo',
-      unmounted: fn
+      unmounted: fn,
     }
     const root = document.createElement('div')
     render(h('div', null, [h(comp)]), root)
@@ -137,7 +137,7 @@ describe('runtime-dom: props patching', () => {
     const fn = vi.fn()
     const comp = {
       render: () => 'foo',
-      unmounted: fn
+      unmounted: fn,
     }
     const root = document.createElement('div')
     render(h('div', null, [h(comp)]), root)
@@ -169,7 +169,7 @@ describe('runtime-dom: props patching', () => {
     Object.defineProperty(el, 'someProp', {
       set() {
         throw new TypeError('Invalid type')
-      }
+      },
     })
     patchProp(el, 'someProp', null, 'foo')
 
@@ -265,7 +265,7 @@ describe('runtime-dom: props patching', () => {
     patchProp(el, 'willValidate', true, null)
     expect(el.willValidate).toBe(true)
     expect(
-      'Failed setting prop "willValidate" on <select>'
+      'Failed setting prop "willValidate" on <select>',
     ).toHaveBeenWarnedLast()
   })
 
@@ -274,9 +274,9 @@ describe('runtime-dom: props patching', () => {
     render(
       h('select', { value: 'foo' }, [
         h('option', { value: 'foo' }, 'foo'),
-        h('option', { value: 'bar' }, 'bar')
+        h('option', { value: 'bar' }, 'bar'),
       ]),
-      root
+      root,
     )
     const el = root.children[0] as HTMLSelectElement
     expect(el.value).toBe('foo')
@@ -284,9 +284,9 @@ describe('runtime-dom: props patching', () => {
     render(
       h('select', { value: 'baz' }, [
         h('option', { value: 'foo' }, 'foo'),
-        h('option', { value: 'baz' }, 'baz')
+        h('option', { value: 'baz' }, 'baz'),
       ]),
-      root
+      root,
     )
     expect(el.value).toBe('baz')
   })
index eeb60fb7eacfa7a79b6d125acf179fb0e00ebc5e..e7cd0984a19bcbf8939cb18a28441b00752dea65 100644 (file)
@@ -16,7 +16,7 @@ describe(`runtime-dom: style patching`, () => {
       get(): any {
         return value
       },
-      set: fn
+      set: fn,
     })
     patchProp(el, 'style', value, value)
     expect(el.style.cssText.replace(/\s/g, '')).toBe('color:red;')
@@ -39,7 +39,7 @@ describe(`runtime-dom: style patching`, () => {
     const el = document.createElement('div')
     patchProp(el, 'style', null, {
       color: undefined,
-      borderRadius: null
+      borderRadius: null,
     })
     expect(el.style.cssText.replace(/\s/g, '')).toBe('')
 
@@ -47,7 +47,7 @@ describe(`runtime-dom: style patching`, () => {
       el,
       'style',
       { color: 'red' },
-      { color: null, borderRadius: undefined }
+      { color: null, borderRadius: undefined },
     )
     expect(el.style.cssText.replace(/\s/g, '')).toBe('')
   })
@@ -62,7 +62,7 @@ describe(`runtime-dom: style patching`, () => {
     const el = document.createElement('div')
     patchProp(el, 'style', {}, { marginRight: '10px !important' })
     expect(el.style.cssText.replace(/\s/g, '')).toBe(
-      'margin-right:10px!important;'
+      'margin-right:10px!important;',
     )
   })
 
@@ -91,12 +91,12 @@ describe(`runtime-dom: style patching`, () => {
     const el = document.createElement('div')
     patchProp(el, 'style', null, { color: 'red;' })
     expect(
-      `Unexpected semicolon at the end of 'color' style value: 'red;'`
+      `Unexpected semicolon at the end of 'color' style value: 'red;'`,
     ).toHaveBeenWarned()
 
     patchProp(el, 'style', null, { '--custom': '100; ' })
     expect(
-      `Unexpected semicolon at the end of '--custom' style value: '100; '`
+      `Unexpected semicolon at the end of '--custom' style value: '100; '`,
     ).toHaveBeenWarned()
   })
 
@@ -112,7 +112,7 @@ describe(`runtime-dom: style patching`, () => {
       el as any,
       'style',
       { borderBottom: '1px solid red' },
-      { border: '1px solid green' }
+      { border: '1px solid green' },
     )
     expect(el.style.border).toBe('1px solid green')
     expect(el.style.borderBottom).toBe('1px solid green')
@@ -131,8 +131,8 @@ describe(`runtime-dom: style patching`, () => {
         },
         getPropertyValue(key: string) {
           return store[key]
-        }
-      }
+        },
+      },
     }
   }
 
@@ -154,7 +154,7 @@ describe(`runtime-dom: style patching`, () => {
       el as any,
       'style',
       {},
-      { display: ['-webkit-box', '-ms-flexbox', 'flex'] }
+      { display: ['-webkit-box', '-ms-flexbox', 'flex'] },
     )
     expect(el.style.display).toBe('flex')
   })
index de37605d68a7151456ffcd220e3426979b5a090f..337a3d90f9a1ec14dc17881b9bbeafabfa718172 100644 (file)
@@ -1,27 +1,27 @@
 import {
-  ComponentOptionsMixin,
-  ComponentOptionsWithArrayProps,
-  ComponentOptionsWithObjectProps,
-  ComponentOptionsWithoutProps,
-  ComponentPropsOptions,
-  ComputedOptions,
-  EmitsOptions,
-  MethodOptions,
-  RenderFunction,
-  SetupContext,
-  ComponentInternalInstance,
-  VNode,
-  RootHydrateFunction,
-  ExtractPropTypes,
+  type ComponentInjectOptions,
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  type ComponentOptionsMixin,
+  type ComponentOptionsWithArrayProps,
+  type ComponentOptionsWithObjectProps,
+  type ComponentOptionsWithoutProps,
+  type ComponentPropsOptions,
+  type ComputedOptions,
+  type ConcreteComponent,
+  type DefineComponent,
+  type EmitsOptions,
+  type ExtractPropTypes,
+  type MethodOptions,
+  type RenderFunction,
+  type RootHydrateFunction,
+  type SetupContext,
+  type SlotsType,
+  type VNode,
   createVNode,
   defineComponent,
   nextTick,
   warn,
-  ConcreteComponent,
-  ComponentOptions,
-  ComponentInjectOptions,
-  SlotsType,
-  DefineComponent
 } from '@vue/runtime-core'
 import { camelize, extend, hyphenate, isArray, toNumber } from '@vue/shared'
 import { hydrate, render } from '.'
@@ -37,8 +37,8 @@ export type VueElementConstructor<P = {}> = {
 export function defineCustomElement<Props, RawBindings = object>(
   setup: (
     props: Readonly<Props>,
-    ctx: SetupContext
-  ) => RawBindings | RenderFunction
+    ctx: SetupContext,
+  ) => RawBindings | RenderFunction,
 ): VueElementConstructor<Props>
 
 // overload 2: object format with no props
@@ -54,7 +54,7 @@ export function defineCustomElement<
   EE extends string = string,
   I extends ComponentInjectOptions = {},
   II extends string = string,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 >(
   options: ComponentOptionsWithoutProps<
     Props,
@@ -69,7 +69,7 @@ export function defineCustomElement<
     I,
     II,
     S
-  > & { styles?: string[] }
+  > & { styles?: string[] },
 ): VueElementConstructor<Props>
 
 // overload 3: object format with array props declaration
@@ -85,7 +85,7 @@ export function defineCustomElement<
   EE extends string = string,
   I extends ComponentInjectOptions = {},
   II extends string = string,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 >(
   options: ComponentOptionsWithArrayProps<
     PropNames,
@@ -100,7 +100,7 @@ export function defineCustomElement<
     I,
     II,
     S
-  > & { styles?: string[] }
+  > & { styles?: string[] },
 ): VueElementConstructor<{ [K in PropNames]: any }>
 
 // overload 4: object format with object props declaration
@@ -116,7 +116,7 @@ export function defineCustomElement<
   EE extends string = string,
   I extends ComponentInjectOptions = {},
   II extends string = string,
-  S extends SlotsType = {}
+  S extends SlotsType = {},
 >(
   options: ComponentOptionsWithObjectProps<
     PropsOptions,
@@ -131,19 +131,19 @@ export function defineCustomElement<
     I,
     II,
     S
-  > & { styles?: string[] }
+  > & { styles?: string[] },
 ): VueElementConstructor<ExtractPropTypes<PropsOptions>>
 
 // overload 5: defining a custom element from the returned value of
 // `defineComponent`
 export function defineCustomElement<P>(
-  options: DefineComponent<P, any, any, any>
+  options: DefineComponent<P, any, any, any>,
 ): VueElementConstructor<ExtractPropTypes<P>>
 
 /*! #__NO_SIDE_EFFECTS__ */
 export function defineCustomElement(
   options: any,
-  hydrate?: RootHydrateFunction
+  hydrate?: RootHydrateFunction,
 ): VueElementConstructor {
   const Comp = defineComponent(options) as any
   class VueCustomElement extends VueElement {
@@ -158,7 +158,7 @@ export function defineCustomElement(
 
 /*! #__NO_SIDE_EFFECTS__ */
 export const defineSSRCustomElement = ((options: any) => {
-  // @ts-ignore
+  // @ts-expect-error
   return defineCustomElement(options, hydrate)
 }) as typeof defineCustomElement
 
@@ -182,7 +182,7 @@ export class VueElement extends BaseClass {
   constructor(
     private _def: InnerComponentDef,
     private _props: Record<string, any> = {},
-    hydrate?: RootHydrateFunction
+    hydrate?: RootHydrateFunction,
   ) {
     super()
     if (this.shadowRoot && hydrate) {
@@ -191,7 +191,7 @@ export class VueElement extends BaseClass {
       if (__DEV__ && this.shadowRoot) {
         warn(
           `Custom element has pre-rendered declarative shadow root but is not ` +
-            `defined as hydratable. Use \`defineSSRCustomElement\`.`
+            `defined as hydratable. Use \`defineSSRCustomElement\`.`,
         )
       }
       this.attachShadow({ mode: 'open' })
@@ -307,7 +307,7 @@ export class VueElement extends BaseClass {
         },
         set(val) {
           this._setProp(key, val)
-        }
+        },
       })
     }
   }
@@ -335,7 +335,7 @@ export class VueElement extends BaseClass {
     key: string,
     val: any,
     shouldReflect = true,
-    shouldUpdate = true
+    shouldUpdate = true,
   ) {
     if (val !== this._props[key]) {
       this._props[key] = val
@@ -382,8 +382,8 @@ export class VueElement extends BaseClass {
         const dispatch = (event: string, args: any[]) => {
           this.dispatchEvent(
             new CustomEvent(event, {
-              detail: args
-            })
+              detail: args,
+            }),
           )
         }
 
index b06752132980b1687ff0b8676161da8ff404a175..cce247fe1aebe257d744b01295a850c1d63a2b43 100644 (file)
@@ -1,14 +1,14 @@
 import {
   BaseTransition,
-  BaseTransitionProps,
+  type BaseTransitionProps,
   BaseTransitionPropsValidators,
-  h,
+  DeprecationTypes,
+  type FunctionalComponent,
   assertNumber,
-  FunctionalComponent,
   compatUtils,
-  DeprecationTypes
+  h,
 } from '@vue/runtime-core'
-import { isObject, toNumber, extend, isArray } from '@vue/shared'
+import { extend, isArray, isObject, toNumber } from '@vue/shared'
 
 const TRANSITION = 'transition'
 const ANIMATION = 'animation'
@@ -46,7 +46,7 @@ export interface ElementWithTransition extends HTMLElement {
 // base Transition component, with DOM-specific logic.
 export const Transition: FunctionalComponent<TransitionProps> = (
   props,
-  { slots }
+  { slots },
 ) => h(BaseTransition, resolveTransitionProps(props), slots)
 
 Transition.displayName = 'Transition'
@@ -60,7 +60,7 @@ const DOMTransitionPropsValidators = {
   type: String,
   css: {
     type: Boolean,
-    default: true
+    default: true,
   },
   duration: [String, Number, Object],
   enterFromClass: String,
@@ -71,14 +71,14 @@ const DOMTransitionPropsValidators = {
   appearToClass: String,
   leaveFromClass: String,
   leaveActiveClass: String,
-  leaveToClass: String
+  leaveToClass: String,
 }
 
 export const TransitionPropsValidators = (Transition.props =
   /*#__PURE__*/ extend(
     {},
     BaseTransitionPropsValidators as any,
-    DOMTransitionPropsValidators
+    DOMTransitionPropsValidators,
   ))
 
 /**
@@ -87,7 +87,7 @@ export const TransitionPropsValidators = (Transition.props =
  */
 const callHook = (
   hook: Function | Function[] | undefined,
-  args: any[] = []
+  args: any[] = [],
 ) => {
   if (isArray(hook)) {
     hook.forEach(h => h(...args))
@@ -101,7 +101,7 @@ const callHook = (
  * intends to explicitly control the end of the transition.
  */
 const hasExplicitCallback = (
-  hook: Function | Function[] | undefined
+  hook: Function | Function[] | undefined,
 ): boolean => {
   return hook
     ? isArray(hook)
@@ -111,7 +111,7 @@ const hasExplicitCallback = (
 }
 
 export function resolveTransitionProps(
-  rawProps: TransitionProps
+  rawProps: TransitionProps,
 ): BaseTransitionProps<Element> {
   const baseProps: BaseTransitionProps<Element> = {}
   for (const key in rawProps) {
@@ -136,7 +136,7 @@ export function resolveTransitionProps(
     appearToClass = enterToClass,
     leaveFromClass = `${name}-leave-from`,
     leaveActiveClass = `${name}-leave-active`,
-    leaveToClass = `${name}-leave-to`
+    leaveToClass = `${name}-leave-to`,
   } = rawProps
 
   // legacy transition class compat
@@ -170,7 +170,7 @@ export function resolveTransitionProps(
     onLeaveCancelled,
     onBeforeAppear = onBeforeEnter,
     onAppear = onEnter,
-    onAppearCancelled = onEnterCancelled
+    onAppearCancelled = onEnterCancelled,
   } = baseProps
 
   const finishEnter = (el: Element, isAppear: boolean, done?: () => void) => {
@@ -181,7 +181,7 @@ export function resolveTransitionProps(
 
   const finishLeave = (
     el: Element & { _isLeaving?: boolean },
-    done?: () => void
+    done?: () => void,
   ) => {
     el._isLeaving = false
     removeTransitionClass(el, leaveFromClass)
@@ -269,12 +269,12 @@ export function resolveTransitionProps(
     onLeaveCancelled(el) {
       finishLeave(el)
       callHook(onLeaveCancelled, [el])
-    }
+    },
   } as BaseTransitionProps<Element>)
 }
 
 function normalizeDuration(
-  duration: TransitionProps['duration']
+  duration: TransitionProps['duration'],
 ): [number, number] | null {
   if (duration == null) {
     return null
@@ -325,7 +325,7 @@ function whenTransitionEnds(
   el: Element & { _endId?: number },
   expectedType: TransitionProps['type'] | undefined,
   explicitTimeout: number | null,
-  resolve: () => void
+  resolve: () => void,
 ) {
   const id = (el._endId = ++endId)
   const resolveIfNotStale = () => {
@@ -376,7 +376,7 @@ type StylePropertiesKey =
 
 export function getTransitionInfo(
   el: Element,
-  expectedType?: TransitionProps['type']
+  expectedType?: TransitionProps['type'],
 ): CSSTransitionInfo {
   const styles = window.getComputedStyle(el) as Pick<
     CSSStyleDeclaration,
@@ -425,13 +425,13 @@ export function getTransitionInfo(
   const hasTransform =
     type === TRANSITION &&
     /\b(transform|all)(,|$)/.test(
-      getStyleProperties(`${TRANSITION}Property`).toString()
+      getStyleProperties(`${TRANSITION}Property`).toString(),
     )
   return {
     type,
     timeout,
     propCount,
-    hasTransform
+    hasTransform,
   }
 }
 
index fc5d260b91ef81121b7e0f156245fc9d676808b9..f98e82b2734ba85bd54d2c377db11ab5a354d0d2 100644 (file)
@@ -1,30 +1,30 @@
 import {
-  TransitionProps,
+  type ElementWithTransition,
+  type TransitionProps,
+  TransitionPropsValidators,
   addTransitionClass,
-  removeTransitionClass,
-  ElementWithTransition,
+  forceReflow,
   getTransitionInfo,
+  removeTransitionClass,
   resolveTransitionProps,
-  TransitionPropsValidators,
-  forceReflow,
-  vtcKey
+  vtcKey,
 } from './Transition'
 import {
+  type ComponentOptions,
+  DeprecationTypes,
   Fragment,
-  VNode,
-  warn,
-  resolveTransitionHooks,
-  useTransitionState,
-  getTransitionRawChildren,
-  getCurrentInstance,
-  setTransitionHooks,
+  type SetupContext,
+  type VNode,
+  compatUtils,
   createVNode,
+  getCurrentInstance,
+  getTransitionRawChildren,
   onUpdated,
-  SetupContext,
+  resolveTransitionHooks,
+  setTransitionHooks,
   toRaw,
-  compatUtils,
-  DeprecationTypes,
-  ComponentOptions
+  useTransitionState,
+  warn,
 } from '@vue/runtime-core'
 import { extend } from '@vue/shared'
 
@@ -42,7 +42,7 @@ const TransitionGroupImpl: ComponentOptions = {
 
   props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
     tag: String,
-    moveClass: String
+    moveClass: String,
   }),
 
   setup(props: TransitionGroupProps, { slots }: SetupContext) {
@@ -62,7 +62,7 @@ const TransitionGroupImpl: ComponentOptions = {
         !hasCSSTransform(
           prevChildren[0].el as ElementWithTransition,
           instance.vnode.el as Node,
-          moveClass
+          moveClass,
         )
       ) {
         return
@@ -106,7 +106,7 @@ const TransitionGroupImpl: ComponentOptions = {
         !rawProps.tag &&
         compatUtils.checkCompatEnabled(
           DeprecationTypes.TRANSITION_GROUP_ROOT,
-          instance.parent
+          instance.parent,
         )
       ) {
         tag = 'span'
@@ -120,7 +120,7 @@ const TransitionGroupImpl: ComponentOptions = {
         if (child.key != null) {
           setTransitionHooks(
             child,
-            resolveTransitionHooks(child, cssTransitionProps, state, instance)
+            resolveTransitionHooks(child, cssTransitionProps, state, instance),
           )
         } else if (__DEV__) {
           warn(`<TransitionGroup> children must be keyed.`)
@@ -132,7 +132,7 @@ const TransitionGroupImpl: ComponentOptions = {
           const child = prevChildren[i]
           setTransitionHooks(
             child,
-            resolveTransitionHooks(child, cssTransitionProps, state, instance)
+            resolveTransitionHooks(child, cssTransitionProps, state, instance),
           )
           positionMap.set(child, (child.el as Element).getBoundingClientRect())
         }
@@ -140,7 +140,7 @@ const TransitionGroupImpl: ComponentOptions = {
 
       return createVNode(tag, null, children)
     }
-  }
+  },
 }
 
 if (__COMPAT__) {
@@ -192,7 +192,7 @@ function applyTranslation(c: VNode): VNode | undefined {
 function hasCSSTransform(
   el: ElementWithTransition,
   root: Node,
-  moveClass: string
+  moveClass: string,
 ): boolean {
   // Detect whether an element with the move class applied has
   // CSS transitions. Since the element may be inside an entering
index 1bc4e76dfbc4e9e3ff13caab83336d3013389fad..7b387096b6804c520692e9e57d9190b89fd69951 100644 (file)
@@ -1,18 +1,18 @@
 import {
-  ObjectDirective,
-  VNode,
-  DirectiveHook,
-  DirectiveBinding,
-  warn
+  type DirectiveBinding,
+  type DirectiveHook,
+  type ObjectDirective,
+  type VNode,
+  warn,
 } from '@vue/runtime-core'
 import { addEventListener } from '../modules/events'
 import {
+  invokeArrayFns,
   isArray,
+  isSet,
   looseEqual,
   looseIndexOf,
-  invokeArrayFns,
   looseToNumber,
-  isSet
 } from '@vue/shared'
 
 type AssignerFn = (value: any) => void
@@ -102,7 +102,7 @@ export const vModelText: ModelDirective<
     }
 
     el.value = newValue
-  }
+  },
 }
 
 export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
@@ -143,13 +143,13 @@ export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
   beforeUpdate(el, binding, vnode) {
     el[assignKey] = getModelAssigner(vnode)
     setChecked(el, binding, vnode)
-  }
+  },
 }
 
 function setChecked(
   el: HTMLInputElement,
   { value, oldValue }: DirectiveBinding,
-  vnode: VNode
+  vnode: VNode,
 ) {
   // store the v-model value on the element so it can be accessed by the
   // change listener.
@@ -176,7 +176,7 @@ export const vModelRadio: ModelDirective<HTMLInputElement> = {
     if (value !== oldValue) {
       el.checked = looseEqual(value, vnode.props!.value)
     }
-  }
+  },
 }
 
 export const vModelSelect: ModelDirective<HTMLSelectElement> = {
@@ -188,14 +188,14 @@ export const vModelSelect: ModelDirective<HTMLSelectElement> = {
       const selectedVal = Array.prototype.filter
         .call(el.options, (o: HTMLOptionElement) => o.selected)
         .map((o: HTMLOptionElement) =>
-          number ? looseToNumber(getValue(o)) : getValue(o)
+          number ? looseToNumber(getValue(o)) : getValue(o),
         )
       el[assignKey](
         el.multiple
           ? isSetModel
             ? new Set(selectedVal)
             : selectedVal
-          : selectedVal[0]
+          : selectedVal[0],
       )
     })
     el[assignKey] = getModelAssigner(vnode)
@@ -210,7 +210,7 @@ export const vModelSelect: ModelDirective<HTMLSelectElement> = {
   },
   updated(el, { value }) {
     setSelected(el, value)
-  }
+  },
 }
 
 function setSelected(el: HTMLSelectElement, value: any) {
@@ -219,7 +219,7 @@ function setSelected(el: HTMLSelectElement, value: any) {
     __DEV__ &&
       warn(
         `<select multiple v-model> expects an Array or Set value for its binding, ` +
-          `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
+          `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`,
       )
     return
   }
@@ -252,7 +252,7 @@ function getValue(el: HTMLOptionElement | HTMLInputElement) {
 // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
 function getCheckboxValue(
   el: HTMLInputElement & { _trueValue?: any; _falseValue?: any },
-  checked: boolean
+  checked: boolean,
 ) {
   const key = checked ? '_trueValue' : '_falseValue'
   return key in el ? el[key] : checked
@@ -272,7 +272,7 @@ export const vModelDynamic: ObjectDirective<
   },
   updated(el, binding, vnode, prevVNode) {
     callModelHook(el, binding, vnode, prevVNode, 'updated')
-  }
+  },
 }
 
 function resolveDynamicModel(tagName: string, type: string | undefined) {
@@ -298,11 +298,11 @@ function callModelHook(
   binding: DirectiveBinding,
   vnode: VNode,
   prevVNode: VNode | null,
-  hook: keyof ObjectDirective
+  hook: keyof ObjectDirective,
 ) {
   const modelToUse = resolveDynamicModel(
     el.tagName,
-    vnode.props && vnode.props.type
+    vnode.props && vnode.props.type,
   )
   const fn = modelToUse[hook] as DirectiveHook
   fn && fn(el, binding, vnode, prevVNode)
@@ -340,7 +340,7 @@ export function initVModelForSSR() {
     const modelToUse = resolveDynamicModel(
       // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
       vnode.type.toUpperCase(),
-      vnode.props && vnode.props.type
+      vnode.props && vnode.props.type,
     )
     if (modelToUse.getSSRProps) {
       return modelToUse.getSSRProps(binding, vnode)
index 823c3fb4c412480bbac4af4a2fde2d2d9bdb1b27..5a7d9e4af4a1b2dcad9edd47495599ec82107548 100644 (file)
@@ -1,9 +1,9 @@
 import {
-  getCurrentInstance,
+  type ComponentInternalInstance,
   DeprecationTypes,
-  LegacyConfig,
+  type LegacyConfig,
   compatUtils,
-  ComponentInternalInstance
+  getCurrentInstance,
 } from '@vue/runtime-core'
 import { hyphenate, isArray } from '@vue/shared'
 
@@ -26,17 +26,17 @@ const modifierGuards: Record<
   middle: e => 'button' in e && (e as MouseEvent).button !== 1,
   right: e => 'button' in e && (e as MouseEvent).button !== 2,
   exact: (e, modifiers) =>
-    systemModifiers.some(m => (e as any)[`${m}Key`] && !modifiers.includes(m))
+    systemModifiers.some(m => (e as any)[`${m}Key`] && !modifiers.includes(m)),
 }
 
 /**
  * @private
  */
 export const withModifiers = <
-  T extends (event: Event, ...args: unknown[]) => any
+  T extends (event: Event, ...args: unknown[]) => any,
 >(
   fn: T & { _withMods?: { [key: string]: T } },
-  modifiers: string[]
+  modifiers: string[],
 ) => {
   const cache = fn._withMods || (fn._withMods = {})
   const cacheKey = modifiers.join('.')
@@ -61,7 +61,7 @@ const keyNames: Record<string, string | string[]> = {
   left: 'arrow-left',
   right: 'arrow-right',
   down: 'arrow-down',
-  delete: 'backspace'
+  delete: 'backspace',
 }
 
 /**
@@ -69,7 +69,7 @@ const keyNames: Record<string, string | string[]> = {
  */
 export const withKeys = <T extends (event: KeyboardEvent) => any>(
   fn: T & { _withKeys?: { [k: string]: T } },
-  modifiers: string[]
+  modifiers: string[],
 ) => {
   let globalKeyCodes: LegacyConfig['keyCodes']
   let instance: ComponentInternalInstance | null = null
@@ -85,7 +85,7 @@ export const withKeys = <T extends (event: KeyboardEvent) => any>(
     if (__DEV__ && modifiers.some(m => /^\d+$/.test(m))) {
       compatUtils.warnDeprecation(
         DeprecationTypes.V_ON_KEYCODE_MODIFIER,
-        instance
+        instance,
       )
     }
   }
@@ -110,7 +110,7 @@ export const withKeys = <T extends (event: KeyboardEvent) => any>(
         if (
           compatUtils.isCompatEnabled(
             DeprecationTypes.V_ON_KEYCODE_MODIFIER,
-            instance
+            instance,
           ) &&
           modifiers.some(mod => mod == keyCode)
         ) {
index b848ec9980f4c565daade1be40ce196d28cf7483..0e20d7fa140c3f9e7e752efe932835c6c3f1e3a5 100644 (file)
@@ -1,4 +1,4 @@
-import { ObjectDirective } from '@vue/runtime-core'
+import type { ObjectDirective } from '@vue/runtime-core'
 
 export const vShowOldKey = Symbol('_vod')
 
@@ -39,7 +39,7 @@ export const vShow: ObjectDirective<VShowElement> = {
   },
   beforeUnmount(el, { value }) {
     setDisplay(el, value)
-  }
+  },
 }
 
 function setDisplay(el: VShowElement, value: unknown): void {
index d96dc69c3426938c62e6a1a8f16ea29dc8e9976a..464951f1c4517b80fab1ba9c80a1b644ae25ab6e 100644 (file)
@@ -1,4 +1,4 @@
-import { warn, getCurrentInstance } from '@vue/runtime-core'
+import { getCurrentInstance, warn } from '@vue/runtime-core'
 import { EMPTY_OBJ } from '@vue/shared'
 
 export function useCssModule(name = '$style'): Record<string, string> {
index 4bd9838ba75f47e9cd2c633788c3d07bd1825323..72714e6f623fd0c7f87a98c4fa71c26d04940078 100644 (file)
@@ -1,12 +1,12 @@
 import {
-  getCurrentInstance,
-  warn,
-  VNode,
   Fragment,
   Static,
-  watchPostEffect,
+  type VNode,
+  getCurrentInstance,
   onMounted,
-  onUnmounted
+  onUnmounted,
+  warn,
+  watchPostEffect,
 } from '@vue/runtime-core'
 import { ShapeFlags } from '@vue/shared'
 
@@ -28,7 +28,7 @@ export function useCssVars(getter: (ctx: any) => Record<string, string>) {
 
   const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
     Array.from(
-      document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
+      document.querySelectorAll(`[data-v-owner="${instance.uid}"]`),
     ).forEach(node => setVarsOnNode(node, vars))
   })
 
index 124789100e284f0a196e40f9bdaf920ba44f5066..44ada3d935f4ae7bbf0bf007e884fb833fb6697c 100644 (file)
@@ -1,29 +1,29 @@
 import {
-  createRenderer,
-  createHydrationRenderer,
-  warn,
-  RootRenderFunction,
-  CreateAppFunction,
-  Renderer,
-  HydrationRenderer,
-  App,
-  RootHydrateFunction,
-  isRuntimeOnly,
+  type App,
+  type CreateAppFunction,
   DeprecationTypes,
+  type ElementNamespace,
+  type HydrationRenderer,
+  type Renderer,
+  type RootHydrateFunction,
+  type RootRenderFunction,
   compatUtils,
-  ElementNamespace
+  createHydrationRenderer,
+  createRenderer,
+  isRuntimeOnly,
+  warn,
 } from '@vue/runtime-core'
 import { nodeOps } from './nodeOps'
 import { patchProp } from './patchProp'
 // Importing from the compiler, will be tree-shaken in prod
 import {
+  NOOP,
+  extend,
   isFunction,
-  isString,
   isHTMLTag,
+  isMathMLTag,
   isSVGTag,
-  extend,
-  NOOP,
-  isMathMLTag
+  isString,
 } from '@vue/shared'
 
 declare module '@vue/reactivity' {
@@ -91,7 +91,7 @@ export const createApp = ((...args) => {
           if (attr.name !== 'v-cloak' && /^(v-|:|@)/.test(attr.name)) {
             compatUtils.warnDeprecation(
               DeprecationTypes.GLOBAL_MOUNT_CONTAINER,
-              null
+              null,
             )
             break
           }
@@ -148,7 +148,7 @@ function injectNativeTagCheck(app: App) {
   // this is used for component name validation (dev only)
   Object.defineProperty(app.config, 'isNativeTag', {
     value: (tag: string) => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag),
-    writable: false
+    writable: false,
   })
 }
 
@@ -163,9 +163,9 @@ function injectCompilerOptionsCheck(app: App) {
       set() {
         warn(
           `The \`isCustomElement\` config option is deprecated. Use ` +
-            `\`compilerOptions.isCustomElement\` instead.`
+            `\`compilerOptions.isCustomElement\` instead.`,
         )
-      }
+      },
     })
 
     const compilerOptions = app.config.compilerOptions
@@ -185,19 +185,19 @@ function injectCompilerOptionsCheck(app: App) {
       },
       set() {
         warn(msg)
-      }
+      },
     })
   }
 }
 
 function normalizeContainer(
-  container: Element | ShadowRoot | string
+  container: Element | ShadowRoot | string,
 ): Element | null {
   if (isString(container)) {
     const res = document.querySelector(container)
     if (__DEV__ && !res) {
       warn(
-        `Failed to mount app: mount target selector "${container}" returned null.`
+        `Failed to mount app: mount target selector "${container}" returned null.`,
       )
     }
     return res
@@ -209,7 +209,7 @@ function normalizeContainer(
     container.mode === 'closed'
   ) {
     warn(
-      `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
+      `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`,
     )
   }
   return container as any
@@ -220,7 +220,7 @@ export {
   defineCustomElement,
   defineSSRCustomElement,
   VueElement,
-  type VueElementConstructor
+  type VueElementConstructor,
 } from './apiCustomElement'
 
 // SFC CSS utilities
@@ -231,7 +231,7 @@ export { useCssVars } from './helpers/useCssVars'
 export { Transition, type TransitionProps } from './components/Transition'
 export {
   TransitionGroup,
-  type TransitionGroupProps
+  type TransitionGroupProps,
 } from './components/TransitionGroup'
 
 // **Internal** DOM-only runtime directive helpers
@@ -240,7 +240,7 @@ export {
   vModelCheckbox,
   vModelRadio,
   vModelSelect,
-  vModelDynamic
+  vModelDynamic,
 } from './directives/vModel'
 export { withModifiers, withKeys } from './directives/vOn'
 export { vShow } from './directives/vShow'
index 7ff4160f952c33b0fc672fca7e19ade111946e58..40fe8b58ca0831de1a0a038c95e9758541834898 100644 (file)
@@ -26,7 +26,7 @@
 //                 Kanitkorn Sujautra <https://github.com/lukyth>
 //                 Sebastian Silbermann <https://github.com/eps1lon>
 
-import * as CSS from 'csstype'
+import type * as CSS from 'csstype'
 
 export interface CSSProperties
   extends CSS.Properties<string | number>,
@@ -1386,7 +1386,7 @@ type EventHandlers<E> = {
     : (payload: E[K]) => void
 }
 
-import { VNodeRef } from '@vue/runtime-core'
+import type { VNodeRef } from '@vue/runtime-core'
 
 export type ReservedProps = {
   key?: string | number | symbol
index dc701a959af9a3b5263028730b2072431a57956a..ff3ce36bf52b9d75e9020f6b721624a15becbbc0 100644 (file)
@@ -1,13 +1,13 @@
 import {
+  NOOP,
   includeBooleanAttr,
   isSpecialBooleanAttr,
   makeMap,
-  NOOP
 } from '@vue/shared'
 import {
+  type ComponentInternalInstance,
+  DeprecationTypes,
   compatUtils,
-  ComponentInternalInstance,
-  DeprecationTypes
 } from '@vue/runtime-core'
 
 export const xlinkNS = 'http://www.w3.org/1999/xlink'
@@ -17,7 +17,7 @@ export function patchAttr(
   key: string,
   value: any,
   isSVG: boolean,
-  instance?: ComponentInternalInstance | null
+  instance?: ComponentInternalInstance | null,
 ) {
   if (isSVG && key.startsWith('xlink:')) {
     if (value == null) {
@@ -50,7 +50,7 @@ export function compatCoerceAttr(
   el: Element,
   key: string,
   value: unknown,
-  instance: ComponentInternalInstance | null = null
+  instance: ComponentInternalInstance | null = null,
 ): boolean {
   if (isEnumeratedAttr(key)) {
     const v2CoercedValue =
@@ -66,7 +66,7 @@ export function compatCoerceAttr(
         instance,
         key,
         value,
-        v2CoercedValue
+        v2CoercedValue,
       )
     ) {
       el.setAttribute(key, v2CoercedValue)
@@ -78,7 +78,7 @@ export function compatCoerceAttr(
     compatUtils.softAssertCompatEnabled(
       DeprecationTypes.ATTR_FALSE_VALUE,
       instance,
-      key
+      key,
     )
   ) {
     el.removeAttribute(key)
index bf2c6280c7754ed86b5ef16b952c1e1978455ca5..d4f6c6d9097278b4f4ebdfeeef864ba5b5a6f105 100644 (file)
@@ -1,4 +1,4 @@
-import { ElementWithTransition, vtcKey } from '../components/Transition'
+import { type ElementWithTransition, vtcKey } from '../components/Transition'
 
 // compiler should normalize class + :class bindings on the same element
 // into a single binding ['staticClass', dynamic]
index 884c55c92322b965982d0dd3eb77ec53e1f404ab..0335b6be0dbc8b9770be43142cc2f2bc62e51d48 100644 (file)
@@ -1,8 +1,8 @@
 import { hyphenate, isArray } from '@vue/shared'
 import {
+  type ComponentInternalInstance,
   ErrorCodes,
-  ComponentInternalInstance,
-  callWithAsyncErrorHandling
+  callWithAsyncErrorHandling,
 } from '@vue/runtime-core'
 
 interface Invoker extends EventListener {
@@ -16,7 +16,7 @@ export function addEventListener(
   el: Element,
   event: string,
   handler: EventListener,
-  options?: EventListenerOptions
+  options?: EventListenerOptions,
 ) {
   el.addEventListener(event, handler, options)
 }
@@ -25,7 +25,7 @@ export function removeEventListener(
   el: Element,
   event: string,
   handler: EventListener,
-  options?: EventListenerOptions
+  options?: EventListenerOptions,
 ) {
   el.removeEventListener(event, handler, options)
 }
@@ -37,7 +37,7 @@ export function patchEvent(
   rawName: string,
   prevValue: EventValue | null,
   nextValue: EventValue | null,
-  instance: ComponentInternalInstance | null = null
+  instance: ComponentInternalInstance | null = null,
 ) {
   // vei = vue event invokers
   const invokers = el[veiKey] || (el[veiKey] = {})
@@ -84,7 +84,7 @@ const getNow = () =>
 
 function createInvoker(
   initialValue: EventValue,
-  instance: ComponentInternalInstance | null
+  instance: ComponentInternalInstance | null,
 ) {
   const invoker: Invoker = (e: Event & { _vts?: number }) => {
     // async edge case vuejs/vue#6566
@@ -108,7 +108,7 @@ function createInvoker(
       patchStopImmediatePropagation(e, invoker.value),
       instance,
       ErrorCodes.NATIVE_EVENT_HANDLER,
-      [e]
+      [e],
     )
   }
   invoker.value = initialValue
@@ -118,7 +118,7 @@ function createInvoker(
 
 function patchStopImmediatePropagation(
   e: Event,
-  value: EventValue
+  value: EventValue,
 ): EventValue {
   if (isArray(value)) {
     const originalStop = e.stopImmediatePropagation
index cdf9d84cf5d72f024b82dba85431cfe2bd974d03..3c09a1279410e6260e694645ec9ed279dad4c8f1 100644 (file)
@@ -2,7 +2,7 @@
 // Reason: potentially setting innerHTML.
 // This can come from explicit usage of v-html or innerHTML as a prop in render
 
-import { warn, DeprecationTypes, compatUtils } from '@vue/runtime-core'
+import { DeprecationTypes, compatUtils, warn } from '@vue/runtime-core'
 import { includeBooleanAttr } from '@vue/shared'
 
 // functions. The user is responsible for using them with only trusted content.
@@ -16,7 +16,7 @@ export function patchDOMProp(
   prevChildren: any,
   parentComponent: any,
   parentSuspense: any,
-  unmountChildren: any
+  unmountChildren: any,
 ) {
   if (key === 'innerHTML' || key === 'textContent') {
     if (prevChildren) {
@@ -71,7 +71,7 @@ export function patchDOMProp(
       value === false &&
       compatUtils.isCompatEnabled(
         DeprecationTypes.ATTR_FALSE_VALUE,
-        parentComponent
+        parentComponent,
       )
     ) {
       const type = typeof el[key]
@@ -80,7 +80,7 @@ export function patchDOMProp(
           compatUtils.warnDeprecation(
             DeprecationTypes.ATTR_FALSE_VALUE,
             parentComponent,
-            key
+            key,
           )
         value = type === 'number' ? 0 : ''
         needRemove = true
@@ -99,7 +99,7 @@ export function patchDOMProp(
       warn(
         `Failed setting prop "${key}" on <${tag.toLowerCase()}>: ` +
           `value ${value} is invalid.`,
-        e
+        e,
       )
     }
   }
index cb4ee7772512fff94f6e8ccae583f7ecb1998b8a..ce112ab87ed57c7ad26a5e40a0f1a5925bf9d8ef 100644 (file)
@@ -1,4 +1,4 @@
-import { isString, hyphenate, capitalize, isArray } from '@vue/shared'
+import { capitalize, hyphenate, isArray, isString } from '@vue/shared'
 import { camelize, warn } from '@vue/runtime-core'
 import { vShowOldKey } from '../directives/vShow'
 import { CSS_VAR_TEXT } from '../helpers/useCssVars'
@@ -48,7 +48,7 @@ const importantRE = /\s*!important$/
 function setStyle(
   style: CSSStyleDeclaration,
   name: string,
-  val: string | string[]
+  val: string | string[],
 ) {
   if (isArray(val)) {
     val.forEach(v => setStyle(style, name, v))
@@ -57,7 +57,7 @@ function setStyle(
     if (__DEV__) {
       if (semicolonRE.test(val)) {
         warn(
-          `Unexpected semicolon at the end of '${name}' style value: '${val}'`
+          `Unexpected semicolon at the end of '${name}' style value: '${val}'`,
         )
       }
     }
@@ -71,7 +71,7 @@ function setStyle(
         style.setProperty(
           hyphenate(prefixed),
           val.replace(importantRE, ''),
-          'important'
+          'important',
         )
       } else {
         style[prefixed as any] = val
index b9595536d002b23d3762c8b9d20d4e6a31e95622..a318000aa915e36149734e016ff1b0926f12c4ec 100644 (file)
@@ -1,4 +1,4 @@
-import { RendererOptions } from '@vue/runtime-core'
+import type { RendererOptions } from '@vue/runtime-core'
 
 export const svgNS = 'http://www.w3.org/2000/svg'
 export const mathmlNS = 'http://www.w3.org/1998/Math/MathML'
@@ -96,7 +96,7 @@ export const nodeOps: Omit<RendererOptions<Node, Element>, 'patchProp'> = {
       // first
       before ? before.nextSibling! : parent.firstChild!,
       // last
-      anchor ? anchor.previousSibling! : parent.lastChild!
+      anchor ? anchor.previousSibling! : parent.lastChild!,
     ]
-  }
+  },
 }
index 4197de2f69d643fa6645a01fa8a5e35a227926f4..ef0197ed23c63c0ffa9955c4a80f2848434ee89e 100644 (file)
@@ -3,8 +3,8 @@ import { patchStyle } from './modules/style'
 import { patchAttr } from './modules/attrs'
 import { patchDOMProp } from './modules/props'
 import { patchEvent } from './modules/events'
-import { isOn, isString, isFunction, isModelListener } from '@vue/shared'
-import { RendererOptions } from '@vue/runtime-core'
+import { isFunction, isModelListener, isOn, isString } from '@vue/shared'
+import type { RendererOptions } from '@vue/runtime-core'
 
 const isNativeOn = (key: string) =>
   key.charCodeAt(0) === 111 /* o */ &&
@@ -24,7 +24,7 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
   prevChildren,
   parentComponent,
   parentSuspense,
-  unmountChildren
+  unmountChildren,
 ) => {
   const isSVG = namespace === 'svg'
   if (key === 'class') {
@@ -50,7 +50,7 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
       prevChildren,
       parentComponent,
       parentSuspense,
-      unmountChildren
+      unmountChildren,
     )
   } else {
     // special case for <input v-model type="checkbox"> with
@@ -70,7 +70,7 @@ function shouldSetAsProp(
   el: Element,
   key: string,
   value: unknown,
-  isSVG: boolean
+  isSVG: boolean,
 ) {
   if (isSVG) {
     // most keys must be set as attribute on svg elements to work
index b148e72a48b3c5020b98398dc659be0dd341ab82..2b6e12c4769dcd52d6bb6fc10529dd23d4836a5e 100644 (file)
@@ -1,18 +1,18 @@
 import {
+  NodeOpTypes,
+  type TestElement,
+  TestNodeTypes,
+  type TestText,
+  dumpOps,
   h,
-  render,
+  nextTick,
   nodeOps,
-  TestNodeTypes,
-  TestElement,
-  TestText,
-  ref,
   reactive,
-  dumpOps,
+  ref,
+  render,
   resetOps,
-  NodeOpTypes,
-  nextTick,
   serialize,
-  triggerEvent
+  triggerEvent,
 } from '../src'
 
 describe('test renderer', () => {
@@ -22,11 +22,11 @@ describe('test renderer', () => {
       h(
         'div',
         {
-          id: 'test'
+          id: 'test',
         },
-        'hello'
+        'hello',
       ),
-      root
+      root,
     )
 
     expect(root.children.length).toBe(1)
@@ -44,7 +44,7 @@ describe('test renderer', () => {
   it('should record ops', async () => {
     const state = reactive({
       id: 'test',
-      text: 'hello'
+      text: 'hello',
     })
 
     const App = {
@@ -52,11 +52,11 @@ describe('test renderer', () => {
         return h(
           'div',
           {
-            id: state.id
+            id: state.id,
           },
-          state.text
+          state.text,
         )
-      }
+      },
     }
     const root = nodeOps.createElement('div')
 
@@ -70,13 +70,13 @@ describe('test renderer', () => {
       type: NodeOpTypes.CREATE,
       nodeType: TestNodeTypes.ELEMENT,
       tag: 'div',
-      targetNode: root.children[0]
+      targetNode: root.children[0],
     })
 
     expect(ops[1]).toEqual({
       type: NodeOpTypes.SET_ELEMENT_TEXT,
       text: 'hello',
-      targetNode: root.children[0]
+      targetNode: root.children[0],
     })
 
     expect(ops[2]).toEqual({
@@ -84,14 +84,14 @@ describe('test renderer', () => {
       targetNode: root.children[0],
       propKey: 'id',
       propPrevValue: null,
-      propNextValue: 'test'
+      propNextValue: 'test',
     })
 
     expect(ops[3]).toEqual({
       type: NodeOpTypes.INSERT,
       targetNode: root.children[0],
       parentNode: root,
-      refNode: null
+      refNode: null,
     })
 
     // test update ops
@@ -105,7 +105,7 @@ describe('test renderer', () => {
     expect(updateOps[0]).toEqual({
       type: NodeOpTypes.SET_ELEMENT_TEXT,
       targetNode: root.children[0],
-      text: 'bar'
+      text: 'bar',
     })
 
     expect(updateOps[1]).toEqual({
@@ -113,7 +113,7 @@ describe('test renderer', () => {
       targetNode: root.children[0],
       propKey: 'id',
       propPrevValue: 'test',
-      propNextValue: 'foo'
+      propNextValue: 'foo',
     })
   })
 
@@ -124,16 +124,16 @@ describe('test renderer', () => {
           'div',
           {
             id: 'test',
-            boolean: ''
+            boolean: '',
           },
-          [h('span', 'foo'), 'hello']
+          [h('span', 'foo'), 'hello'],
         )
-      }
+      },
     }
     const root = nodeOps.createElement('div')
     render(h(App), root)
     expect(serialize(root)).toEqual(
-      `<div><div id="test" boolean><span>foo</span>hello</div></div>`
+      `<div><div id="test" boolean><span>foo</span>hello</div></div>`,
     )
     // indented output
     expect(serialize(root, 2)).toEqual(
@@ -144,7 +144,7 @@ describe('test renderer', () => {
     </span>
     hello
   </div>
-</div>`
+</div>`,
     )
   })
 
@@ -157,9 +157,9 @@ describe('test renderer', () => {
         {
           onClick: () => {
             count.value++
-          }
+          },
         },
-        count.value
+        count.value,
       )
     }
 
@@ -185,10 +185,10 @@ describe('test renderer', () => {
             },
             () => {
               count2.value++
-            }
-          ]
+            },
+          ],
         },
-        `${count.value}, ${count2.value}`
+        `${count.value}, ${count2.value}`,
       )
     }
 
index e90d611928e5bf893488f98b5b1bcf9bf7b5a56d..ba11f60c2c1d067d05770a2877a510af009f6e4a 100644 (file)
@@ -1,16 +1,16 @@
 import {
+  type CreateAppFunction,
+  type RootRenderFunction,
+  type VNode,
   createRenderer,
-  VNode,
-  RootRenderFunction,
-  CreateAppFunction
 } from '@vue/runtime-core'
-import { nodeOps, TestElement } from './nodeOps'
+import { type TestElement, nodeOps } from './nodeOps'
 import { patchProp } from './patchProp'
 import { serializeInner } from './serialize'
 import { extend } from '@vue/shared'
 
 const { render: baseRender, createApp: baseCreateApp } = createRenderer(
-  extend({ patchProp }, nodeOps)
+  extend({ patchProp }, nodeOps),
 )
 
 export const render = baseRender as RootRenderFunction<TestElement>
index e45dda1a06f49ad9cd27d0452985cc03ceb2bae1..e338fd52000e2250828c664526ef6b9e449a0a1f 100644 (file)
@@ -3,7 +3,7 @@ import { markRaw } from '@vue/reactivity'
 export enum TestNodeTypes {
   TEXT = 'text',
   ELEMENT = 'element',
-  COMMENT = 'comment'
+  COMMENT = 'comment',
 }
 
 export enum NodeOpTypes {
@@ -12,7 +12,7 @@ export enum NodeOpTypes {
   REMOVE = 'remove',
   SET_TEXT = 'setText',
   SET_ELEMENT_TEXT = 'setElementText',
-  PATCH = 'patch'
+  PATCH = 'patch',
 }
 
 export interface TestElement {
@@ -79,13 +79,13 @@ function createElement(tag: string): TestElement {
     children: [],
     props: {},
     parentNode: null,
-    eventListeners: null
+    eventListeners: null,
   }
   logNodeOp({
     type: NodeOpTypes.CREATE,
     nodeType: TestNodeTypes.ELEMENT,
     targetNode: node,
-    tag
+    tag,
   })
   // avoid test nodes from being observed
   markRaw(node)
@@ -97,13 +97,13 @@ function createText(text: string): TestText {
     id: nodeId++,
     type: TestNodeTypes.TEXT,
     text,
-    parentNode: null
+    parentNode: null,
   }
   logNodeOp({
     type: NodeOpTypes.CREATE,
     nodeType: TestNodeTypes.TEXT,
     targetNode: node,
-    text
+    text,
   })
   // avoid test nodes from being observed
   markRaw(node)
@@ -115,13 +115,13 @@ function createComment(text: string): TestComment {
     id: nodeId++,
     type: TestNodeTypes.COMMENT,
     text,
-    parentNode: null
+    parentNode: null,
   }
   logNodeOp({
     type: NodeOpTypes.CREATE,
     nodeType: TestNodeTypes.COMMENT,
     targetNode: node,
-    text
+    text,
   })
   // avoid test nodes from being observed
   markRaw(node)
@@ -132,7 +132,7 @@ function setText(node: TestText, text: string) {
   logNodeOp({
     type: NodeOpTypes.SET_TEXT,
     targetNode: node,
-    text
+    text,
   })
   node.text = text
 }
@@ -151,7 +151,7 @@ function insert(child: TestNode, parent: TestElement, ref?: TestNode | null) {
     type: NodeOpTypes.INSERT,
     targetNode: child,
     parentNode: parent,
-    refNode: ref
+    refNode: ref,
   })
   // remove the node first, but don't log it as a REMOVE op
   remove(child, false)
@@ -173,7 +173,7 @@ function remove(child: TestNode, logOp = true) {
       logNodeOp({
         type: NodeOpTypes.REMOVE,
         targetNode: child,
-        parentNode: parent
+        parentNode: parent,
       })
     }
     const i = parent.children.indexOf(child)
@@ -192,7 +192,7 @@ function setElementText(el: TestElement, text: string) {
   logNodeOp({
     type: NodeOpTypes.SET_ELEMENT_TEXT,
     targetNode: el,
-    text
+    text,
   })
   el.children.forEach(c => {
     c.parentNode = null
@@ -205,8 +205,8 @@ function setElementText(el: TestElement, text: string) {
         id: nodeId++,
         type: TestNodeTypes.TEXT,
         text,
-        parentNode: el
-      }
+        parentNode: el,
+      },
     ]
   }
 }
@@ -243,5 +243,5 @@ export const nodeOps = {
   parentNode,
   nextSibling,
   querySelector,
-  setScopeId
+  setScopeId,
 }
index 3ebc64d1b0472ef1824b388692061e555bb51059..f10b5364746ae18b9baf60b540dfe453e92ffdc3 100644 (file)
@@ -1,18 +1,18 @@
-import { TestElement, logNodeOp, NodeOpTypes } from './nodeOps'
+import { NodeOpTypes, type TestElement, logNodeOp } from './nodeOps'
 import { isOn } from '@vue/shared'
 
 export function patchProp(
   el: TestElement,
   key: string,
   prevValue: any,
-  nextValue: any
+  nextValue: any,
 ) {
   logNodeOp({
     type: NodeOpTypes.PATCH,
     targetNode: el,
     propKey: key,
     propPrevValue: prevValue,
-    propNextValue: nextValue
+    propNextValue: nextValue,
   })
   el.props[key] = nextValue
   if (isOn(key)) {
index 8b16c9993b036c45f1c492151cc363242251f981..e8871945be121cfe7c70a9a83d23d95e8553fba8 100644 (file)
@@ -1,16 +1,16 @@
 import {
-  TestElement,
-  TestNode,
+  type TestComment,
+  type TestElement,
+  type TestNode,
   TestNodeTypes,
-  TestText,
-  TestComment
+  type TestText,
 } from './nodeOps'
 import { isOn } from '@vue/shared'
 
 export function serialize(
   node: TestNode,
   indent: number = 0,
-  depth: number = 0
+  depth: number = 0,
 ): string {
   if (node.type === TestNodeTypes.ELEMENT) {
     return serializeElement(node, indent, depth)
@@ -22,7 +22,7 @@ export function serialize(
 export function serializeInner(
   node: TestElement,
   indent: number = 0,
-  depth: number = 0
+  depth: number = 0,
 ) {
   const newLine = indent ? `\n` : ``
   return node.children.length
@@ -35,7 +35,7 @@ export function serializeInner(
 function serializeElement(
   node: TestElement,
   indent: number,
-  depth: number
+  depth: number,
 ): string {
   const props = Object.keys(node.props)
     .map(key => {
@@ -59,7 +59,7 @@ function serializeElement(
 function serializeText(
   node: TestText | TestComment,
   indent: number,
-  depth: number
+  depth: number,
 ): string {
   const padding = indent ? ` `.repeat(indent).repeat(depth) : ``
   return (
index 89ee71f208fcd06c0a44aa47b44570bcc6f70dd6..94ccd2badcd991442cde7f34f44dac1875057776 100644 (file)
@@ -1,10 +1,10 @@
 import { isArray } from '@vue/shared'
-import { TestElement } from './nodeOps'
+import type { TestElement } from './nodeOps'
 
 export function triggerEvent(
   el: TestElement,
   event: string,
-  payload: any[] = []
+  payload: any[] = [],
 ) {
   const { eventListeners } = el
   if (eventListeners) {
index 1899c76708584359e4b9569f92945227e6940c94..705cb2a8b6f31bc78c03a2a36a715a52e21e5b3b 100644 (file)
@@ -1,33 +1,33 @@
 import {
+  type ComponentOptions,
+  KeepAlive,
+  Transition,
+  computed,
   createApp,
-  h,
   createCommentVNode,
-  resolveComponent,
-  ComponentOptions,
-  ref,
-  defineComponent,
-  createTextVNode,
+  createSSRApp,
   createStaticVNode,
-  withCtx,
-  KeepAlive,
-  Transition,
-  watchEffect,
+  createTextVNode,
   createVNode,
-  resolveDynamicComponent,
-  renderSlot,
+  defineComponent,
+  getCurrentInstance,
+  h,
   onErrorCaptured,
   onServerPrefetch,
-  getCurrentInstance,
   reactive,
-  computed,
-  createSSRApp
+  ref,
+  renderSlot,
+  resolveComponent,
+  resolveDynamicComponent,
+  watchEffect,
+  withCtx,
 } from 'vue'
 import { escapeHtml } from '@vue/shared'
 import { renderToString } from '../src/renderToString'
-import { renderToNodeStream, pipeToNodeWritable } from '../src/renderToStream'
-import { ssrRenderSlot, SSRSlot } from '../src/helpers/ssrRenderSlot'
+import { pipeToNodeWritable, renderToNodeStream } from '../src/renderToStream'
+import { type SSRSlot, ssrRenderSlot } from '../src/helpers/ssrRenderSlot'
 import { ssrRenderComponent } from '../src/helpers/ssrRenderComponent'
-import { Readable, Transform } from 'stream'
+import { type Readable, Transform } from 'node:stream'
 import { ssrRenderVNode } from '../src'
 
 const promisifyStream = (stream: Readable) => {
@@ -54,7 +54,7 @@ const pipeToWritable = (app: any, context?: any) => {
     transform(data, _encoding, cb) {
       this.push(data)
       cb()
-    }
+    },
   })
   pipeToNodeWritable(app, context, stream)
   return promisifyStream(stream)
@@ -72,10 +72,10 @@ function testRender(type: string, render: typeof renderToString) {
         render() {
           const Foo = resolveComponent('foo') as ComponentOptions
           return h(Foo)
-        }
+        },
       })
       app.component('foo', {
-        render: () => h('div', 'foo')
+        render: () => h('div', 'foo'),
       })
       const html = await render(app)
       expect(html).toBe(`<div>foo</div>`)
@@ -91,9 +91,9 @@ function testRender(type: string, render: typeof renderToString) {
               },
               render(this: any) {
                 return h('div', this.msg)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
@@ -104,9 +104,9 @@ function testRender(type: string, render: typeof renderToString) {
               setup() {
                 const msg = ref('hello')
                 return () => h('div', msg.value)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
@@ -117,9 +117,9 @@ function testRender(type: string, render: typeof renderToString) {
               defineComponent(() => {
                 const msg = ref('hello')
                 return () => h('div', msg.value)
-              })
-            )
-          )
+              }),
+            ),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
@@ -134,11 +134,11 @@ function testRender(type: string, render: typeof renderToString) {
                   },
                   render() {
                     return h('div', this.msg)
-                  }
-                })
-              })
-            )
-          )
+                  },
+                }),
+              }),
+            ),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
@@ -154,12 +154,12 @@ function testRender(type: string, render: typeof renderToString) {
                     },
                     render() {
                       return h('div', this.msg)
-                    }
-                  })
-                ]
-              })
-            )
-          )
+                    },
+                  }),
+                ],
+              }),
+            ),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
@@ -172,9 +172,9 @@ function testRender(type: string, render: typeof renderToString) {
               },
               ssrRender(ctx, push) {
                 push(`<div>${ctx.msg}</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
@@ -183,7 +183,7 @@ function testRender(type: string, render: typeof renderToString) {
           props: ['msg'],
           render(this: any) {
             return h('div', this.msg)
-          }
+          },
         }
 
         expect(
@@ -191,9 +191,9 @@ function testRender(type: string, render: typeof renderToString) {
             createApp({
               render() {
                 return h('div', ['parent', h(Child, { msg: 'hello' })])
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>parent<div>hello</div></div>`)
       })
 
@@ -202,7 +202,7 @@ function testRender(type: string, render: typeof renderToString) {
           props: ['msg'],
           ssrRender(ctx: any, push: any) {
             push(`<div>${ctx.msg}</div>`)
-          }
+          },
         }
 
         expect(
@@ -212,19 +212,19 @@ function testRender(type: string, render: typeof renderToString) {
                 push(`<div>parent`)
                 push(ssrRenderComponent(Child, { msg: 'hello' }, null, parent))
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>parent<div>hello</div></div>`)
       })
 
       test('nested template components', async () => {
         const Child = {
           props: ['msg'],
-          template: `<div>{{ msg }}</div>`
+          template: `<div>{{ msg }}</div>`,
         }
         const app = createApp({
-          template: `<div>parent<Child msg="hello" /></div>`
+          template: `<div>parent<Child msg="hello" /></div>`,
         })
         app.component('Child', Child)
 
@@ -233,19 +233,19 @@ function testRender(type: string, render: typeof renderToString) {
 
       test('template components with dynamic class attribute after static', async () => {
         const app = createApp({
-          template: `<div><div class="child" :class="'dynamic'"></div></div>`
+          template: `<div><div class="child" :class="'dynamic'"></div></div>`,
         })
         expect(await render(app)).toBe(
-          `<div><div class="dynamic child"></div></div>`
+          `<div><div class="dynamic child"></div></div>`,
         )
       })
 
       test('template components with dynamic class attribute before static', async () => {
         const app = createApp({
-          template: `<div><div :class="'dynamic'" class="child"></div></div>`
+          template: `<div><div :class="'dynamic'" class="child"></div></div>`,
         })
         expect(await render(app)).toBe(
-          `<div><div class="dynamic child"></div></div>`
+          `<div><div class="dynamic child"></div></div>`,
         )
       })
 
@@ -254,19 +254,19 @@ function testRender(type: string, render: typeof renderToString) {
           props: ['msg'],
           ssrRender(ctx: any, push: any) {
             push(`<div>${ctx.msg}</div>`)
-          }
+          },
         }
 
         const VNodeChild = {
           props: ['msg'],
           render(this: any) {
             return h('div', this.msg)
-          }
+          },
         }
 
         const TemplateChild = {
           props: ['msg'],
-          template: `<div>{{ msg }}</div>`
+          template: `<div>{{ msg }}</div>`,
         }
 
         expect(
@@ -279,26 +279,31 @@ function testRender(type: string, render: typeof renderToString) {
                     OptimizedChild,
                     { msg: 'opt' },
                     null,
-                    parent
-                  )
+                    parent,
+                  ),
                 )
                 push(
-                  ssrRenderComponent(VNodeChild, { msg: 'vnode' }, null, parent)
+                  ssrRenderComponent(
+                    VNodeChild,
+                    { msg: 'vnode' },
+                    null,
+                    parent,
+                  ),
                 )
                 push(
                   ssrRenderComponent(
                     TemplateChild,
                     { msg: 'template' },
                     null,
-                    parent
-                  )
+                    parent,
+                  ),
                 )
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(
-          `<div>parent<div>opt</div><div>vnode</div><div>template</div></div>`
+          `<div>parent<div>opt</div><div>vnode</div><div>template</div></div>`,
         )
       })
 
@@ -307,12 +312,12 @@ function testRender(type: string, render: typeof renderToString) {
           // should wait for resolved render context from setup()
           async setup() {
             return {
-              msg: 'hello'
+              msg: 'hello',
             }
           },
           ssrRender(ctx: any, push: any) {
             push(`<div>${ctx.msg}</div>`)
-          }
+          },
         }
 
         expect(
@@ -322,9 +327,9 @@ function testRender(type: string, render: typeof renderToString) {
                 push(`<div>parent`)
                 push(ssrRenderComponent(Child, null, null, parent))
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>parent<div>hello</div></div>`)
       })
 
@@ -333,24 +338,24 @@ function testRender(type: string, render: typeof renderToString) {
           props: ['msg'],
           async setup(props: any) {
             return {
-              localMsg: props.msg + '!'
+              localMsg: props.msg + '!',
             }
           },
           ssrRender(ctx: any, push: any) {
             push(`<div>${ctx.localMsg}</div>`)
-          }
+          },
         }
 
         const VNodeChild = {
           props: ['msg'],
           async setup(props: any) {
             return {
-              localMsg: props.msg + '!'
+              localMsg: props.msg + '!',
             }
           },
           render(this: any) {
             return h('div', this.localMsg)
-          }
+          },
         }
 
         expect(
@@ -363,16 +368,21 @@ function testRender(type: string, render: typeof renderToString) {
                     OptimizedChild,
                     { msg: 'opt' },
                     null,
-                    parent
-                  )
+                    parent,
+                  ),
                 )
                 push(
-                  ssrRenderComponent(VNodeChild, { msg: 'vnode' }, null, parent)
+                  ssrRenderComponent(
+                    VNodeChild,
+                    { msg: 'vnode' },
+                    null,
+                    parent,
+                  ),
                 )
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(`<div>parent<div>opt!</div><div>vnode!</div></div>`)
       })
     })
@@ -391,10 +401,10 @@ function testRender(type: string, render: typeof renderToString) {
                 push(`fallback`)
               },
               push,
-              parent
+              parent,
             )
             push(`</div>`)
-          }
+          },
         }
 
         expect(
@@ -412,19 +422,19 @@ function testRender(type: string, render: typeof renderToString) {
                         push(`<span>${msg}</span>`)
                       }) as SSRSlot,
                       // important to avoid slots being normalized
-                      _: 1 as any
+                      _: 1 as any,
                     },
-                    parent
-                  )
+                    parent,
+                  ),
                 )
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(
           `<div>parent<div class="child">` +
             `<!--[--><span>from slot</span><!--]-->` +
-            `</div></div>`
+            `</div></div>`,
         )
 
         // test fallback
@@ -435,11 +445,11 @@ function testRender(type: string, render: typeof renderToString) {
                 push(`<div>parent`)
                 push(ssrRenderComponent(Child, { msg: 'hello' }, null, parent))
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(
-          `<div>parent<div class="child"><!--[-->fallback<!--]--></div></div>`
+          `<div>parent<div class="child"><!--[-->fallback<!--]--></div></div>`,
         )
       })
 
@@ -454,10 +464,10 @@ function testRender(type: string, render: typeof renderToString) {
               { msg: 'from slot' },
               null,
               push,
-              parent
+              parent,
             )
             push(`</div>`)
-          }
+          },
         }
 
         expect(
@@ -473,37 +483,37 @@ function testRender(type: string, render: typeof renderToString) {
                       // bailed slots returning raw vnodes
                       default: ({ msg }: any) => {
                         return h('span', msg)
-                      }
+                      },
                     },
-                    parent
-                  )
+                    parent,
+                  ),
                 )
                 push(`</div>`)
-              }
-            })
-          )
+              },
+            }),
+          ),
         ).toBe(
           `<div>parent<div class="child">` +
             `<!--[--><span>from slot</span><!--]-->` +
-            `</div></div>`
+            `</div></div>`,
         )
       })
 
       test('nested components with template slots', async () => {
         const Child = {
           props: ['msg'],
-          template: `<div class="child"><slot msg="from slot"></slot></div>`
+          template: `<div class="child"><slot msg="from slot"></slot></div>`,
         }
 
         const app = createApp({
           components: { Child },
-          template: `<div>parent<Child v-slot="{ msg }"><span>{{ msg }}</span></Child></div>`
+          template: `<div>parent<Child v-slot="{ msg }"><span>{{ msg }}</span></Child></div>`,
         })
 
         expect(await render(app)).toBe(
           `<div>parent<div class="child">` +
             `<!--[--><span>from slot</span><!--]-->` +
-            `</div></div>`
+            `</div></div>`,
         )
       })
 
@@ -514,15 +524,15 @@ function testRender(type: string, render: typeof renderToString) {
             return h(
               'div',
               {
-                class: 'child'
+                class: 'child',
               },
-              this.$slots.default({ msg: 'from slot' })
+              this.$slots.default({ msg: 'from slot' }),
             )
-          }
+          },
         }
 
         const app = createApp({
-          template: `<div>parent<Child v-slot="{ msg }"><span>{{ msg }}</span></Child></div>`
+          template: `<div>parent<Child v-slot="{ msg }"><span>{{ msg }}</span></Child></div>`,
         })
         app.component('Child', Child)
 
@@ -530,69 +540,69 @@ function testRender(type: string, render: typeof renderToString) {
           `<div>parent<div class="child">` +
             // no comment anchors because slot is used directly as element children
             `<span>from slot</span>` +
-            `</div></div>`
+            `</div></div>`,
         )
       })
 
       test('template slots forwarding', async () => {
         const Child = {
-          template: `<div><slot/></div>`
+          template: `<div><slot/></div>`,
         }
 
         const Parent = {
           components: { Child },
-          template: `<Child><slot/></Child>`
+          template: `<Child><slot/></Child>`,
         }
 
         const app = createApp({
           components: { Parent },
-          template: `<Parent>hello</Parent>`
+          template: `<Parent>hello</Parent>`,
         })
 
         expect(await render(app)).toBe(
-          `<div><!--[--><!--[-->hello<!--]--><!--]--></div>`
+          `<div><!--[--><!--[-->hello<!--]--><!--]--></div>`,
         )
       })
 
       test('template slots forwarding, empty slot', async () => {
         const Child = {
-          template: `<div><slot/></div>`
+          template: `<div><slot/></div>`,
         }
 
         const Parent = {
           components: { Child },
-          template: `<Child><slot/></Child>`
+          template: `<Child><slot/></Child>`,
         }
 
         const app = createApp({
           components: { Parent },
-          template: `<Parent></Parent>`
+          template: `<Parent></Parent>`,
         })
 
         expect(await render(app)).toBe(
           // should only have a single fragment
-          `<div><!--[--><!--]--></div>`
+          `<div><!--[--><!--]--></div>`,
         )
       })
 
       test('template slots forwarding, empty slot w/ fallback', async () => {
         const Child = {
-          template: `<div><slot>fallback</slot></div>`
+          template: `<div><slot>fallback</slot></div>`,
         }
 
         const Parent = {
           components: { Child },
-          template: `<Child><slot/></Child>`
+          template: `<Child><slot/></Child>`,
         }
 
         const app = createApp({
           components: { Parent },
-          template: `<Parent></Parent>`
+          template: `<Parent></Parent>`,
         })
 
         expect(await render(app)).toBe(
           // should only have a single fragment
-          `<div><!--[-->fallback<!--]--></div>`
+          `<div><!--[-->fallback<!--]--></div>`,
         )
       })
     })
@@ -600,7 +610,9 @@ function testRender(type: string, render: typeof renderToString) {
     describe('vnode element', () => {
       test('props', async () => {
         expect(
-          await render(h('div', { id: 'foo&', class: ['bar', 'baz'] }, 'hello'))
+          await render(
+            h('div', { id: 'foo&', class: ['bar', 'baz'] }, 'hello'),
+          ),
         ).toBe(`<div id="foo&amp;" class="bar baz">hello</div>`)
       })
 
@@ -615,11 +627,11 @@ function testRender(type: string, render: typeof renderToString) {
               'foo',
               h('span', 'bar'),
               [h('span', 'baz')],
-              createCommentVNode('qux')
-            ])
-          )
+              createCommentVNode('qux'),
+            ]),
+          ),
         ).toBe(
-          `<div>foo<span>bar</span><!--[--><span>baz</span><!--]--><!--qux--></div>`
+          `<div>foo<span>bar</span><!--[--><span>baz</span><!--]--><!--qux--></div>`,
         )
       })
 
@@ -633,11 +645,11 @@ function testRender(type: string, render: typeof renderToString) {
             h(
               'div',
               {
-                innerHTML: `<span>hello</span>`
+                innerHTML: `<span>hello</span>`,
               },
-              'ignored'
-            )
-          )
+              'ignored',
+            ),
+          ),
         ).toBe(`<div><span>hello</span></div>`)
       })
 
@@ -647,11 +659,11 @@ function testRender(type: string, render: typeof renderToString) {
             h(
               'div',
               {
-                textContent: `<span>hello</span>`
+                textContent: `<span>hello</span>`,
               },
-              'ignored'
-            )
-          )
+              'ignored',
+            ),
+          ),
         ).toBe(`<div>${escapeHtml(`<span>hello</span>`)}</div>`)
       })
 
@@ -661,11 +673,11 @@ function testRender(type: string, render: typeof renderToString) {
             h(
               'textarea',
               {
-                value: `<span>hello</span>`
+                value: `<span>hello</span>`,
               },
-              'ignored'
-            )
-          )
+              'ignored',
+            ),
+          ),
         ).toBe(`<textarea>${escapeHtml(`<span>hello</span>`)}</textarea>`)
       })
     })
@@ -673,17 +685,17 @@ function testRender(type: string, render: typeof renderToString) {
     describe('vnode component', () => {
       test('KeepAlive', async () => {
         const MyComp = {
-          render: () => h('p', 'hello')
+          render: () => h('p', 'hello'),
         }
         expect(await render(h(KeepAlive, () => h(MyComp)))).toBe(`<p>hello</p>`)
       })
 
       test('Transition', async () => {
         const MyComp = {
-          render: () => h('p', 'hello')
+          render: () => h('p', 'hello'),
         }
         expect(await render(h(Transition, () => h(MyComp)))).toBe(
-          `<p>hello</p>`
+          `<p>hello</p>`,
         )
       })
     })
@@ -691,7 +703,7 @@ function testRender(type: string, render: typeof renderToString) {
     describe('raw vnode types', () => {
       test('Text', async () => {
         expect(await render(createTextVNode('hello <div>'))).toBe(
-          `hello &lt;div&gt;`
+          `hello &lt;div&gt;`,
         )
       })
 
@@ -703,9 +715,9 @@ function testRender(type: string, render: typeof renderToString) {
               createCommentVNode('>foo'),
               createCommentVNode('->foo'),
               createCommentVNode('<!--foo-->'),
-              createCommentVNode('--!>foo<!-')
-            ])
-          )
+              createCommentVNode('--!>foo<!-'),
+            ]),
+          ),
         ).toBe(`<div><!--foo--><!--foo--><!--foo--><!--foo--></div>`)
       })
 
@@ -724,7 +736,7 @@ function testRender(type: string, render: typeof renderToString) {
           __scopeId: 'data-v-test',
           render() {
             return h('div')
-          }
+          },
         }
         expect(await render(h(Foo))).toBe(`<div data-v-test></div>`)
       })
@@ -734,22 +746,22 @@ function testRender(type: string, render: typeof renderToString) {
           __scopeId: 'data-v-child',
           render: function (this: any) {
             return h('div', null, [renderSlot(this.$slots, 'default')])
-          }
+          },
         }
 
         const Parent = {
           __scopeId: 'data-v-test',
           render: () => {
             return h(Child, null, {
-              default: withCtx(() => [h('span', 'slot')])
+              default: withCtx(() => [h('span', 'slot')]),
             })
-          }
+          },
         }
 
         expect(await render(h(Parent))).toBe(
           `<div data-v-child data-v-test>` +
             `<!--[--><span data-v-test data-v-child-s>slot</span><!--]-->` +
-            `</div>`
+            `</div>`,
         )
       })
     })
@@ -762,20 +774,20 @@ function testRender(type: string, render: typeof renderToString) {
               data() {
                 return { msg: 'hello' }
               },
-              template: `<div>{{ msg }}</div>`
-            })
-          )
+              template: `<div>{{ msg }}</div>`,
+            }),
+          ),
         ).toBe(`<div>hello</div>`)
       })
 
       test('handle compiler errors', async () => {
         await render(
           // render different content since compilation is cached
-          createApp({ template: `<div>${type}</` })
+          createApp({ template: `<div>${type}</` }),
         )
 
         expect(
-          `Template compilation error: Unexpected EOF in tag.`
+          `Template compilation error: Unexpected EOF in tag.`,
         ).toHaveBeenWarned()
         expect(`Element is missing end tag`).toHaveBeenWarned()
       })
@@ -790,8 +802,8 @@ function testRender(type: string, render: typeof renderToString) {
               data() {
                 return { msg: null }
               },
-              template: `<div>{{ msg.text }}</div>`
-            })
+              template: `<div>{{ msg.text }}</div>`,
+            }),
           )
         } catch {}
         expect(getCurrentInstance()).toBe(prev)
@@ -807,8 +819,8 @@ function testRender(type: string, render: typeof renderToString) {
               data() {
                 throw new Error()
               },
-              template: `<div>hello</div>`
-            })
+              template: `<div>hello</div>`,
+            }),
           )
         } catch {}
         expect(getCurrentInstance()).toBe(null)
@@ -824,7 +836,7 @@ function testRender(type: string, render: typeof renderToString) {
       const Child = {
         created() {
           throw new Error()
-        }
+        },
       }
       try {
         await render(
@@ -832,12 +844,12 @@ function testRender(type: string, render: typeof renderToString) {
             errorCaptured() {
               throw new Error()
             },
-            render: () => h(Child)
-          })
+            render: () => h(Child),
+          }),
         )
       } catch {}
       expect(
-        'Unhandled error during execution of errorCaptured hook'
+        'Unhandled error during execution of errorCaptured hook',
       ).toHaveBeenWarned()
       expect(getCurrentInstance()).toBe(null)
     })
@@ -847,7 +859,7 @@ function testRender(type: string, render: typeof renderToString) {
       const app = createApp({
         data() {
           return {
-            msg: ''
+            msg: '',
           }
         },
         async serverPrefetch() {
@@ -855,7 +867,7 @@ function testRender(type: string, render: typeof renderToString) {
         },
         render() {
           return h('div', this.msg)
-        }
+        },
       })
       const html = await render(app)
       expect(html).toBe(`<div>hello</div>`)
@@ -870,17 +882,17 @@ function testRender(type: string, render: typeof renderToString) {
         async setup() {
           return Promise.reject('async child error')
         },
-        template: `<div>asyncChildren</div>`
+        template: `<div>asyncChildren</div>`,
       })
       const app = createApp({
         name: 'App',
         components: {
-          asyncChildren
+          asyncChildren,
         },
         template: `<div class="app"><async-children /></div>`,
         errorCaptured(error) {
           fn(error)
-        }
+        },
       })
 
       app.config.errorHandler = error => {
@@ -904,7 +916,7 @@ function testRender(type: string, render: typeof renderToString) {
         setup: () => {
           watchEffect(onInvalidate => onInvalidate(noop))
         },
-        render: noop
+        render: noop,
       })
       expect(await render(app)).toBe('<!---->')
     })
@@ -918,11 +930,11 @@ function testRender(type: string, render: typeof renderToString) {
               A: {
                 ssrRender(_ctx, _push) {
                   _push(`<div>A</div>`)
-                }
+                },
               },
               B: {
-                render: () => h('div', 'B')
-              }
+                render: () => h('div', 'B'),
+              },
             },
             ssrRender(_ctx, _push, _parent) {
               const A: any = resolveComponent('A')
@@ -930,11 +942,11 @@ function testRender(type: string, render: typeof renderToString) {
               ssrRenderVNode(
                 _push,
                 createVNode(resolveDynamicComponent('B'), null, null),
-                _parent
+                _parent,
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<div>A</div><div>B</div>`)
     })
 
@@ -947,12 +959,12 @@ function testRender(type: string, render: typeof renderToString) {
             message.value = await msg
           })
           return {
-            message
+            message,
           }
         },
         render() {
           return h('div', this.message)
-        }
+        },
       })
       const html = await render(app)
       expect(html).toBe(`<div>hello</div>`)
@@ -979,12 +991,12 @@ function testRender(type: string, render: typeof renderToString) {
           return {
             message,
             message2,
-            message3
+            message3,
           }
         },
         render() {
           return h('div', `${this.message} ${this.message2} ${this.message3}`)
-        }
+        },
       })
       const html = await render(app)
       expect(html).toBe(`<div>hello hi bonjour</div>`)
@@ -1010,7 +1022,7 @@ function testRender(type: string, render: typeof renderToString) {
         },
         render() {
           return h('div', '')
-        }
+        },
       })
       await render(app)
       expect(first).toHaveBeenCalled()
@@ -1025,7 +1037,7 @@ function testRender(type: string, render: typeof renderToString) {
       const app = createApp({
         data() {
           return {
-            message: ''
+            message: '',
           }
         },
 
@@ -1039,12 +1051,12 @@ function testRender(type: string, render: typeof renderToString) {
             message2.value = await msg2
           })
           return {
-            message2
+            message2,
           }
         },
         render() {
           return h('div', `${this.message} ${this.message2}`)
-        }
+        },
       })
       const html = await render(app)
       expect(html).toBe(`<div>hello hi</div>`)
@@ -1055,19 +1067,19 @@ function testRender(type: string, render: typeof renderToString) {
       const app = createApp({
         data() {
           return {
-            msg: ''
+            msg: '',
           }
         },
         mixins: [
           {
             async serverPrefetch() {
               this.msg = await msg
-            }
-          }
+            },
+          },
         ],
         render() {
           return h('div', this.msg)
-        }
+        },
       })
       const html = await render(app)
       expect(html).toBe(`<div>hello</div>`)
@@ -1082,27 +1094,27 @@ function testRender(type: string, render: typeof renderToString) {
           return {
             foo: '',
             bar: '',
-            baz: ''
+            baz: '',
           }
         },
         mixins: [
           {
             async serverPrefetch() {
               this.foo = await foo
-            }
+            },
           },
           {
             async serverPrefetch() {
               this.bar = await bar
-            }
-          }
+            },
+          },
         ],
         async serverPrefetch() {
           this.baz = await baz
         },
         render() {
           return h('div', `${this.foo}${this.bar}${this.baz}`)
-        }
+        },
       })
       const html = await render(app)
       expect(html).toBe(`<div>foobarbaz</div>`)
@@ -1120,7 +1132,7 @@ function testRender(type: string, render: typeof renderToString) {
         },
         render() {
           return h('span')
-        }
+        },
       }
 
       const app = createApp({
@@ -1132,7 +1144,7 @@ function testRender(type: string, render: typeof renderToString) {
         },
         render() {
           return h('div', h(Child))
-        }
+        },
       })
 
       try {
@@ -1152,7 +1164,7 @@ function testRender(type: string, render: typeof renderToString) {
         // pretend to fetch some data from an api
         async fetchData() {
           this.state.items = ['hello', 'world']
-        }
+        },
       }
 
       const getterSpy = vi.fn()
index fb974f97923b9a7d9e5a36d92950208dbc6f38cc..e8cfa75e77c58e03435bf9452a4110bbb42199fd 100644 (file)
@@ -4,11 +4,11 @@ import { renderToString } from '../src/renderToString'
 describe('ssr: attr fallthrough', () => {
   test('basic', async () => {
     const Child = {
-      template: `<div class="foo" />`
+      template: `<div class="foo" />`,
     }
     const Parent = {
       components: { Child },
-      template: `<child class="bar"/>`
+      template: `<child class="bar"/>`,
     }
     const app = createApp(Parent)
     expect(await renderToString(app)).toBe(`<div class="foo bar"></div>`)
@@ -17,62 +17,62 @@ describe('ssr: attr fallthrough', () => {
   test('with v-if', async () => {
     const Child = {
       props: ['ok'],
-      template: `<div v-if="ok" class="foo" /><span v-else />`
+      template: `<div v-if="ok" class="foo" /><span v-else />`,
     }
     const Parent = {
       props: ['ok'],
       components: { Child },
-      template: `<child :ok="ok" class="bar"/>`
+      template: `<child :ok="ok" class="bar"/>`,
     }
     expect(await renderToString(createApp(Parent, { ok: true }))).toBe(
-      `<div class="foo bar"></div>`
+      `<div class="foo bar"></div>`,
     )
     expect(await renderToString(createApp(Parent, { ok: false }))).toBe(
-      `<span class="bar"></span>`
+      `<span class="bar"></span>`,
     )
   })
 
   test('with v-model', async () => {
     const Child = {
       props: ['text'],
-      template: `<input v-model="text">`
+      template: `<input v-model="text">`,
     }
     const Parent = {
       components: { Child },
-      template: `<child text="hello" class="bar"/>`
+      template: `<child text="hello" class="bar"/>`,
     }
     expect(await renderToString(createApp(Parent))).toBe(
-      `<input class="bar" value="hello">`
+      `<input class="bar" value="hello">`,
     )
   })
 
   test('with v-bind', async () => {
     const Child = {
       props: ['obj'],
-      template: `<div v-bind="obj" />`
+      template: `<div v-bind="obj" />`,
     }
     const Parent = {
       components: { Child },
-      template: `<child :obj="{ class: 'foo' }" class="bar"/>`
+      template: `<child :obj="{ class: 'foo' }" class="bar"/>`,
     }
     expect(await renderToString(createApp(Parent))).toBe(
-      `<div class="foo bar"></div>`
+      `<div class="foo bar"></div>`,
     )
   })
 
   test('nested fallthrough', async () => {
     const Child = {
       props: ['id'],
-      template: `<div :id="id"></div>`
+      template: `<div :id="id"></div>`,
     }
     const Parent = {
       components: { Child },
-      template: `<child id="foo" class="bar"/>`
+      template: `<child id="foo" class="bar"/>`,
     }
     // pass to parent, fallthrough to child and merge
     const app = createApp(Parent, { class: 'baz' })
     expect(await renderToString(app)).toBe(
-      `<div id="foo" class="bar baz"></div>`
+      `<div id="foo" class="bar baz"></div>`,
     )
   })
 })
index 34fcd4ef48b6e10f2362ec5e9750a85ae3a7ae2a..ce5f6233e3432d813829c12c12ae7c11224224ef 100644 (file)
@@ -4,7 +4,7 @@ import { renderToString } from '../src/renderToString'
 describe('ssr: compiler options', () => {
   test('config.isCustomElement (deprecated)', async () => {
     const app = createApp({
-      template: `<div><x-button/></div>`
+      template: `<div><x-button/></div>`,
     })
     app.config.isCustomElement = tag => tag.startsWith('x-')
     expect(await renderToString(app)).toBe(`<div><x-button></x-button></div>`)
@@ -12,7 +12,7 @@ describe('ssr: compiler options', () => {
 
   test('config.compilerOptions.isCustomElement', async () => {
     const app = createApp({
-      template: `<div><x-panel/></div>`
+      template: `<div><x-panel/></div>`,
     })
     app.config.compilerOptions.isCustomElement = tag => tag.startsWith('x-')
     expect(await renderToString(app)).toBe(`<div><x-panel></x-panel></div>`)
@@ -22,31 +22,31 @@ describe('ssr: compiler options', () => {
     const app = createApp({
       template: `<div><x-card/><y-child/></div>`,
       compilerOptions: {
-        isCustomElement: (tag: string) => tag.startsWith('x-')
+        isCustomElement: (tag: string) => tag.startsWith('x-'),
       },
       components: {
         YChild: {
-          template: `<div><y-button/></div>`
-        }
-      }
+          template: `<div><y-button/></div>`,
+        },
+      },
     })
     app.config.compilerOptions.isCustomElement = tag => tag.startsWith('y-')
     expect(await renderToString(app)).toBe(
-      `<div><x-card></x-card><div><y-button></y-button></div></div>`
+      `<div><x-card></x-card><div><y-button></y-button></div></div>`,
     )
   })
 
   test('component.delimiters (deprecated)', async () => {
     const app = createApp({
       template: `<div>[[ 1 + 1 ]]</div>`,
-      delimiters: ['[[', ']]']
+      delimiters: ['[[', ']]'],
     })
     expect(await renderToString(app)).toBe(`<div>2</div>`)
   })
 
   test('config.compilerOptions.delimiters', async () => {
     const app = createApp({
-      template: `<div>[( 1 + 1 )]</div>`
+      template: `<div>[( 1 + 1 )]</div>`,
     })
     app.config.compilerOptions.delimiters = ['[(', ')]']
     expect(await renderToString(app)).toBe(`<div>2</div>`)
@@ -56,13 +56,13 @@ describe('ssr: compiler options', () => {
     const app = createApp({
       template: `<div>[[ 1 + 1 ]]<ChildComponent/></div>`,
       compilerOptions: {
-        delimiters: ['[[', ']]']
+        delimiters: ['[[', ']]'],
       },
       components: {
         ChildComponent: {
-          template: `<div>(( 2 + 2 ))</div>`
-        }
-      }
+          template: `<div>(( 2 + 2 ))</div>`,
+        },
+      },
     })
     app.config.compilerOptions.delimiters = ['((', '))']
     expect(await renderToString(app)).toBe(`<div>2<div>4</div></div>`)
@@ -72,17 +72,17 @@ describe('ssr: compiler options', () => {
     const app = createApp({
       template: `<div><span>Hello   world</span><ChildComponent/></div>`,
       compilerOptions: {
-        whitespace: 'condense'
+        whitespace: 'condense',
       },
       components: {
         ChildComponent: {
-          template: `<span>Hello   world</span>`
-        }
-      }
+          template: `<span>Hello   world</span>`,
+        },
+      },
     })
     app.config.compilerOptions.whitespace = 'preserve'
     expect(await renderToString(app)).toBe(
-      `<div><span>Hello world</span><span>Hello   world</span></div>`
+      `<div><span>Hello world</span><span>Hello   world</span></div>`,
     )
   })
 
@@ -93,24 +93,24 @@ describe('ssr: compiler options', () => {
       template: `<div><ChildOne/><ChildTwo/><ChildThree/></div>`,
       components: {
         ChildOne: {
-          template
+          template,
         },
         ChildTwo: {
           template,
           compilerOptions: {
-            whitespace: 'preserve'
-          }
+            whitespace: 'preserve',
+          },
         },
         ChildThree: {
           template,
           compilerOptions: {
-            delimiters: ['[[', ']]']
-          }
-        }
-      }
+            delimiters: ['[[', ']]'],
+          },
+        },
+      },
     })
     expect(await renderToString(app)).toBe(
-      `<div><div>2 [[1 + 1]]</div><div>2   [[1 + 1]]</div><div>{{1 + 1}} 2</div></div>`
+      `<div><div>2 [[1 + 1]]</div><div>2   [[1 + 1]]</div><div>{{1 + 1}} 2</div></div>`,
     )
   })
 
@@ -124,21 +124,21 @@ describe('ssr: compiler options', () => {
         MyChild: {
           template,
           compilerOptions: {
-            isCustomElement: tag => tag.startsWith('x-')
+            isCustomElement: tag => tag.startsWith('x-'),
           },
           components: {
             MyChild: {
               template,
               compilerOptions: {
-                isCustomElement: tag => tag.startsWith('My')
-              }
-            }
-          }
-        }
-      }
+                isCustomElement: tag => tag.startsWith('My'),
+              },
+            },
+          },
+        },
+      },
     })
     expect(await renderToString(app)).toBe(
-      `<div><div><div><MyChild></MyChild></div></div></div>`
+      `<div><div><div><MyChild></MyChild></div></div></div>`,
     )
   })
 })
index 52b45a63636880c9086f0bc1b2346b8c6378de42..646fa83731c79f7283be82952312381b4b9111ad 100644 (file)
@@ -1,4 +1,4 @@
-import { createSSRApp, defineComponent, h, computed, reactive } from 'vue'
+import { computed, createSSRApp, defineComponent, h, reactive } from 'vue'
 import { renderToString } from '../src/renderToString'
 
 // #5208 reported memory leak of keeping computed alive during SSR
@@ -17,7 +17,7 @@ test('computed reactivity during SSR', async () => {
     // pretend to fetch some data from an api
     async fetchData() {
       this.state.items = ['hello', 'world']
-    }
+    },
   }
 
   const getterSpy = vi.fn()
index e52ef2db69f38d0366ae0478c55a890860bac139..d3ced89b3d2381113cd7a52893978c51465f5201 100644 (file)
@@ -2,13 +2,13 @@ import { renderToString } from '../src/renderToString'
 import {
   createApp,
   h,
-  withDirectives,
-  vShow,
-  vModelText,
-  vModelRadio,
+  resolveDirective,
   vModelCheckbox,
   vModelDynamic,
-  resolveDirective
+  vModelRadio,
+  vModelText,
+  vShow,
+  withDirectives,
 } from 'vue'
 import { ssrGetDirectiveProps, ssrRenderAttrs } from '../src'
 
@@ -18,17 +18,17 @@ describe('ssr: directives', () => {
       expect(
         await renderToString(
           createApp({
-            template: `<div v-show="true"/>`
-          })
-        )
+            template: `<div v-show="true"/>`,
+          }),
+        ),
       ).toBe(`<div style=""></div>`)
 
       expect(
         await renderToString(
           createApp({
-            template: `<div v-show="false"/>`
-          })
-        )
+            template: `<div v-show="false"/>`,
+          }),
+        ),
       ).toBe(`<div style="display:none;"></div>`)
     })
 
@@ -36,9 +36,9 @@ describe('ssr: directives', () => {
       expect(
         await renderToString(
           createApp({
-            template: `<div style="color:red" v-show="false"/>`
-          })
-        )
+            template: `<div style="color:red" v-show="false"/>`,
+          }),
+        ),
       ).toBe(`<div style="color:red;display:none;"></div>`)
     })
 
@@ -47,9 +47,9 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ style: { color: 'red' } }),
-            template: `<div :style="style" v-show="false"/>`
-          })
-        )
+            template: `<div :style="style" v-show="false"/>`,
+          }),
+        ),
       ).toBe(`<div style="color:red;display:none;"></div>`)
     })
 
@@ -58,9 +58,9 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ style: { color: 'red' } }),
-            template: `<div :style="style" style="font-size:12;" v-show="false"/>`
-          })
-        )
+            template: `<div :style="style" style="font-size:12;" v-show="false"/>`,
+          }),
+        ),
       ).toBe(`<div style="color:red;font-size:12;display:none;"></div>`)
     })
   })
@@ -71,9 +71,9 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ text: 'hello' }),
-            template: `<input v-model="text">`
-          })
-        )
+            template: `<input v-model="text">`,
+          }),
+        ),
       ).toBe(`<input value="hello">`)
     })
 
@@ -82,18 +82,18 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ selected: 'foo' }),
-            template: `<input type="radio" value="foo" v-model="selected">`
-          })
-        )
+            template: `<input type="radio" value="foo" v-model="selected">`,
+          }),
+        ),
       ).toBe(`<input type="radio" value="foo" checked>`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ selected: 'foo' }),
-            template: `<input type="radio" value="bar" v-model="selected">`
-          })
-        )
+            template: `<input type="radio" value="bar" v-model="selected">`,
+          }),
+        ),
       ).toBe(`<input type="radio" value="bar">`)
 
       // non-string values
@@ -101,9 +101,9 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ selected: 'foo' }),
-            template: `<input type="radio" :value="{}" v-model="selected">`
-          })
-        )
+            template: `<input type="radio" :value="{}" v-model="selected">`,
+          }),
+        ),
       ).toBe(`<input type="radio">`)
     })
 
@@ -112,22 +112,22 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ model: 1 }),
-            template: `<select v-model="model"><option value="0"></option><option value="1"></option></select>`
-          })
-        )
+            template: `<select v-model="model"><option value="0"></option><option value="1"></option></select>`,
+          }),
+        ),
       ).toBe(
-        `<select><option value="0"></option><option value="1" selected></option></select>`
+        `<select><option value="0"></option><option value="1" selected></option></select>`,
       )
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ model: [0, 1] }),
-            template: `<select multiple v-model="model"><option value="0"></option><option value="1"></option></select>`
-          })
-        )
+            template: `<select multiple v-model="model"><option value="0"></option><option value="1"></option></select>`,
+          }),
+        ),
       ).toBe(
-        `<select multiple><option value="0" selected></option><option value="1" selected></option></select>`
+        `<select multiple><option value="0" selected></option><option value="1" selected></option></select>`,
       )
     })
 
@@ -136,36 +136,36 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ checked: true }),
-            template: `<input type="checkbox" v-model="checked">`
-          })
-        )
+            template: `<input type="checkbox" v-model="checked">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox" checked>`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ checked: false }),
-            template: `<input type="checkbox" v-model="checked">`
-          })
-        )
+            template: `<input type="checkbox" v-model="checked">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox">`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ checked: ['foo'] }),
-            template: `<input type="checkbox" value="foo" v-model="checked">`
-          })
-        )
+            template: `<input type="checkbox" value="foo" v-model="checked">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="foo" checked>`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ checked: [] }),
-            template: `<input type="checkbox" value="foo" v-model="checked">`
-          })
-        )
+            template: `<input type="checkbox" value="foo" v-model="checked">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="foo">`)
     })
 
@@ -174,9 +174,9 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ foo: 'hello' }),
-            template: `<textarea v-model="foo"/>`
-          })
-        )
+            template: `<textarea v-model="foo"/>`,
+          }),
+        ),
       ).toBe(`<textarea>hello</textarea>`)
     })
 
@@ -185,63 +185,63 @@ describe('ssr: directives', () => {
         await renderToString(
           createApp({
             data: () => ({ type: 'text', model: 'hello' }),
-            template: `<input :type="type" v-model="model">`
-          })
-        )
+            template: `<input :type="type" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="text" value="hello">`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ type: 'checkbox', model: true }),
-            template: `<input :type="type" v-model="model">`
-          })
-        )
+            template: `<input :type="type" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox" checked>`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ type: 'checkbox', model: false }),
-            template: `<input :type="type" v-model="model">`
-          })
-        )
+            template: `<input :type="type" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox">`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ type: 'checkbox', model: ['hello'] }),
-            template: `<input :type="type" value="hello" v-model="model">`
-          })
-        )
+            template: `<input :type="type" value="hello" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="hello" checked>`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ type: 'checkbox', model: [] }),
-            template: `<input :type="type" value="hello" v-model="model">`
-          })
-        )
+            template: `<input :type="type" value="hello" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="hello">`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ type: 'radio', model: 'hello' }),
-            template: `<input :type="type" value="hello" v-model="model">`
-          })
-        )
+            template: `<input :type="type" value="hello" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="radio" value="hello" checked>`)
 
       expect(
         await renderToString(
           createApp({
             data: () => ({ type: 'radio', model: 'hello' }),
-            template: `<input :type="type" value="bar" v-model="model">`
-          })
-        )
+            template: `<input :type="type" value="bar" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="radio" value="bar">`)
     })
 
@@ -251,11 +251,11 @@ describe('ssr: directives', () => {
           createApp({
             data: () => ({
               obj: { type: 'radio', value: 'hello' },
-              model: 'hello'
+              model: 'hello',
             }),
-            template: `<input v-bind="obj" v-model="model">`
-          })
-        )
+            template: `<input v-bind="obj" v-model="model">`,
+          }),
+        ),
       ).toBe(`<input type="radio" value="hello" checked>`)
     })
   })
@@ -267,9 +267,9 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('div'), [[vShow, true]])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<div></div>`)
 
       expect(
@@ -277,9 +277,9 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('div'), [[vShow, false]])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<div style="display:none;"></div>`)
     })
 
@@ -291,14 +291,14 @@ describe('ssr: directives', () => {
               return withDirectives(
                 h('div', {
                   style: {
-                    color: 'red'
-                  }
+                    color: 'red',
+                  },
                 }),
-                [[vShow, false]]
+                [[vShow, false]],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<div style="color:red;display:none;"></div>`)
     })
   })
@@ -310,9 +310,9 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('input'), [[vModelText, 'hello']])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input value="hello">`)
     })
 
@@ -323,11 +323,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'radio', value: 'hello' }),
-                [[vModelRadio, 'hello']]
+                [[vModelRadio, 'hello']],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="radio" value="hello" checked>`)
 
       expect(
@@ -336,11 +336,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'radio', value: 'hello' }),
-                [[vModelRadio, 'foo']]
+                [[vModelRadio, 'foo']],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="radio" value="hello">`)
     })
 
@@ -350,11 +350,11 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('input', { type: 'checkbox' }), [
-                [vModelCheckbox, true]
+                [vModelCheckbox, true],
               ])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox" checked>`)
 
       expect(
@@ -362,11 +362,11 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('input', { type: 'checkbox' }), [
-                [vModelCheckbox, false]
+                [vModelCheckbox, false],
               ])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox">`)
 
       expect(
@@ -375,11 +375,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'checkbox', value: 'foo' }),
-                [[vModelCheckbox, ['foo']]]
+                [[vModelCheckbox, ['foo']]],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="foo" checked>`)
 
       expect(
@@ -388,11 +388,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'checkbox', value: 'foo' }),
-                [[vModelCheckbox, []]]
+                [[vModelCheckbox, []]],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="foo">`)
     })
   })
@@ -404,9 +404,9 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('input'), [[vModelDynamic, 'hello']])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input value="hello">`)
     })
 
@@ -417,11 +417,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'radio', value: 'hello' }),
-                [[vModelDynamic, 'hello']]
+                [[vModelDynamic, 'hello']],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="radio" value="hello" checked>`)
 
       expect(
@@ -430,11 +430,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'radio', value: 'hello' }),
-                [[vModelDynamic, 'foo']]
+                [[vModelDynamic, 'foo']],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="radio" value="hello">`)
     })
 
@@ -444,11 +444,11 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('input', { type: 'checkbox' }), [
-                [vModelDynamic, true]
+                [vModelDynamic, true],
               ])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox" checked>`)
 
       expect(
@@ -456,11 +456,11 @@ describe('ssr: directives', () => {
           createApp({
             render() {
               return withDirectives(h('input', { type: 'checkbox' }), [
-                [vModelDynamic, false]
+                [vModelDynamic, false],
               ])
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox">`)
 
       expect(
@@ -469,11 +469,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'checkbox', value: 'foo' }),
-                [[vModelDynamic, ['foo']]]
+                [[vModelDynamic, ['foo']]],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="foo" checked>`)
 
       expect(
@@ -482,11 +482,11 @@ describe('ssr: directives', () => {
             render() {
               return withDirectives(
                 h('input', { type: 'checkbox', value: 'foo' }),
-                [[vModelDynamic, []]]
+                [[vModelDynamic, []]],
               )
-            }
-          })
-        )
+            },
+          }),
+        ),
       ).toBe(`<input type="checkbox" value="foo">`)
     })
   })
@@ -501,14 +501,14 @@ describe('ssr: directives', () => {
                 {
                   getSSRProps({ value }) {
                     return { id: value }
-                  }
+                  },
                 },
-                'foo'
-              ]
+                'foo',
+              ],
             ])
-          }
-        })
-      )
+          },
+        }),
+      ),
     ).toBe(`<div id="foo"></div>`)
   })
 
@@ -518,28 +518,28 @@ describe('ssr: directives', () => {
         createApp({
           data() {
             return {
-              x: 'foo'
+              x: 'foo',
             }
           },
           directives: {
             xxx: {
               getSSRProps({ value, arg, modifiers }) {
                 return { id: [value, arg, modifiers.ok].join('-') }
-              }
-            }
+              },
+            },
           },
           ssrRender(_ctx, _push, _parent, _attrs) {
             const _directive_xxx = resolveDirective('xxx')!
             _push(
               `<div${ssrRenderAttrs(
                 ssrGetDirectiveProps(_ctx, _directive_xxx, _ctx.x, 'arg', {
-                  ok: true
-                })
-              )}></div>`
+                  ok: true,
+                }),
+              )}></div>`,
             )
-          }
-        })
-      )
+          },
+        }),
+      ),
     ).toBe(`<div id="foo-arg-true"></div>`)
   })
 })
index dff16c781b870749d9bcd92d5d03163643959dfb..caeb88397b16ca9a824dfc5271248f55e14dc645 100644 (file)
@@ -8,12 +8,12 @@ describe('ssr: dynamic component', () => {
         createApp({
           components: {
             one: {
-              template: `<div><slot/></div>`
-            }
+              template: `<div><slot/></div>`,
+            },
           },
-          template: `<component :is="'one'"><span>slot</span></component>`
-        })
-      )
+          template: `<component :is="'one'"><span>slot</span></component>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><span>slot</span><!--]--></div>`)
   })
 
@@ -21,28 +21,28 @@ describe('ssr: dynamic component', () => {
     expect(
       await renderToString(
         createApp({
-          template: `<component :is="'p'"><span>slot</span></component>`
-        })
-      )
+          template: `<component :is="'p'"><span>slot</span></component>`,
+        }),
+      ),
     ).toBe(`<p><span>slot</span></p>`)
   })
 
   test('resolve to component vnode', async () => {
     const Child = {
       props: ['id'],
-      template: `<div>{{ id }}<slot/></div>`
+      template: `<div>{{ id }}<slot/></div>`,
     }
     expect(
       await renderToString(
         createApp({
           setup() {
             return {
-              vnode: createVNode(Child, { id: 'test' })
+              vnode: createVNode(Child, { id: 'test' }),
             }
           },
-          template: `<component :is="vnode"><span>slot</span></component>`
-        })
-      )
+          template: `<component :is="vnode"><span>slot</span></component>`,
+        }),
+      ),
     ).toBe(`<div>test<!--[--><span>slot</span><!--]--></div>`)
   })
 
@@ -52,12 +52,12 @@ describe('ssr: dynamic component', () => {
         createApp({
           setup() {
             return {
-              vnode: createVNode('div', { id: 'test' })
+              vnode: createVNode('div', { id: 'test' }),
             }
           },
-          template: `<component :is="vnode"><span>slot</span></component>`
-        })
-      )
+          template: `<component :is="vnode"><span>slot</span></component>`,
+        }),
+      ),
     ).toBe(`<div id="test"><span>slot</span></div>`)
   })
 })
index fc9a4a3b40d9818a07880767ce173c6ae01367e4..11177c84a01d86d5f6e16182835051082cc0d434 100644 (file)
@@ -7,23 +7,23 @@ test('ssr: interpolate', () => {
   expect(ssrInterpolate(`<div>`)).toBe(`&lt;div&gt;`)
   // should escape interpolated values
   expect(ssrInterpolate([1, 2, 3])).toBe(
-    escapeHtml(JSON.stringify([1, 2, 3], null, 2))
+    escapeHtml(JSON.stringify([1, 2, 3], null, 2)),
   )
   expect(
     ssrInterpolate({
       foo: 1,
-      bar: `<div>`
-    })
+      bar: `<div>`,
+    }),
   ).toBe(
     escapeHtml(
       JSON.stringify(
         {
           foo: 1,
-          bar: `<div>`
+          bar: `<div>`,
         },
         null,
-        2
-      )
-    )
+        2,
+      ),
+    ),
   )
 })
index 2439c3514528685f49643db0903ba6c09290d00a..53b44728cfa72f47585c5ddee5b45dc5b931354b 100644 (file)
@@ -1,8 +1,8 @@
 import {
+  ssrRenderAttr,
   ssrRenderAttrs,
   ssrRenderClass,
   ssrRenderStyle,
-  ssrRenderAttr
 } from '../src/helpers/ssrRenderAttrs'
 import { escapeHtml } from '@vue/shared'
 
@@ -14,8 +14,8 @@ describe('ssr: renderAttrs', () => {
         ref_key: 'foo',
         ref_for: 'bar',
         ref: () => {},
-        onClick: () => {}
-      })
+        onClick: () => {},
+      }),
     ).toBe('')
   })
 
@@ -23,24 +23,24 @@ describe('ssr: renderAttrs', () => {
     expect(
       ssrRenderAttrs({
         id: 'foo',
-        title: 'bar'
-      })
+        title: 'bar',
+      }),
     ).toBe(` id="foo" title="bar"`)
   })
 
   test('empty value attrs', () => {
     expect(
       ssrRenderAttrs({
-        'data-v-abc': ''
-      })
+        'data-v-abc': '',
+      }),
     ).toBe(` data-v-abc`)
   })
 
   test('escape attrs', () => {
     expect(
       ssrRenderAttrs({
-        id: '"><script'
-      })
+        id: '"><script',
+      }),
     ).toBe(` id="&quot;&gt;&lt;script"`)
   })
 
@@ -50,8 +50,8 @@ describe('ssr: renderAttrs', () => {
         checked: true,
         multiple: false,
         readonly: 0,
-        disabled: ''
-      })
+        disabled: '',
+      }),
     ).toBe(` checked disabled`) // boolean attr w/ false should be ignored
   })
 
@@ -60,8 +60,8 @@ describe('ssr: renderAttrs', () => {
       ssrRenderAttrs({
         foo: false,
         title: null,
-        baz: undefined
-      })
+        baz: undefined,
+      }),
     ).toBe(` foo="false"`) // non boolean should render `false` as is
   })
 
@@ -70,8 +70,8 @@ describe('ssr: renderAttrs', () => {
       ssrRenderAttrs({
         foo: {},
         bar: [],
-        baz: () => {}
-      })
+        baz: () => {},
+      }),
     ).toBe(``)
   })
 
@@ -79,8 +79,8 @@ describe('ssr: renderAttrs', () => {
     expect(
       ssrRenderAttrs({
         readOnly: true, // simple lower case conversion
-        htmlFor: 'foobar' // special cases
-      })
+        htmlFor: 'foobar', // special cases
+      }),
     ).toBe(` readonly for="foobar"`)
   })
 
@@ -88,10 +88,10 @@ describe('ssr: renderAttrs', () => {
     expect(
       ssrRenderAttrs(
         {
-          fooBar: 'ok'
+          fooBar: 'ok',
         },
-        'my-el'
-      )
+        'my-el',
+      ),
     ).toBe(` fooBar="ok"`)
   })
 
@@ -99,10 +99,10 @@ describe('ssr: renderAttrs', () => {
     expect(
       ssrRenderAttrs(
         {
-          viewBox: 'foo'
+          viewBox: 'foo',
         },
-        'svg'
-      )
+        'svg',
+      ),
     ).toBe(` viewBox="foo"`)
   })
 })
@@ -119,7 +119,7 @@ describe('ssr: renderAttr', () => {
 
   test('escape', () => {
     expect(ssrRenderAttr('foo', '<script>')).toBe(
-      ` foo="${escapeHtml(`<script>`)}"`
+      ` foo="${escapeHtml(`<script>`)}"`,
     )
   })
 })
@@ -128,8 +128,8 @@ describe('ssr: renderClass', () => {
   test('via renderProps', () => {
     expect(
       ssrRenderAttrs({
-        class: ['foo', 'bar']
-      })
+        class: ['foo', 'bar'],
+      }),
     ).toBe(` class="foo bar"`)
   })
 
@@ -152,9 +152,9 @@ describe('ssr: renderStyle', () => {
         style: {
           color: 'red',
           '--a': 2,
-          '-webkit-line-clamp': 1
-        }
-      })
+          '-webkit-line-clamp': 1,
+        },
+      }),
     ).toBe(` style="color:red;--a:2;-webkit-line-clamp:1;"`)
   })
 
@@ -162,14 +162,14 @@ describe('ssr: renderStyle', () => {
     expect(ssrRenderStyle(`color:red`)).toBe(`color:red`)
     expect(
       ssrRenderStyle({
-        color: `red`
-      })
+        color: `red`,
+      }),
     ).toBe(`color:red;`)
     expect(
       ssrRenderStyle([
         { color: `red` },
-        { fontSize: `15px` } // case conversion
-      ])
+        { fontSize: `15px` }, // case conversion
+      ]),
     ).toBe(`color:red;font-size:15px;`)
   })
 
@@ -177,8 +177,8 @@ describe('ssr: renderStyle', () => {
     expect(
       ssrRenderStyle({
         fontSize: null, // invalid value should be ignored
-        opacity: 0.5
-      })
+        opacity: 0.5,
+      }),
     ).toBe(`opacity:0.5;`)
   })
 
@@ -186,8 +186,8 @@ describe('ssr: renderStyle', () => {
     expect(ssrRenderStyle(`"><script`)).toBe(`&quot;&gt;&lt;script`)
     expect(
       ssrRenderStyle({
-        color: `"><script`
-      })
+        color: `"><script`,
+      }),
     ).toBe(`color:&quot;&gt;&lt;script;`)
   })
 })
index 56c9b7c3593dc0304e8835224e73ce80e2c55c34..f8dcb2930590b4a84abd6062a81dd4532c383837 100644 (file)
@@ -9,7 +9,7 @@ describe('ssr: renderList', () => {
 
   it('should render items in an array', () => {
     ssrRenderList(['1', '2', '3'], (item, index) =>
-      stack.push(`node ${index}: ${item}`)
+      stack.push(`node ${index}: ${item}`),
     )
     expect(stack).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
   })
@@ -27,13 +27,13 @@ describe('ssr: renderList', () => {
   it('should warn when given a non-integer N', () => {
     ssrRenderList(3.1, () => {})
     expect(
-      `The v-for range expect an integer value but got 3.1.`
+      `The v-for range expect an integer value but got 3.1.`,
     ).toHaveBeenWarned()
   })
 
   it('should render properties in an object', () => {
     ssrRenderList({ a: 1, b: 2, c: 3 }, (item, key, index) =>
-      stack.push(`node ${index}/${key}: ${item}`)
+      stack.push(`node ${index}/${key}: ${item}`),
     )
     expect(stack).toEqual(['node 0/a: 1', 'node 1/b: 2', 'node 2/c: 3'])
   })
@@ -46,14 +46,14 @@ describe('ssr: renderList', () => {
     }
 
     ssrRenderList(iterable(), (item, index) =>
-      stack.push(`node ${index}: ${item}`)
+      stack.push(`node ${index}: ${item}`),
     )
     expect(stack).toEqual(['node 0: 1', 'node 1: 2', 'node 2: 3'])
   })
 
   it('should not render items when source is undefined', () => {
     ssrRenderList(undefined, (item, index) =>
-      stack.push(`node ${index}: ${item}`)
+      stack.push(`node ${index}: ${item}`),
     )
     expect(stack).toEqual([])
   })
index 2637fd7840231bbdcfa2930fab5d988350c0ef71..f9d356065d0c8539608b99cb290e25a34cffe2b5 100644 (file)
@@ -1,20 +1,20 @@
 import { createApp, h, mergeProps, withCtx } from 'vue'
 import { renderToString } from '../src/renderToString'
-import { ssrRenderComponent, ssrRenderAttrs, ssrRenderSlot } from '../src'
+import { ssrRenderAttrs, ssrRenderComponent, ssrRenderSlot } from '../src'
 
 describe('ssr: scopedId runtime behavior', () => {
   test('id on component root', async () => {
     const Child = {
       ssrRender: (ctx: any, push: any, parent: any, attrs: any) => {
         push(`<div${ssrRenderAttrs(attrs)}></div>`)
-      }
+      },
     }
 
     const Comp = {
       __scopeId: 'parent',
       ssrRender: (ctx: any, push: any, parent: any) => {
         push(ssrRenderComponent(Child), null, null, parent)
-      }
+      },
     }
 
     const result = await renderToString(createApp(Comp))
@@ -26,7 +26,7 @@ describe('ssr: scopedId runtime behavior', () => {
       // <div></div>
       ssrRender: (_: any, push: any, _parent: any, attrs: any) => {
         push(`<div${ssrRenderAttrs(attrs)} child></div>`)
-      }
+      },
     }
 
     const Wrapper = {
@@ -40,9 +40,9 @@ describe('ssr: scopedId runtime behavior', () => {
           null,
           push,
           parent,
-          'wrapper-s'
+          'wrapper-s',
         )
-      }
+      },
     }
 
     const Comp = {
@@ -57,14 +57,14 @@ describe('ssr: scopedId runtime behavior', () => {
               default: withCtx(
                 (_: any, push: any, parent: any, scopeId: string) => {
                   push(ssrRenderComponent(Child, null, null, parent, scopeId))
-                }
+                },
               ),
-              _: 1
+              _: 1,
             } as any,
-            parent
-          )
+            parent,
+          ),
         )
-      }
+      },
     }
 
     const result = await renderToString(createApp(Comp))
@@ -79,8 +79,8 @@ describe('ssr: scopedId runtime behavior', () => {
         // <div class="wrapper"><slot/></div>
         push(
           `<div${ssrRenderAttrs(
-            mergeProps({ class: 'wrapper' }, attrs)
-          )} wrapper>`
+            mergeProps({ class: 'wrapper' }, attrs),
+          )} wrapper>`,
         )
         ssrRenderSlot(
           ctx.$slots,
@@ -89,10 +89,10 @@ describe('ssr: scopedId runtime behavior', () => {
           null,
           push,
           parent,
-          'wrapper-s'
+          'wrapper-s',
         )
         push(`</div>`)
-      }
+      },
     }
 
     const Slotted = {
@@ -113,16 +113,16 @@ describe('ssr: scopedId runtime behavior', () => {
                     null,
                     push,
                     parent,
-                    'slotted-s' + scopeId
+                    'slotted-s' + scopeId,
                   )
-                }
+                },
               ),
-              _: 1
+              _: 1,
             } as any,
-            parent
-          )
+            parent,
+          ),
         )
-      }
+      },
     }
 
     const Root = {
@@ -137,21 +137,21 @@ describe('ssr: scopedId runtime behavior', () => {
               default: withCtx(
                 (_: any, push: any, parent: any, scopeId: string) => {
                   push(`<div root${scopeId}></div>`)
-                }
+                },
               ),
-              _: 1
+              _: 1,
             } as any,
-            parent
-          )
+            parent,
+          ),
         )
-      }
+      },
     }
 
     const result = await renderToString(createApp(Root))
     expect(result).toBe(
       `<div class="wrapper" root slotted wrapper>` +
         `<!--[--><!--[--><div root slotted-s wrapper-s></div><!--]--><!--]-->` +
-        `</div>`
+        `</div>`,
     )
   })
 
@@ -160,20 +160,20 @@ describe('ssr: scopedId runtime behavior', () => {
     const Child = {
       ssrRender: (ctx: any, push: any, parent: any, attrs: any) => {
         push(`<div${ssrRenderAttrs(attrs)}></div>`)
-      }
+      },
     }
 
     const Middle = {
       render() {
         return h(Child)
-      }
+      },
     }
 
     const Comp = {
       __scopeId: 'parent',
       ssrRender: (ctx: any, push: any, parent: any) => {
         push(ssrRenderComponent(Middle, null, null, parent))
-      }
+      },
     }
 
     const result = await renderToString(createApp(Comp)) // output: `<div></div>`
index 9b3a2cdcc94e480e4101a5d5c48249996d9660d8..4534630879f2867752d2e6e04dcd98eed02d5d49 100644 (file)
@@ -3,8 +3,8 @@ import { renderToString } from '../src/renderToString'
 
 const components = {
   one: {
-    template: `<div><slot/></div>`
-  }
+    template: `<div><slot/></div>`,
+  },
 }
 
 describe('ssr: slot', () => {
@@ -13,9 +13,9 @@ describe('ssr: slot', () => {
       await renderToString(
         createApp({
           components,
-          template: `<one>hello</one>`
-        })
-      )
+          template: `<one>hello</one>`,
+        }),
+      ),
     ).toBe(`<div><!--[-->hello<!--]--></div>`)
   })
 
@@ -24,9 +24,9 @@ describe('ssr: slot', () => {
       await renderToString(
         createApp({
           components,
-          template: `<one><div>hi</div></one>`
-        })
-      )
+          template: `<one><div>hi</div></one>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><div>hi</div><!--]--></div>`)
   })
 
@@ -36,12 +36,12 @@ describe('ssr: slot', () => {
         createApp({
           components: {
             one: {
-              template: `<div><slot/></div>`
-            }
+              template: `<div><slot/></div>`,
+            },
           },
-          template: `<one><template v-if="false"/></one>`
-        })
-      )
+          template: `<one><template v-if="false"/></one>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><!--]--></div>`)
   })
 
@@ -51,12 +51,12 @@ describe('ssr: slot', () => {
         createApp({
           components: {
             one: {
-              template: `<div><slot/></div>`
-            }
+              template: `<div><slot/></div>`,
+            },
           },
-          template: `<one><!--hello--></one>`
-        })
-      )
+          template: `<one><!--hello--></one>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><!--]--></div>`)
   })
 
@@ -66,12 +66,12 @@ describe('ssr: slot', () => {
         createApp({
           components: {
             one: {
-              template: `<div><slot/></div>`
-            }
+              template: `<div><slot/></div>`,
+            },
           },
-          template: `<one><!--he\nllo--></one>`
-        })
-      )
+          template: `<one><!--he\nllo--></one>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><!--]--></div>`)
   })
 
@@ -80,9 +80,9 @@ describe('ssr: slot', () => {
       await renderToString(
         createApp({
           components,
-          template: `<one><div>one</div><div>two</div></one>`
-        })
-      )
+          template: `<one><div>one</div><div>two</div></one>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><div>one</div><div>two</div><!--]--></div>`)
   })
 
@@ -91,9 +91,9 @@ describe('ssr: slot', () => {
       await renderToString(
         createApp({
           components,
-          template: `<one><template v-if="true">hello</template></one>`
-        })
-      )
+          template: `<one><template v-if="true">hello</template></one>`,
+        }),
+      ),
     ).toBe(`<div><!--[--><!--[-->hello<!--]--><!--]--></div>`)
   })
 
@@ -102,11 +102,11 @@ describe('ssr: slot', () => {
       await renderToString(
         createApp({
           components,
-          template: `<one><template v-if="true"><div>one</div><div>two</div></template></one>`
-        })
-      )
+          template: `<one><template v-if="true"><div>one</div><div>two</div></template></one>`,
+        }),
+      ),
     ).toBe(
-      `<div><!--[--><!--[--><div>one</div><div>two</div><!--]--><!--]--></div>`
+      `<div><!--[--><!--[--><div>one</div><div>two</div><!--]--><!--]--></div>`,
     )
   })
 
@@ -116,12 +116,12 @@ describe('ssr: slot', () => {
         createApp({
           components: {
             one: {
-              template: `<transition><slot/></transition>`
-            }
+              template: `<transition><slot/></transition>`,
+            },
           },
-          template: `<one><div v-if="false">foo</div></one>`
-        })
-      )
+          template: `<one><div v-if="false">foo</div></one>`,
+        }),
+      ),
     ).toBe(`<!---->`)
 
     expect(
@@ -129,12 +129,12 @@ describe('ssr: slot', () => {
         createApp({
           components: {
             one: {
-              template: `<transition><slot/></transition>`
-            }
+              template: `<transition><slot/></transition>`,
+            },
           },
-          template: `<one><div v-if="true">foo</div></one>`
-        })
-      )
+          template: `<one><div v-if="true">foo</div></one>`,
+        }),
+      ),
     ).toBe(`<div>foo</div>`)
   })
 })
index 97984f61d9452d9dbed62840be95e31e11549356..eef642d004263a0f751035560820965978a7802c 100644 (file)
@@ -1,17 +1,17 @@
-import { createApp, h, Suspense } from 'vue'
+import { Suspense, createApp, h } from 'vue'
 import { renderToString } from '../src/renderToString'
 
 describe('SSR Suspense', () => {
   const ResolvingAsync = {
     async setup() {
       return () => h('div', 'async')
-    }
+    },
   }
 
   const RejectingAsync = {
     setup() {
       return new Promise((_, reject) => reject('foo'))
-    }
+    },
   }
 
   test('content', async () => {
@@ -19,9 +19,9 @@ describe('SSR Suspense', () => {
       render() {
         return h(Suspense, null, {
           default: h(ResolvingAsync),
-          fallback: h('div', 'fallback')
+          fallback: h('div', 'fallback'),
         })
-      }
+      },
     }
 
     expect(await renderToString(createApp(Comp))).toBe(`<div>async</div>`)
@@ -33,9 +33,9 @@ describe('SSR Suspense', () => {
       render() {
         return h(Suspense, null, {
           default: h(RejectingAsync),
-          fallback: h('div', 'fallback')
+          fallback: h('div', 'fallback'),
         })
-      }
+      },
     }
 
     expect(await renderToString(createApp(Comp))).toBe(`<!---->`)
@@ -49,13 +49,13 @@ describe('SSR Suspense', () => {
       render() {
         return h(Suspense, null, {
           default: h('div', [h(ResolvingAsync), h(ResolvingAsync)]),
-          fallback: h('div', 'fallback')
+          fallback: h('div', 'fallback'),
         })
-      }
+      },
     }
 
     expect(await renderToString(createApp(Comp))).toBe(
-      `<div><div>async</div><div>async</div></div>`
+      `<div><div>async</div><div>async</div></div>`,
     )
   })
 
@@ -65,13 +65,13 @@ describe('SSR Suspense', () => {
       render() {
         return h(Suspense, null, {
           default: h('div', [h(ResolvingAsync), h(RejectingAsync)]),
-          fallback: h('div', 'fallback')
+          fallback: h('div', 'fallback'),
         })
-      }
+      },
     }
 
     expect(await renderToString(createApp(Comp))).toBe(
-      `<div><div>async</div><!----></div>`
+      `<div><div>async</div><!----></div>`,
     )
 
     expect(Comp.errorCaptured).toHaveBeenCalledTimes(1)
@@ -87,16 +87,16 @@ describe('SSR Suspense', () => {
             h(ResolvingAsync),
             h(Suspense, null, {
               default: h('div', [h(RejectingAsync)]),
-              fallback: h('div', 'fallback 2')
-            })
+              fallback: h('div', 'fallback 2'),
+            }),
           ]),
-          fallback: h('div', 'fallback 1')
+          fallback: h('div', 'fallback 1'),
         })
-      }
+      },
     }
 
     expect(await renderToString(createApp(Comp))).toBe(
-      `<div><div>async</div><div><!----></div></div>`
+      `<div><div>async</div><div><!----></div></div>`,
     )
 
     expect(Comp.errorCaptured).toHaveBeenCalledTimes(1)
@@ -112,16 +112,16 @@ describe('SSR Suspense', () => {
             h(RejectingAsync),
             h(Suspense, null, {
               default: h('div', [h(ResolvingAsync)]),
-              fallback: h('div', 'fallback 2')
-            })
+              fallback: h('div', 'fallback 2'),
+            }),
           ]),
-          fallback: h('div', 'fallback 1')
+          fallback: h('div', 'fallback 1'),
         })
-      }
+      },
     }
 
     expect(await renderToString(createApp(Comp))).toBe(
-      `<div><!----><div><div>async</div></div></div>`
+      `<div><!----><div><div>async</div></div></div>`,
     )
     expect(Comp.errorCaptured).toHaveBeenCalledTimes(1)
     expect('missing template').toHaveBeenWarned()
index 4de6b44bb53b2ea671adc84e9e23598e088807e3..a0a2f6ae0a103ee56d554225d68521ddbed31ea7 100644 (file)
@@ -1,7 +1,7 @@
-import { createApp, h, Teleport } from 'vue'
+import { Teleport, createApp, h } from 'vue'
 import { renderToString } from '../src/renderToString'
 import { renderToSimpleStream } from '../src/renderToStream'
-import { SSRContext } from '../src/render'
+import type { SSRContext } from '../src/render'
 import { ssrRenderTeleport } from '../src/helpers/ssrRenderTeleport'
 
 describe('ssrRenderTeleport', () => {
@@ -20,15 +20,15 @@ describe('ssrRenderTeleport', () => {
             },
             '#target',
             false,
-            _parent
+            _parent,
           )
-        }
+        },
       }),
-      ctx
+      ctx,
     )
     expect(html).toBe('<!--teleport start--><!--teleport end-->')
     expect(ctx.teleports!['#target']).toBe(
-      `<div>content</div><!--teleport anchor-->`
+      `<div>content</div><!--teleport anchor-->`,
     )
   })
 
@@ -47,14 +47,14 @@ describe('ssrRenderTeleport', () => {
             },
             '#target',
             true,
-            _parent
+            _parent,
           )
-        }
+        },
       }),
-      ctx
+      ctx,
     )
     expect(html).toBe(
-      '<!--teleport start--><div>content</div><!--teleport end-->'
+      '<!--teleport start--><div>content</div><!--teleport end-->',
     )
     expect(ctx.teleports!['#target']).toBe(`<!--teleport anchor-->`)
   })
@@ -65,15 +65,15 @@ describe('ssrRenderTeleport', () => {
       h(
         Teleport,
         {
-          to: `#target`
+          to: `#target`,
         },
-        h('span', 'hello')
+        h('span', 'hello'),
       ),
-      ctx
+      ctx,
     )
     expect(html).toBe('<!--teleport start--><!--teleport end-->')
     expect(ctx.teleports!['#target']).toBe(
-      '<span>hello</span><!--teleport anchor-->'
+      '<span>hello</span><!--teleport anchor-->',
     )
   })
 
@@ -84,14 +84,14 @@ describe('ssrRenderTeleport', () => {
         Teleport,
         {
           to: `#target`,
-          disabled: true
+          disabled: true,
         },
-        h('span', 'hello')
+        h('span', 'hello'),
       ),
-      ctx
+      ctx,
     )
     expect(html).toBe(
-      '<!--teleport start--><span>hello</span><!--teleport end-->'
+      '<!--teleport start--><span>hello</span><!--teleport end-->',
     )
     expect(ctx.teleports!['#target']).toBe(`<!--teleport anchor-->`)
   })
@@ -103,19 +103,19 @@ describe('ssrRenderTeleport', () => {
         h(
           Teleport,
           {
-            to: `#target`
+            to: `#target`,
           },
-          h('span', 'hello')
+          h('span', 'hello'),
         ),
-        h(Teleport, { to: `#target` }, 'world')
+        h(Teleport, { to: `#target` }, 'world'),
       ]),
-      ctx
+      ctx,
     )
     expect(html).toBe(
-      '<div><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--></div>'
+      '<div><!--teleport start--><!--teleport end--><!--teleport start--><!--teleport end--></div>',
     )
     expect(ctx.teleports!['#target']).toBe(
-      '<span>hello</span><!--teleport anchor-->world<!--teleport anchor-->'
+      '<span>hello</span><!--teleport anchor-->world<!--teleport anchor-->',
     )
   })
 
@@ -123,18 +123,18 @@ describe('ssrRenderTeleport', () => {
     const ctx: SSRContext = {}
     const asyncComponent = {
       template: '<teleport to="#target"><div>content</div></teleport>',
-      async setup() {}
+      async setup() {},
     }
     const html = await renderToString(
       h({
         template: '<async-component />',
-        components: { asyncComponent }
+        components: { asyncComponent },
       }),
-      ctx
+      ctx,
     )
     expect(html).toBe('<!--teleport start--><!--teleport end-->')
     expect(ctx.teleports!['#target']).toBe(
-      `<div>content</div><!--teleport anchor-->`
+      `<div>content</div><!--teleport anchor-->`,
     )
   })
 
@@ -142,7 +142,7 @@ describe('ssrRenderTeleport', () => {
     const ctx: SSRContext = {}
     const asyncComponent = {
       template: '<teleport to="#target"><div>content</div></teleport>',
-      async setup() {}
+      async setup() {},
     }
     let html = ''
     let resolve: any
@@ -150,7 +150,7 @@ describe('ssrRenderTeleport', () => {
     renderToSimpleStream(
       h({
         template: '<async-component />',
-        components: { asyncComponent }
+        components: { asyncComponent },
       }),
       ctx,
       {
@@ -163,13 +163,13 @@ describe('ssrRenderTeleport', () => {
         },
         destroy(err) {
           throw err
-        }
-      }
+        },
+      },
     )
     await p
     expect(html).toBe('<!--teleport start--><!--teleport end-->')
     expect(ctx.teleports!['#target']).toBe(
-      `<div>content</div><!--teleport anchor-->`
+      `<div>content</div><!--teleport anchor-->`,
     )
   })
 })
index d003c54064f5f3a582d27289bd4a9594fca5ff33..7d00b9cb7bab42835a0a498639adaa6474be7161 100644 (file)
@@ -1,6 +1,6 @@
 import {
+  ssrGetDynamicModelProps,
   ssrRenderDynamicModel,
-  ssrGetDynamicModelProps
   // ssrGetDynamicModelProps
 } from '../src/helpers/ssrVModelHelpers'
 
@@ -26,90 +26,90 @@ describe('ssr: v-model helpers', () => {
     expect(
       ssrGetDynamicModelProps(
         {
-          type: 'text'
+          type: 'text',
         },
-        'foo'
-      )
+        'foo',
+      ),
     ).toMatchObject({ value: 'foo' })
     expect(
       ssrGetDynamicModelProps(
         {
-          type: 'email'
+          type: 'email',
         },
-        'foo'
-      )
+        'foo',
+      ),
     ).toMatchObject({ value: 'foo' })
 
     expect(
       ssrGetDynamicModelProps(
         {
-          type: 'checkbox'
+          type: 'checkbox',
         },
-        true
-      )
+        true,
+      ),
     ).toMatchObject({ checked: true })
     expect(
       ssrGetDynamicModelProps(
         {
-          type: 'checkbox'
+          type: 'checkbox',
         },
-        false
-      )
+        false,
+      ),
     ).toBe(null)
     expect(
       ssrGetDynamicModelProps(
         {
           type: 'checkbox',
-          value: '1'
+          value: '1',
         },
-        [1]
-      )
+        [1],
+      ),
     ).toMatchObject({ checked: true })
     expect(
       ssrGetDynamicModelProps(
         {
           type: 'checkbox',
-          value: 1
+          value: 1,
         },
-        [1]
-      )
+        [1],
+      ),
     ).toMatchObject({ checked: true })
     expect(
       ssrGetDynamicModelProps(
         {
           type: 'checkbox',
-          value: 0
+          value: 0,
         },
-        [1]
-      )
+        [1],
+      ),
     ).toBe(null)
 
     expect(
       ssrGetDynamicModelProps(
         {
           type: 'radio',
-          value: 'foo'
+          value: 'foo',
         },
-        'foo'
-      )
+        'foo',
+      ),
     ).toMatchObject({ checked: true })
     expect(
       ssrGetDynamicModelProps(
         {
           type: 'radio',
-          value: '1'
+          value: '1',
         },
-        1
-      )
+        1,
+      ),
     ).toMatchObject({ checked: true })
     expect(
       ssrGetDynamicModelProps(
         {
           type: 'radio',
-          value: 0
+          value: 0,
         },
-        1
-      )
+        1,
+      ),
     ).toBe(null)
   })
 })
index df085332dc0cbe6d22db1bcaa1f2da719c50e0b2..c157c90cd42eb7a27fc06c1a83f3491516dd7bf1 100644 (file)
@@ -1,5 +1,5 @@
-import { createSSRApp, defineComponent, h, watch, ref } from 'vue'
-import { SSRContext, renderToString } from '../src'
+import { createSSRApp, defineComponent, h, ref, watch } from 'vue'
+import { type SSRContext, renderToString } from '../src'
 
 describe('ssr: watch', () => {
   // #6013
@@ -12,7 +12,7 @@ describe('ssr: watch', () => {
         () => {
           msg = 'hello world'
         },
-        { flush: 'sync' }
+        { flush: 'sync' },
       )
       count.value = 1
       expect(msg).toBe('hello world')
index 1b5c054c5ae43c57b21cf4c408c0cafaf3938ccc..700a9a0ae3f182596119bbf6f3f1c7ba08bcd44d 100644 (file)
@@ -1,25 +1,25 @@
-import { createApp, h, defineAsyncComponent } from 'vue'
-import { ReadableStream, TransformStream } from 'stream/web'
+import { createApp, defineAsyncComponent, h } from 'vue'
+import { ReadableStream, TransformStream } from 'node:stream/web'
 import { pipeToWebWritable, renderToWebStream } from '../src'
 
 beforeEach(() => {
-  // @ts-ignore
+  // @ts-expect-error
   global.ReadableStream = ReadableStream
 })
 
 afterEach(() => {
-  // @ts-ignore
+  // @ts-expect-error
   delete global.ReadableStream
 })
 
 test('renderToWebStream', async () => {
   const Async = defineAsyncComponent(() =>
     Promise.resolve({
-      render: () => h('div', 'async')
-    })
+      render: () => h('div', 'async'),
+    }),
   )
   const App = {
-    render: () => [h('div', 'parent'), h(Async)]
+    render: () => [h('div', 'parent'), h(Async)],
   }
 
   const stream = renderToWebStream(createApp(App))
@@ -41,11 +41,11 @@ test('renderToWebStream', async () => {
 test('pipeToWebWritable', async () => {
   const Async = defineAsyncComponent(() =>
     Promise.resolve({
-      render: () => h('div', 'async')
-    })
+      render: () => h('div', 'async'),
+    }),
   )
   const App = {
-    render: () => [h('div', 'parent'), h(Async)]
+    render: () => [h('div', 'parent'), h(Async)],
   }
 
   const { readable, writable } = new TransformStream()
index 722997c1a98b9c36924109e19d29ace0976bcc3f..6ab296976ace98b5eb342b65d63794dbe2553001 100644 (file)
@@ -1,8 +1,12 @@
-import { ComponentInternalInstance, ComponentOptions, warn } from 'vue'
+import {
+  type ComponentInternalInstance,
+  type ComponentOptions,
+  warn,
+} from 'vue'
 import { compile } from '@vue/compiler-ssr'
-import { extend, generateCodeFrame, isFunction, NO } from '@vue/shared'
-import { CompilerError, CompilerOptions } from '@vue/compiler-core'
-import { PushFn } from '../render'
+import { NO, extend, generateCodeFrame, isFunction } from '@vue/shared'
+import type { CompilerError, CompilerOptions } from '@vue/compiler-core'
+import type { PushFn } from '../render'
 
 import * as Vue from 'vue'
 import * as helpers from '../internal'
@@ -10,21 +14,21 @@ import * as helpers from '../internal'
 type SSRRenderFunction = (
   context: any,
   push: PushFn,
-  parentInstance: ComponentInternalInstance
+  parentInstance: ComponentInternalInstance,
 ) => void
 
 const compileCache: Record<string, SSRRenderFunction> = Object.create(null)
 
 export function ssrCompile(
   template: string,
-  instance: ComponentInternalInstance
+  instance: ComponentInternalInstance,
 ): SSRRenderFunction {
   // TODO: this branch should now work in ESM builds, enable it in a minor
   if (!__NODE_JS__) {
     throw new Error(
       `On-the-fly template compilation is not supported in the ESM build of ` +
         `@vue/server-renderer. All templates must be pre-compiled into ` +
-        `render functions.`
+        `render functions.`,
     )
   }
 
@@ -37,11 +41,11 @@ export function ssrCompile(
     extend(
       {
         isCustomElement,
-        delimiters
+        delimiters,
       },
-      compilerOptions
+      compilerOptions,
     ),
-    componentCompilerOptions
+    componentCompilerOptions,
   )
 
   finalCompilerOptions.isCustomElement =
@@ -51,11 +55,11 @@ export function ssrCompile(
   const cacheKey = JSON.stringify(
     {
       template,
-      compilerOptions: finalCompilerOptions
+      compilerOptions: finalCompilerOptions,
     },
     (key, value) => {
       return isFunction(value) ? value.toString() : value
-    }
+    },
   )
 
   const cached = compileCache[cacheKey]
@@ -71,7 +75,7 @@ export function ssrCompile(
         generateCodeFrame(
           template as string,
           err.loc.start.offset,
-          err.loc.end.offset
+          err.loc.end.offset,
         )
       warn(codeFrame ? `${message}\n${codeFrame}` : message)
     } else {
@@ -82,7 +86,7 @@ export function ssrCompile(
   const { code } = compile(template, finalCompilerOptions)
   const requireMap = {
     vue: Vue,
-    'vue/server-renderer': helpers
+    'vue/server-renderer': helpers,
   }
   const fakeRequire = (id: 'vue' | 'vue/server-renderer') => requireMap[id]
   return (compileCache[cacheKey] = Function('require', code)(fakeRequire))
index 9a1eb310930d1229b1f616b9ea5d7d96495b2a5b..094d8564f8d262f3b75c8f2468728ef03ff25dae 100644 (file)
@@ -1,11 +1,11 @@
-import { ComponentPublicInstance, Directive } from '@vue/runtime-core'
+import type { ComponentPublicInstance, Directive } from '@vue/runtime-core'
 
 export function ssrGetDirectiveProps(
   instance: ComponentPublicInstance,
   dir: Directive,
   value?: any,
   arg?: string,
-  modifiers: Record<string, boolean> = {}
+  modifiers: Record<string, boolean> = {},
 ): Record<string, any> {
   if (typeof dir !== 'function' && dir.getSSRProps) {
     return (
@@ -16,9 +16,9 @@ export function ssrGetDirectiveProps(
           value,
           oldValue: undefined,
           arg,
-          modifiers
+          modifiers,
         },
-        null as any
+        null as any,
       ) || {}
     )
   }
index 6bbf83a1eaacda21f9efed7bcd03ed171d810a2f..a8d1c7df9dbced81e9211a7acf82762b0ed17f99 100644 (file)
@@ -1,24 +1,24 @@
 import { escapeHtml, isSVGTag, stringifyStyle } from '@vue/shared'
 import {
+  includeBooleanAttr,
+  isBooleanAttr,
+  isOn,
+  isSSRSafeAttrName,
+  isString,
+  makeMap,
   normalizeClass,
   normalizeStyle,
   propsToAttrMap,
-  isString,
-  isOn,
-  isSSRSafeAttrName,
-  isBooleanAttr,
-  includeBooleanAttr,
-  makeMap
 } from '@vue/shared'
 
 // leading comma for empty string ""
 const shouldIgnoreProp = makeMap(
-  `,key,ref,innerHTML,textContent,ref_key,ref_for`
+  `,key,ref,innerHTML,textContent,ref_key,ref_for`,
 )
 
 export function ssrRenderAttrs(
   props: Record<string, unknown>,
-  tag?: string
+  tag?: string,
 ): string {
   let ret = ''
   for (const key in props) {
@@ -45,7 +45,7 @@ export function ssrRenderAttrs(
 export function ssrRenderDynamicAttr(
   key: string,
   value: unknown,
-  tag?: string
+  tag?: string,
 ): string {
   if (!isRenderableValue(value)) {
     return ``
@@ -60,7 +60,7 @@ export function ssrRenderDynamicAttr(
     return value === '' ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`
   } else {
     console.warn(
-      `[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
+      `[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`,
     )
     return ``
   }
index 4709f23a67452403120faf73969ad811f799bb83..4277bb1747e5eabe1f220f82bd7af183d7d597cd 100644 (file)
@@ -1,17 +1,22 @@
-import { Component, ComponentInternalInstance, createVNode, Slots } from 'vue'
-import { Props, renderComponentVNode, SSRBuffer } from '../render'
-import { SSRSlots } from './ssrRenderSlot'
+import {
+  type Component,
+  type ComponentInternalInstance,
+  type Slots,
+  createVNode,
+} from 'vue'
+import { type Props, type SSRBuffer, renderComponentVNode } from '../render'
+import type { SSRSlots } from './ssrRenderSlot'
 
 export function ssrRenderComponent(
   comp: Component,
   props: Props | null = null,
   children: Slots | SSRSlots | null = null,
   parentComponent: ComponentInternalInstance | null = null,
-  slotScopeId?: string
+  slotScopeId?: string,
 ): SSRBuffer | Promise<SSRBuffer> {
   return renderComponentVNode(
     createVNode(comp, props, children),
     parentComponent,
-    slotScopeId
+    slotScopeId,
   )
 }
index bde28f25759b59f8f18b990092cbd2f4a8dfa119..1d0091721453586de33f96deb145c06caf3c6875 100644 (file)
@@ -1,9 +1,9 @@
-import { isArray, isString, isObject } from '@vue/shared'
+import { isArray, isObject, isString } from '@vue/shared'
 import { warn } from '@vue/runtime-core'
 
 export function ssrRenderList(
   source: unknown,
-  renderItem: (value: unknown, key: string | number, index?: number) => void
+  renderItem: (value: unknown, key: string | number, index?: number) => void,
 ) {
   if (isArray(source) || isString(source)) {
     for (let i = 0, l = source.length; i < l; i++) {
index ea1e7e941064e432cac5dde977b6750bfb7468a3..b388e7d193604f5c2e58f0561b2de95e36d170ca 100644 (file)
@@ -1,5 +1,10 @@
-import { ComponentInternalInstance, Slots } from 'vue'
-import { Props, PushFn, renderVNodeChildren, SSRBufferItem } from '../render'
+import type { ComponentInternalInstance, Slots } from 'vue'
+import {
+  type Props,
+  type PushFn,
+  type SSRBufferItem,
+  renderVNodeChildren,
+} from '../render'
 import { isArray } from '@vue/shared'
 
 export type SSRSlots = Record<string, SSRSlot>
@@ -7,7 +12,7 @@ export type SSRSlot = (
   props: Props,
   push: PushFn,
   parentComponent: ComponentInternalInstance | null,
-  scopeId: string | null
+  scopeId: string | null,
 ) => void
 
 export function ssrRenderSlot(
@@ -17,7 +22,7 @@ export function ssrRenderSlot(
   fallbackRenderFn: (() => void) | null,
   push: PushFn,
   parentComponent: ComponentInternalInstance,
-  slotScopeId?: string
+  slotScopeId?: string,
 ) {
   // template-compiled slots are always rendered as fragments
   push(`<!--[-->`)
@@ -28,7 +33,7 @@ export function ssrRenderSlot(
     fallbackRenderFn,
     push,
     parentComponent,
-    slotScopeId
+    slotScopeId,
   )
   push(`<!--]-->`)
 }
@@ -41,7 +46,7 @@ export function ssrRenderSlotInner(
   push: PushFn,
   parentComponent: ComponentInternalInstance,
   slotScopeId?: string,
-  transition?: boolean
+  transition?: boolean,
 ) {
   const slotFn = slots[slotName]
   if (slotFn) {
@@ -53,7 +58,7 @@ export function ssrRenderSlotInner(
       slotProps,
       bufferedPush,
       parentComponent,
-      slotScopeId ? ' ' + slotScopeId : ''
+      slotScopeId ? ' ' + slotScopeId : '',
     )
     if (isArray(ret)) {
       // normal slot
index f02b85d17962ec9047862577864e69f29c2d1181..58e668b070fa1cd403c8e5c1bc170d763445da7d 100644 (file)
@@ -1,8 +1,8 @@
-import { PushFn } from '../render'
+import type { PushFn } from '../render'
 
 export async function ssrRenderSuspense(
   push: PushFn,
-  { default: renderContent }: Record<string, (() => void) | undefined>
+  { default: renderContent }: Record<string, (() => void) | undefined>,
 ) {
   if (renderContent) {
     renderContent()
index 8338ec06c25f1a5f211580a44c245d23107d1e47..d83af28c131c08c527db873fdff7512c47c972a8 100644 (file)
@@ -1,12 +1,17 @@
-import { ComponentInternalInstance, ssrContextKey } from 'vue'
-import { createBuffer, PushFn, SSRBufferItem, SSRContext } from '../render'
+import { type ComponentInternalInstance, ssrContextKey } from 'vue'
+import {
+  type PushFn,
+  type SSRBufferItem,
+  type SSRContext,
+  createBuffer,
+} from '../render'
 
 export function ssrRenderTeleport(
   parentPush: PushFn,
   contentRenderFn: (push: PushFn) => void,
   target: string,
   disabled: boolean,
-  parentComponent: ComponentInternalInstance
+  parentComponent: ComponentInternalInstance,
 ) {
   parentPush('<!--teleport start-->')
 
index 76b3d4f60f1e5e2d3fdc8e34ebb52d41df9b58e1..d899db88f35a9f33ee43c3ba33674b2892b95948 100644 (file)
@@ -1,4 +1,4 @@
-import { looseEqual, looseIndexOf, isArray } from '@vue/shared'
+import { isArray, looseEqual, looseIndexOf } from '@vue/shared'
 import { ssrRenderAttr } from './ssrRenderAttrs'
 
 export const ssrLooseEqual = looseEqual as (a: unknown, b: unknown) => boolean
@@ -11,7 +11,7 @@ export function ssrLooseContain(arr: unknown[], value: unknown): boolean {
 export function ssrRenderDynamicModel(
   type: unknown,
   model: unknown,
-  value: unknown
+  value: unknown,
 ) {
   switch (type) {
     case 'radio':
@@ -29,7 +29,7 @@ export function ssrRenderDynamicModel(
 // for <input v-bind="obj" v-model="model">
 export function ssrGetDynamicModelProps(
   existingProps: any = {},
-  model: unknown
+  model: unknown,
 ) {
   const { type, value } = existingProps
   switch (type) {
index 1e453c913c1f2f56842e58a1faa47db4aebe0f42..e339fe9f5e1c55ab3ca361f57f8c9b9b74316864 100644 (file)
@@ -12,7 +12,7 @@ export {
   pipeToWebWritable,
   type SimpleReadable,
   // deprecated
-  renderToStream
+  renderToStream,
 } from './renderToStream'
 
 // internal runtime helpers
index 93919fcb04ee3c7da338b3b1f6c7e787f64ac1e5..3a2054066c3c89f7bb0c4310f552217270dcdf0b 100644 (file)
@@ -8,7 +8,7 @@ export {
   ssrRenderStyle,
   ssrRenderAttrs,
   ssrRenderAttr,
-  ssrRenderDynamicAttr
+  ssrRenderDynamicAttr,
 } from './helpers/ssrRenderAttrs'
 export { ssrInterpolate } from './helpers/ssrInterpolate'
 export { ssrRenderList } from './helpers/ssrRenderList'
@@ -21,5 +21,5 @@ export {
   ssrLooseEqual,
   ssrLooseContain,
   ssrRenderDynamicModel,
-  ssrGetDynamicModelProps
+  ssrGetDynamicModelProps,
 } from './helpers/ssrVModelHelpers'
index 011d0840386ba474da0c32de04c15c2b9b77d395..cd60c350942d4877341a34d23f46545d8d39d766 100644 (file)
@@ -1,29 +1,29 @@
 import {
   Comment,
-  Component,
-  ComponentInternalInstance,
-  DirectiveBinding,
+  type Component,
+  type ComponentInternalInstance,
+  type DirectiveBinding,
   Fragment,
-  FunctionalComponent,
-  mergeProps,
-  ssrUtils,
+  type FunctionalComponent,
   Static,
   Text,
-  VNode,
-  VNodeArrayChildren,
-  VNodeProps,
-  warn
+  type VNode,
+  type VNodeArrayChildren,
+  type VNodeProps,
+  mergeProps,
+  ssrUtils,
+  warn,
 } from 'vue'
 import {
+  NOOP,
+  ShapeFlags,
   escapeHtml,
   escapeHtmlComment,
+  isArray,
   isFunction,
   isPromise,
   isString,
   isVoidTag,
-  ShapeFlags,
-  isArray,
-  NOOP
 } from '@vue/shared'
 import { ssrRenderAttrs } from './helpers/ssrRenderAttrs'
 import { ssrCompile } from './helpers/ssrCompile'
@@ -34,7 +34,7 @@ const {
   setCurrentRenderingInstance,
   setupComponent,
   renderComponentRoot,
-  normalizeVNode
+  normalizeVNode,
 } = ssrUtils
 
 export type SSRBuffer = SSRBufferItem[] & { hasAsync?: boolean }
@@ -82,14 +82,14 @@ export function createBuffer() {
         // this allows skipping unnecessary await ticks during unroll stage
         buffer.hasAsync = true
       }
-    }
+    },
   }
 }
 
 export function renderComponentVNode(
   vnode: VNode,
   parentComponent: ComponentInternalInstance | null = null,
-  slotScopeId?: string
+  slotScopeId?: string,
 ): SSRBuffer | Promise<SSRBuffer> {
   const instance = createComponentInstance(vnode, parentComponent, null)
   const res = setupComponent(instance, true /* isSSR */)
@@ -102,7 +102,9 @@ export function renderComponentVNode(
     if (prefetches) {
       p = p
         .then(() =>
-          Promise.all(prefetches.map(prefetch => prefetch.call(instance.proxy)))
+          Promise.all(
+            prefetches.map(prefetch => prefetch.call(instance.proxy)),
+          ),
         )
         // Note: error display is already done by the wrapped lifecycle hook function.
         .catch(() => {})
@@ -115,7 +117,7 @@ export function renderComponentVNode(
 
 function renderComponentSubTree(
   instance: ComponentInternalInstance,
-  slotScopeId?: string
+  slotScopeId?: string,
 ): SSRBuffer | Promise<SSRBuffer> {
   const comp = instance.type as Component
   const { getBuffer, push } = createBuffer()
@@ -194,7 +196,7 @@ function renderComponentSubTree(
           instance.props,
           instance.setupState,
           instance.data,
-          instance.ctx
+          instance.ctx,
         )
       } finally {
         setCurrentRenderingInstance(prev)
@@ -204,7 +206,7 @@ function renderComponentSubTree(
         push,
         (instance.subTree = renderComponentRoot(instance)),
         instance,
-        slotScopeId
+        slotScopeId,
       )
     } else {
       const componentName = comp.name || comp.__file || `<Anonymous>`
@@ -219,7 +221,7 @@ export function renderVNode(
   push: PushFn,
   vnode: VNode,
   parentComponent: ComponentInternalInstance,
-  slotScopeId?: string
+  slotScopeId?: string,
 ) {
   const { type, shapeFlag, children } = vnode
   switch (type) {
@@ -228,7 +230,9 @@ export function renderVNode(
       break
     case Comment:
       push(
-        children ? `<!--${escapeHtmlComment(children as string)}-->` : `<!---->`
+        children
+          ? `<!--${escapeHtmlComment(children as string)}-->`
+          : `<!---->`,
       )
       break
     case Static:
@@ -244,7 +248,7 @@ export function renderVNode(
         push,
         children as VNodeArrayChildren,
         parentComponent,
-        slotScopeId
+        slotScopeId,
       )
       push(`<!--]-->`) // close
       break
@@ -261,7 +265,7 @@ export function renderVNode(
         warn(
           '[@vue/server-renderer] Invalid VNode type:',
           type,
-          `(${typeof type})`
+          `(${typeof type})`,
         )
       }
   }
@@ -271,7 +275,7 @@ export function renderVNodeChildren(
   push: PushFn,
   children: VNodeArrayChildren,
   parentComponent: ComponentInternalInstance,
-  slotScopeId: string | undefined
+  slotScopeId: string | undefined,
 ) {
   for (let i = 0; i < children.length; i++) {
     renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId)
@@ -282,7 +286,7 @@ function renderElementVNode(
   push: PushFn,
   vnode: VNode,
   parentComponent: ComponentInternalInstance,
-  slotScopeId: string | undefined
+  slotScopeId: string | undefined,
 ) {
   const tag = vnode.type as string
   let { props, children, shapeFlag, scopeId, dirs } = vnode
@@ -336,7 +340,7 @@ function renderElementVNode(
           push,
           children as VNodeArrayChildren,
           parentComponent,
-          slotScopeId
+          slotScopeId,
         )
       }
     }
@@ -347,13 +351,13 @@ function renderElementVNode(
 function applySSRDirectives(
   vnode: VNode,
   rawProps: VNodeProps | null,
-  dirs: DirectiveBinding[]
+  dirs: DirectiveBinding[],
 ): VNodeProps {
   const toMerge: VNodeProps[] = []
   for (let i = 0; i < dirs.length; i++) {
     const binding = dirs[i]
     const {
-      dir: { getSSRProps }
+      dir: { getSSRProps },
     } = binding
     if (getSSRProps) {
       const props = getSSRProps(binding, vnode)
@@ -367,7 +371,7 @@ function renderTeleportVNode(
   push: PushFn,
   vnode: VNode,
   parentComponent: ComponentInternalInstance,
-  slotScopeId: string | undefined
+  slotScopeId: string | undefined,
 ) {
   const target = vnode.props && vnode.props.to
   const disabled = vnode.props && vnode.props.disabled
@@ -379,7 +383,7 @@ function renderTeleportVNode(
   }
   if (!isString(target)) {
     warn(
-      `[@vue/server-renderer] Teleport target must be a query selector string.`
+      `[@vue/server-renderer] Teleport target must be a query selector string.`,
     )
     return []
   }
@@ -390,11 +394,11 @@ function renderTeleportVNode(
         push,
         vnode.children as VNodeArrayChildren,
         parentComponent,
-        slotScopeId
+        slotScopeId,
       )
     },
     target,
     disabled || disabled === '',
-    parentComponent
+    parentComponent,
   )
 }
index bdcdb0a026e1451d98db2d4ea8b9be241dccc284..c807b4a22362eefffc1277d1c67ceb5ef7dfc6b0 100644 (file)
@@ -1,14 +1,14 @@
 import {
-  App,
-  VNode,
+  type App,
+  type VNode,
+  createApp,
   createVNode,
+  ssrContextKey,
   ssrUtils,
-  createApp,
-  ssrContextKey
 } from 'vue'
-import { isString, isPromise } from '@vue/shared'
-import { renderComponentVNode, SSRBuffer, SSRContext } from './render'
-import { Readable, Writable } from 'stream'
+import { isPromise, isString } from '@vue/shared'
+import { type SSRBuffer, type SSRContext, renderComponentVNode } from './render'
+import type { Readable, Writable } from 'node:stream'
 import { resolveTeleports } from './renderToString'
 
 const { isVNode } = ssrUtils
@@ -20,7 +20,7 @@ export interface SimpleReadable {
 
 async function unrollBuffer(
   buffer: SSRBuffer,
-  stream: SimpleReadable
+  stream: SimpleReadable,
 ): Promise<void> {
   if (buffer.hasAsync) {
     for (let i = 0; i < buffer.length; i++) {
@@ -56,14 +56,14 @@ function unrollBufferSync(buffer: SSRBuffer, stream: SimpleReadable) {
 export function renderToSimpleStream<T extends SimpleReadable>(
   input: App | VNode,
   context: SSRContext,
-  stream: T
+  stream: T,
 ): T {
   if (isVNode(input)) {
     // raw vnode, wrap with app (for context)
     return renderToSimpleStream(
       createApp({ render: () => input }),
       context,
-      stream
+      stream,
     )
   }
 
@@ -96,27 +96,27 @@ export function renderToSimpleStream<T extends SimpleReadable>(
  */
 export function renderToStream(
   input: App | VNode,
-  context: SSRContext = {}
+  context: SSRContext = {},
 ): Readable {
   console.warn(
-    `[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
+    `[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`,
   )
   return renderToNodeStream(input, context)
 }
 
 export function renderToNodeStream(
   input: App | VNode,
-  context: SSRContext = {}
+  context: SSRContext = {},
 ): Readable {
   const stream: Readable = __NODE_JS__
-    ? new (require('stream').Readable)({ read() {} })
+    ? new (require('node:stream').Readable)({ read() {} })
     : null
 
   if (!stream) {
     throw new Error(
       `ESM build of renderToStream() does not support renderToNodeStream(). ` +
         `Use pipeToNodeWritable() with an existing Node.js Writable stream ` +
-        `instance instead.`
+        `instance instead.`,
     )
   }
 
@@ -126,7 +126,7 @@ export function renderToNodeStream(
 export function pipeToNodeWritable(
   input: App | VNode,
   context: SSRContext = {},
-  writable: Writable
+  writable: Writable,
 ) {
   renderToSimpleStream(input, context, {
     push(content) {
@@ -138,19 +138,19 @@ export function pipeToNodeWritable(
     },
     destroy(err) {
       writable.destroy(err)
-    }
+    },
   })
 }
 
 export function renderToWebStream(
   input: App | VNode,
-  context: SSRContext = {}
+  context: SSRContext = {},
 ): ReadableStream {
   if (typeof ReadableStream !== 'function') {
     throw new Error(
       `ReadableStream constructor is not available in the global scope. ` +
         `If the target environment does support web streams, consider using ` +
-        `pipeToWebWritable() with an existing WritableStream instance instead.`
+        `pipeToWebWritable() with an existing WritableStream instance instead.`,
     )
   }
 
@@ -170,19 +170,19 @@ export function renderToWebStream(
         },
         destroy(err) {
           controller.error(err)
-        }
+        },
       })
     },
     cancel() {
       cancelled = true
-    }
+    },
   })
 }
 
 export function pipeToWebWritable(
   input: App | VNode,
   context: SSRContext = {},
-  writable: WritableStream
+  writable: WritableStream,
 ): void {
   const writer = writable.getWriter()
   const encoder = new TextEncoder()
@@ -208,6 +208,6 @@ export function pipeToWebWritable(
       // TODO better error handling?
       console.log(err)
       writer.close()
-    }
+    },
   })
 }
index 2fdc39f681676cb4282c0c15ef4e45cb4b01021c..0e9299ee834e1567b644689399536446bcc6aecb 100644 (file)
@@ -1,13 +1,13 @@
 import {
-  App,
+  type App,
+  type VNode,
   createApp,
   createVNode,
   ssrContextKey,
   ssrUtils,
-  VNode
 } from 'vue'
 import { isPromise, isString } from '@vue/shared'
-import { SSRContext, renderComponentVNode, SSRBuffer } from './render'
+import { type SSRBuffer, type SSRContext, renderComponentVNode } from './render'
 
 const { isVNode } = ssrUtils
 
@@ -49,7 +49,7 @@ function unrollBufferSync(buffer: SSRBuffer): string {
 
 export async function renderToString(
   input: App | VNode,
-  context: SSRContext = {}
+  context: SSRContext = {},
 ): Promise<string> {
   if (isVNode(input)) {
     // raw vnode, wrap with app (for context)
@@ -83,7 +83,7 @@ export async function resolveTeleports(context: SSRContext) {
       // note: it's OK to await sequentially here because the Promises were
       // created eagerly in parallel.
       context.teleports[key] = await unrollBuffer(
-        await Promise.all([context.__teleportBuffers[key]])
+        await Promise.all([context.__teleportBuffers[key]]),
       )
     }
   }
index e1a279de638ae950bc95f8e66bdb7257fecdaabd..1a484cc480115bf18ccadb3cf2d47f2dfb2e6d90 100644 (file)
@@ -10,11 +10,11 @@ const EditorComponent = shallowRef<typeof Monaco | typeof CodeMirror>()
 
 if (import.meta.env.DEV) {
   import('@vue/repl/codemirror-editor').then(
-    mod => (EditorComponent.value = mod.default)
+    mod => (EditorComponent.value = mod.default),
   )
 } else {
   import('@vue/repl/monaco-editor').then(
-    mod => (EditorComponent.value = mod.default)
+    mod => (EditorComponent.value = mod.default),
   )
 }
 
@@ -54,7 +54,7 @@ const store = new ReplStore({
     : `${location.origin}/src/vue-dev-proxy-prod`,
   defaultVueServerRendererURL: import.meta.env.PROD
     ? `${location.origin}/server-renderer.esm-browser.js`
-    : `${location.origin}/src/vue-server-renderer-dev-proxy`
+    : `${location.origin}/src/vue-server-renderer-dev-proxy`,
 })
 
 // enable experimental features
@@ -62,14 +62,14 @@ const sfcOptions: SFCOptions = {
   script: {
     inlineTemplate: useProdMode.value,
     isProd: useProdMode.value,
-    propsDestructure: true
+    propsDestructure: true,
   },
   style: {
-    isProd: useProdMode.value
+    isProd: useProdMode.value,
   },
   template: {
-    isProd: useProdMode.value
-  }
+    isProd: useProdMode.value,
+  },
 }
 
 // persist state
index 33da636b9c99b18ff3068d9a4c1d639dd8a6d6a2..49e370e6c3091c6951f4d1ceeaa4113856b8fee5 100644 (file)
@@ -19,7 +19,7 @@ const emit = defineEmits([
   'toggle-theme',
   'toggle-ssr',
   'toggle-prod',
-  'reload-page'
+  'reload-page',
 ])
 
 const { store } = props
@@ -53,7 +53,7 @@ function toggleDark() {
   cls.toggle('dark')
   localStorage.setItem(
     'vue-sfc-playground-prefer-dark',
-    String(cls.contains('dark'))
+    String(cls.contains('dark')),
   )
   emit('toggle-theme', cls.contains('dark'))
 }
index 0c4a37138e5fa718606850852ce3ba5f31822c35..50c3c59ac24f6d8fe58412d3b91a324fdf7222e5 100644 (file)
@@ -19,7 +19,7 @@ async function toggle() {
 
 async function fetchVersions(): Promise<string[]> {
   const res = await fetch(
-    `https://data.jsdelivr.com/v1/package/npm/${props.pkg}`
+    `https://data.jsdelivr.com/v1/package/npm/${props.pkg}`,
   )
   const { versions } = (await res.json()) as { versions: string[] }
 
index eb534538bf29cc39b5a795b85141de521c3849b5..f981134a701f66ed7038f21c7f138dbf7efb042c 100644 (file)
@@ -5,7 +5,7 @@ import main from './template/main.js?raw'
 import pkg from './template/package.json?raw'
 import config from './template/vite.config.js?raw'
 import readme from './template/README.md?raw'
-import { ReplStore } from '@vue/repl'
+import type { ReplStore } from '@vue/repl'
 
 export async function downloadProject(store: ReplStore) {
   if (!confirm('Download project files?')) {
index 315212d69a7ba5cc02f13ef35b14a8010fe04319..05c17402a4a92b87397786592fc5135e13b7a666 100644 (file)
@@ -3,5 +3,5 @@ import vue from '@vitejs/plugin-vue'
 
 // https://vitejs.dev/config/
 export default defineConfig({
-  plugins: [vue()]
+  plugins: [vue()],
 })
index cc2506a787d766714bcbffa740e3a404244a9079..2a6aaf62dd26ccf08c460463ec1c37c07a9794a0 100644 (file)
@@ -1,6 +1,7 @@
 <template>
   <svg width="1.7em" height="1.7em" viewBox="0 0 24 24" fill="currentColor">
     <path
-        d="M10.9,2.1c-4.6,0.5-8.3,4.2-8.8,8.7c-0.5,4.7,2.2,8.9,6.3,10.5C8.7,21.4,9,21.2,9,20.8v-1.6c0,0-0.4,0.1-0.9,0.1 c-1.4,0-2-1.2-2.1-1.9c-0.1-0.4-0.3-0.7-0.6-1C5.1,16.3,5,16.3,5,16.2C5,16,5.3,16,5.4,16c0.6,0,1.1,0.7,1.3,1c0.5,0.8,1.1,1,1.4,1 c0.4,0,0.7-0.1,0.9-0.2c0.1-0.7,0.4-1.4,1-1.8c-2.3-0.5-4-1.8-4-4c0-1.1,0.5-2.2,1.2-3C7.1,8.8,7,8.3,7,7.6C7,7.2,7,6.6,7.3,6 c0,0,1.4,0,2.8,1.3C10.6,7.1,11.3,7,12,7s1.4,0.1,2,0.3C15.3,6,16.8,6,16.8,6C17,6.6,17,7.2,17,7.6c0,0.8-0.1,1.2-0.2,1.4 c0.7,0.8,1.2,1.8,1.2,3c0,2.2-1.7,3.5-4,4c0.6,0.5,1,1.4,1,2.3v2.6c0,0.3,0.3,0.6,0.7,0.5c3.7-1.5,6.3-5.1,6.3-9.3 C22,6.1,16.9,1.4,10.9,2.1z"/>
+      d="M10.9,2.1c-4.6,0.5-8.3,4.2-8.8,8.7c-0.5,4.7,2.2,8.9,6.3,10.5C8.7,21.4,9,21.2,9,20.8v-1.6c0,0-0.4,0.1-0.9,0.1 c-1.4,0-2-1.2-2.1-1.9c-0.1-0.4-0.3-0.7-0.6-1C5.1,16.3,5,16.3,5,16.2C5,16,5.3,16,5.4,16c0.6,0,1.1,0.7,1.3,1c0.5,0.8,1.1,1,1.4,1 c0.4,0,0.7-0.1,0.9-0.2c0.1-0.7,0.4-1.4,1-1.8c-2.3-0.5-4-1.8-4-4c0-1.1,0.5-2.2,1.2-3C7.1,8.8,7,8.3,7,7.6C7,7.2,7,6.6,7.3,6 c0,0,1.4,0,2.8,1.3C10.6,7.1,11.3,7,12,7s1.4,0.1,2,0.3C15.3,6,16.8,6,16.8,6C17,6.6,17,7.2,17,7.6c0,0.8-0.1,1.2-0.2,1.4 c0.7,0.8,1.2,1.8,1.2,3c0,2.2-1.7,3.5-4,4c0.6,0.5,1,1.4,1,2.3v2.6c0,0.3,0.3,0.6,0.7,0.5c3.7-1.5,6.3-5.1,6.3-9.3 C22,6.1,16.9,1.4,10.9,2.1z"
+    />
   </svg>
 </template>
index 30c6eb515f19d13334db423160f31a8715783d98..21f393d4d6efdd73ddc9d82c6050f05f807e03b8 100644 (file)
@@ -1,5 +1,8 @@
 <template>
   <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
-    <path fill="currentColor" d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z" />
+    <path
+      fill="currentColor"
+      d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"
+    />
   </svg>
 </template>
index c38ba0899424946978a4a6fabf6505f2cface937..5ec5be80889f928c60682bf76c0ed1376e907cd2 100644 (file)
@@ -1,6 +1,14 @@
 <template>
-  <svg fill="currentColor" width="1.7em" height="1.7em" viewBox="0 0 24 24"  xmlns="http://www.w3.org/2000/svg">
-    <path d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"/>
-    <path d="M0 0h24v24H0z" fill="none"/>
+  <svg
+    fill="currentColor"
+    width="1.7em"
+    height="1.7em"
+    viewBox="0 0 24 24"
+    xmlns="http://www.w3.org/2000/svg"
+  >
+    <path
+      d="M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
+    />
+    <path d="M0 0h24v24H0z" fill="none" />
   </svg>
 </template>
index 4e4b1f409f934bcb4756c865d6c0630f9ed4b708..4b73922421a753f04f0db670ae948f02a04f4805 100644 (file)
@@ -1,13 +1,40 @@
 <template>
   <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
-    <path fill="currentColor" d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z" />
-    <path fill="currentColor" d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z" />
-    <path fill="currentColor" d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z" />
-    <path fill="currentColor" d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z" />
-    <path fill="currentColor" d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z" />
-    <path fill="currentColor" d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z" />
-    <path fill="currentColor" d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z" />
-    <path fill="currentColor" d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z" />
-    <path fill="currentColor" d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z" />
+    <path
+      fill="currentColor"
+      d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"
+    />
+    <path
+      fill="currentColor"
+      d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"
+    />
+    <path
+      fill="currentColor"
+      d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"
+    />
+    <path
+      fill="currentColor"
+      d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"
+    />
+    <path
+      fill="currentColor"
+      d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"
+    />
+    <path
+      fill="currentColor"
+      d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"
+    />
+    <path
+      fill="currentColor"
+      d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"
+    />
+    <path
+      fill="currentColor"
+      d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"
+    />
+    <path
+      fill="currentColor"
+      d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"
+    />
   </svg>
 </template>
index 2e7bc652865ec3ff7039592d14113986a0e75bae..7be63408035931b79b5dd5fa53a6c4426907d90b 100644 (file)
@@ -3,7 +3,7 @@ import App from './App.vue'
 
 // @ts-expect-error Custom window property
 window.VUE_DEVTOOLS_CONFIG = {
-  defaultSelectedAppId: 'repl'
+  defaultSelectedAppId: 'repl',
 }
 
 createApp(App).mount('#app')
index ad796cab5bc8c71ffe3f3b1dcb19b0504cc54634..c20c51579a46c6ed035abfd238bc77408c863ae3 100644 (file)
@@ -1,3 +1,3 @@
 // serve vue to the iframe sandbox during dev.
-// @ts-ignore
+// @ts-expect-error
 export * from 'vue/dist/vue.runtime.esm-browser.prod.js'
index 54db67b9818b511fbe3caba6ae627f6733ae9e9d..e30078f4b790787dbdf102a72b39b206caa8b5d0 100644 (file)
@@ -1,6 +1,6 @@
-import fs from 'fs'
-import path from 'path'
-import { defineConfig, Plugin } from 'vite'
+import fs from 'node:fs'
+import path from 'node:path'
+import { type Plugin, defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import { execaSync } from 'execa'
 
@@ -12,19 +12,19 @@ export default defineConfig({
       script: {
         fs: {
           fileExists: fs.existsSync,
-          readFile: file => fs.readFileSync(file, 'utf-8')
-        }
-      }
+          readFile: file => fs.readFileSync(file, 'utf-8'),
+        },
+      },
     }),
-    copyVuePlugin()
+    copyVuePlugin(),
   ],
   define: {
     __COMMIT__: JSON.stringify(commit),
-    __VUE_PROD_DEVTOOLS__: JSON.stringify(true)
+    __VUE_PROD_DEVTOOLS__: JSON.stringify(true),
   },
   optimizeDeps: {
-    exclude: ['@vue/repl']
-  }
+    exclude: ['@vue/repl'],
+  },
 })
 
 function copyVuePlugin(): Plugin {
@@ -37,13 +37,13 @@ function copyVuePlugin(): Plugin {
         if (!fs.existsSync(filePath)) {
           throw new Error(
             `${basename} not built. ` +
-              `Run "nr build vue -f esm-browser" first.`
+              `Run "nr build vue -f esm-browser" first.`,
           )
         }
         this.emitFile({
           type: 'asset',
           fileName: basename,
-          source: fs.readFileSync(filePath, 'utf-8')
+          source: fs.readFileSync(filePath, 'utf-8'),
         })
       }
 
@@ -52,6 +52,6 @@ function copyVuePlugin(): Plugin {
       copyFile(`../vue/dist/vue.runtime.esm-browser.js`)
       copyFile(`../vue/dist/vue.runtime.esm-browser.prod.js`)
       copyFile(`../server-renderer/dist/server-renderer.esm-browser.js`)
-    }
+    },
   }
 }
index 5083100485d32febaf9709bc7f30c52aab5d7b3d..addae82c90848279855ac3c69351cf5dd07996c8 100644 (file)
@@ -75,7 +75,7 @@ attr
       const keyEnd =
         windowsNewLineSource.indexOf(endToken, keyStart) + endToken.length
       expect(
-        generateCodeFrame(windowsNewLineSource, keyStart, keyEnd)
+        generateCodeFrame(windowsNewLineSource, keyStart, keyEnd),
       ).toMatchSnapshot()
     })
 
@@ -84,7 +84,7 @@ attr
       const keyEnd =
         unixNewlineSource.indexOf(endToken, keyStart) + endToken.length
       expect(
-        generateCodeFrame(unixNewlineSource, keyStart, keyEnd)
+        generateCodeFrame(unixNewlineSource, keyStart, keyEnd),
       ).toMatchSnapshot()
     })
   }
index 67b69dd76d48314b3212f709bee779d419c76f21..2dea58ce5869e5724a8cd2522613220310b465dc 100644 (file)
@@ -69,27 +69,27 @@ describe('utils/looseEqual', () => {
     const date2 = new Date(2019, 1, 2, 3, 4, 5, 7)
     const file1 = new File([''], 'filename.txt', {
       type: 'text/plain',
-      lastModified: date1.getTime()
+      lastModified: date1.getTime(),
     })
     const file2 = new File([''], 'filename.txt', {
       type: 'text/plain',
-      lastModified: date1.getTime()
+      lastModified: date1.getTime(),
     })
     const file3 = new File([''], 'filename.txt', {
       type: 'text/plain',
-      lastModified: date2.getTime()
+      lastModified: date2.getTime(),
     })
     const file4 = new File([''], 'filename.csv', {
       type: 'text/csv',
-      lastModified: date1.getTime()
+      lastModified: date1.getTime(),
     })
     const file5 = new File(['abcdef'], 'filename.txt', {
       type: 'text/plain',
-      lastModified: date1.getTime()
+      lastModified: date1.getTime(),
     })
     const file6 = new File(['12345'], 'filename.txt', {
       type: 'text/plain',
-      lastModified: date1.getTime()
+      lastModified: date1.getTime(),
     })
 
     // Identical file object references
@@ -178,7 +178,7 @@ describe('utils/looseEqual', () => {
     const date1 = new Date(2019, 1, 2, 3, 4, 5, 6)
     const file1 = new File([''], 'filename.txt', {
       type: 'text/plain',
-      lastModified: date1.getTime()
+      lastModified: date1.getTime(),
     })
 
     expect(looseEqual(123, '123')).toBe(true)
index bf9cf7e33be1df36460d143cc36d11483452fb1d..4e5736af46fd75a9e057f7178a2ef041407c7132 100644 (file)
@@ -11,7 +11,7 @@ describe('normalizeClass', () => {
 
   test('handles array correctly', () => {
     expect(normalizeClass(['foo', undefined, true, false, 'bar'])).toEqual(
-      'foo bar'
+      'foo bar',
     )
   })
 
@@ -25,7 +25,7 @@ describe('normalizeClass', () => {
 
   test('handles object correctly', () => {
     expect(normalizeClass({ foo: true, bar: false, baz: true })).toEqual(
-      'foo baz'
+      'foo baz',
     )
   })
 
@@ -35,7 +35,7 @@ describe('normalizeClass', () => {
 
   test('handles arrays and objects correctly', () => {
     expect(
-      normalizeClass(['foo', ['bar'], { baz: true }, [{ qux: true }]])
+      normalizeClass(['foo', ['bar'], { baz: true }, [{ qux: true }]]),
     ).toEqual('foo bar baz qux')
   })
 
@@ -48,8 +48,8 @@ describe('normalizeClass', () => {
         { qux: '' },
         { quux: null },
         { corge: undefined },
-        { grault: NaN }
-      ])
+        { grault: NaN },
+      ]),
     ).toEqual('')
   })
 
@@ -60,8 +60,8 @@ describe('normalizeClass', () => {
         { bar: 'not-empty' },
         { baz: 1 },
         { qux: {} },
-        { quux: [] }
-      ])
+        { quux: [] },
+      ]),
     ).toEqual('foo bar baz qux quux')
   })
 
@@ -76,7 +76,7 @@ describe('normalizeClass', () => {
         #ccc 0.5em,
         white 0,
         white 0.75em
-      );`)
+      );`),
     ).toMatchInlineSnapshot(`
       {
         "background": "linear-gradient(white, white) padding-box,
index 3b02911b8f0ef914e2faaa5c7596befa0525b429..ef5030239b405a05cb03d53856666a67fd03bc6b 100644 (file)
@@ -27,19 +27,19 @@ describe('toDisplayString', () => {
       foo: 555,
       toString() {
         return 'override'
-      }
+      },
     }
     expect(toDisplayString(objWithToStringOverride)).toBe('override')
 
     const objWithNonInvokableToString = {
       foo: 555,
-      toString: null
+      toString: null,
     }
     expect(toDisplayString(objWithNonInvokableToString)).toBe(
       `{
   "foo": 555,
   "toString": null
-}`
+}`,
     )
 
     // object created from null does not have .toString in its prototype
@@ -48,7 +48,7 @@ describe('toDisplayString', () => {
     expect(toDisplayString(nullObjectWithoutToString)).toBe(
       `{
   "bar": 1
-}`
+}`,
     )
 
     // array toString override is ignored
@@ -60,7 +60,7 @@ describe('toDisplayString', () => {
   1,
   2,
   3
-]`
+]`,
     )
   })
 
@@ -70,8 +70,8 @@ describe('toDisplayString', () => {
     expect(
       toDisplayString({
         n,
-        np
-      })
+        np,
+      }),
     ).toBe(JSON.stringify({ n: 1, np: 2 }, null, 2))
   })
 
@@ -100,7 +100,7 @@ describe('toDisplayString', () => {
   test('Map and Set', () => {
     const m = new Map<any, any>([
       [1, 'foo'],
-      [{ baz: 1 }, { foo: 'bar', qux: 2 }]
+      [{ baz: 1 }, { foo: 'bar', qux: 2 }],
     ])
     const s = new Set<any>([1, { foo: 'bar' }, m])
 
@@ -138,8 +138,8 @@ describe('toDisplayString', () => {
     expect(
       toDisplayString({
         m,
-        s
-      })
+        s,
+      }),
     ).toMatchInlineSnapshot(`
       "{
         "m": {
@@ -177,7 +177,7 @@ describe('toDisplayString', () => {
     const m = new Map<any, any>([
       [Symbol(), 'foo'],
       [Symbol(), 'bar'],
-      [Symbol('baz'), 'baz']
+      [Symbol('baz'), 'baz'],
     ])
     expect(toDisplayString(m)).toMatchInlineSnapshot(`
       "{
@@ -190,7 +190,7 @@ describe('toDisplayString', () => {
     `)
     // confirming the symbol renders Symbol(foo)
     expect(toDisplayString(new Map([[Symbol('foo'), 'foo']]))).toContain(
-      String(Symbol('foo'))
+      String(Symbol('foo')),
     )
   })
 
index 82b38bfb33085d3f2684c1956a40c9af293ef8fe..af7212166eecb6b815ad67f94fe7932d24ad8f25 100644 (file)
@@ -3,7 +3,7 @@ const range: number = 2
 export function generateCodeFrame(
   source: string,
   start = 0,
-  end = source.length
+  end = source.length,
 ): string {
   // Split the content into individual lines but capture the newline sequence
   // that separated each line. This is important because the actual sequence is
@@ -28,7 +28,7 @@ export function generateCodeFrame(
         res.push(
           `${line}${' '.repeat(Math.max(3 - String(line).length, 0))}|  ${
             lines[j]
-          }`
+          }`,
         )
         const lineLength = lines[j].length
         const newLineSeqLength =
@@ -39,7 +39,7 @@ export function generateCodeFrame(
           const pad = start - (count - (lineLength + newLineSeqLength))
           const length = Math.max(
             1,
-            end > count ? lineLength - pad : end - start
+            end > count ? lineLength - pad : end - start,
           )
           res.push(`   |  ` + ' '.repeat(pad) + '^'.repeat(length))
         } else if (j > i) {
index 9a0f88b94de375f47eb2d255ae49464f1928c180..a34eb3260ce227a45c3a1f733fe38546b759f90c 100644 (file)
@@ -21,7 +21,7 @@ export const isBooleanAttr = /*#__PURE__*/ makeMap(
   specialBooleanAttrs +
     `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +
     `inert,loop,open,required,reversed,scoped,seamless,` +
-    `checked,muted,multiple,selected`
+    `checked,muted,multiple,selected`,
 )
 
 /**
@@ -50,7 +50,7 @@ export const propsToAttrMap: Record<string, string | undefined> = {
   acceptCharset: 'accept-charset',
   className: 'class',
   htmlFor: 'for',
-  httpEquiv: 'http-equiv'
+  httpEquiv: 'http-equiv',
 }
 
 /**
@@ -74,7 +74,7 @@ export const isKnownHtmlAttr = /*#__PURE__*/ makeMap(
     `referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,` +
     `selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,` +
     `start,step,style,summary,tabindex,target,title,translate,type,usemap,` +
-    `value,width,wrap`
+    `value,width,wrap`,
 )
 
 /**
@@ -119,5 +119,5 @@ export const isKnownSvgAttr = /*#__PURE__*/ makeMap(
     `vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,` +
     `writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,` +
     `xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,` +
-    `xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
+    `xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`,
 )
index dcde4c8c6cc98b27b0d5d4844d3fa33718cdacb0..e04b961227adf545099818c2706cc59210323a34 100644 (file)
@@ -32,7 +32,7 @@ export const remove = <T>(arr: T[], el: T) => {
 const hasOwnProperty = Object.prototype.hasOwnProperty
 export const hasOwn = (
   val: object,
-  key: string | symbol
+  key: string | symbol,
 ): key is keyof typeof val => hasOwnProperty.call(val, key)
 
 export const isArray = Array.isArray
@@ -83,11 +83,11 @@ export const isReservedProp = /*#__PURE__*/ makeMap(
   ',key,ref,ref_for,ref_key,' +
     'onVnodeBeforeMount,onVnodeMounted,' +
     'onVnodeBeforeUpdate,onVnodeUpdated,' +
-    'onVnodeBeforeUnmount,onVnodeUnmounted'
+    'onVnodeBeforeUnmount,onVnodeUnmounted',
 )
 
 export const isBuiltInDirective = /*#__PURE__*/ makeMap(
-  'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo'
+  'bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo',
 )
 
 const cacheStringFunction = <T extends (str: string) => string>(fn: T): T => {
@@ -111,7 +111,7 @@ const hyphenateRE = /\B([A-Z])/g
  * @private
  */
 export const hyphenate = cacheStringFunction((str: string) =>
-  str.replace(hyphenateRE, '-$1').toLowerCase()
+  str.replace(hyphenateRE, '-$1').toLowerCase(),
 )
 
 /**
@@ -143,7 +143,7 @@ export const def = (obj: object, key: string | symbol, value: any) => {
   Object.defineProperty(obj, key, {
     configurable: true,
     enumerable: false,
-    value
+    value,
   })
 }
 
index 9c4180c1e7a44061249825e6849b782957fe28c0..f11cc407c6f4a236aec64a8da514a28236768be0 100644 (file)
@@ -7,7 +7,7 @@
  */
 export function makeMap(
   str: string,
-  expectsLowerCase?: boolean
+  expectsLowerCase?: boolean,
 ): (key: string) => boolean {
   const set = new Set(str.split(','))
   return expectsLowerCase
index 10d54c6b51ad5cecaa23a4c1f2864e457490425e..07e782d44f1376b85552bb5e732b0854408cd7b3 100644 (file)
@@ -1,9 +1,9 @@
-import { isArray, isString, isObject, hyphenate } from './general'
+import { hyphenate, isArray, isObject, isString } from './general'
 
 export type NormalizedStyle = Record<string, string | number>
 
 export function normalizeStyle(
-  value: unknown
+  value: unknown,
 ): NormalizedStyle | string | undefined {
   if (isArray(value)) {
     const res: NormalizedStyle = {}
@@ -43,7 +43,7 @@ export function parseStringStyle(cssText: string): NormalizedStyle {
 }
 
 export function stringifyStyle(
-  styles: NormalizedStyle | string | undefined
+  styles: NormalizedStyle | string | undefined,
 ): string {
   let ret = ''
   if (!styles || isString(styles)) {
index 49ee70dc21c9a0660343369cd5f293d9451d21c2..009b714737feb0ebfbc9fb87c8479f5420855fed 100644 (file)
@@ -120,7 +120,7 @@ export enum PatchFlags {
    * render functions, which should always be fully diffed)
    * OR manually cloneVNodes
    */
-  BAIL = -2
+  BAIL = -2,
 }
 
 /**
@@ -140,5 +140,5 @@ export const PatchFlagNames: Record<PatchFlags, string> = {
   [PatchFlags.DYNAMIC_SLOTS]: `DYNAMIC_SLOTS`,
   [PatchFlags.DEV_ROOT_FRAGMENT]: `DEV_ROOT_FRAGMENT`,
   [PatchFlags.HOISTED]: `HOISTED`,
-  [PatchFlags.BAIL]: `BAIL`
+  [PatchFlags.BAIL]: `BAIL`,
 }
index 84825c7f198f0ff66348bdf1dac196e3167dc588..855d159ea5914acc71b1609b775491419ab7b9af 100644 (file)
@@ -9,5 +9,5 @@ export enum ShapeFlags {
   SUSPENSE = 1 << 7,
   COMPONENT_SHOULD_KEEP_ALIVE = 1 << 8,
   COMPONENT_KEPT_ALIVE = 1 << 9,
-  COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT
+  COMPONENT = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT,
 }
index 805c7d7c69380b9633864f11101ba20cb62ac967..e7892343d5c2bac4e4634a4cc8483974c7104704 100644 (file)
@@ -17,7 +17,7 @@ export enum SlotFlags {
    * received. This has to be refined at runtime, when the child's vnode
    * is being created (in `normalizeChildren`)
    */
-  FORWARDED = 3
+  FORWARDED = 3,
 }
 
 /**
@@ -26,5 +26,5 @@ export enum SlotFlags {
 export const slotFlagsText = {
   [SlotFlags.STABLE]: 'STABLE',
   [SlotFlags.DYNAMIC]: 'DYNAMIC',
-  [SlotFlags.FORWARDED]: 'FORWARDED'
+  [SlotFlags.FORWARDED]: 'FORWARDED',
 }
index efef5ff4dead660fda354f9494f49caa148b0f37..aff107cd97fabc5201674e2ece7c946c1bf99596 100644 (file)
@@ -1,13 +1,13 @@
 import {
   isArray,
+  isFunction,
   isMap,
   isObject,
-  isFunction,
   isPlainObject,
   isSet,
-  objectToString,
   isString,
-  isSymbol
+  isSymbol,
+  objectToString,
 } from './general'
 
 /**
@@ -37,12 +37,12 @@ const replacer = (_key: string, val: any): any => {
           entries[stringifySymbol(key, i) + ' =>'] = val
           return entries
         },
-        {} as Record<string, any>
-      )
+        {} as Record<string, any>,
+      ),
     }
   } else if (isSet(val)) {
     return {
-      [`Set(${val.size})`]: [...val.values()].map(v => stringifySymbol(v))
+      [`Set(${val.size})`]: [...val.values()].map(v => stringifySymbol(v)),
     }
   } else if (isSymbol(val)) {
     return stringifySymbol(val)
index 9faeb0a59f6937a7dc1b0478ef18e62a152c7e31..988712d623ca076144afcce0c4bc55c686d3c399 100644 (file)
@@ -1,11 +1,15 @@
-import * as m from 'monaco-editor'
-import { compile, CompilerError, CompilerOptions } from '@vue/compiler-dom'
+import type * as m from 'monaco-editor'
+import {
+  type CompilerError,
+  type CompilerOptions,
+  compile,
+} from '@vue/compiler-dom'
 import { compile as ssrCompile } from '@vue/compiler-ssr'
 import {
-  defaultOptions,
   compilerOptions,
+  defaultOptions,
   initOptions,
-  ssrMode
+  ssrMode,
 } from './options'
 import { toRaw, watchEffect } from '@vue/runtime-dom'
 import { SourceMapConsumer } from 'source-map-js'
@@ -30,8 +34,8 @@ const sharedEditorOptions: m.editor.IStandaloneEditorConstructionOptions = {
   scrollBeyondLastLine: false,
   renderWhitespace: 'selection',
   minimap: {
-    enabled: false
-  }
+    enabled: false,
+  },
 }
 
 window.init = () => {
@@ -48,13 +52,13 @@ window.init = () => {
       hash = escape(atob(hash))
     } catch (e) {}
     persistedState = JSON.parse(
-      decodeURIComponent(hash) || localStorage.getItem('state') || `{}`
+      decodeURIComponent(hash) || localStorage.getItem('state') || `{}`,
     )
   } catch (e: any) {
     // bad stored state, clear it
     console.warn(
       'Persisted state in localStorage seems to be corrupted, please reload.\n' +
-        e.message
+        e.message,
     )
     localStorage.clear()
   }
@@ -81,13 +85,13 @@ window.init = () => {
         sourceMap: true,
         onError: err => {
           errors.push(err)
-        }
+        },
       })
       console.log(`Compiled in ${(performance.now() - start).toFixed(2)}ms.`)
       monaco.editor.setModelMarkers(
         editor.getModel()!,
         `@vue/compiler-dom`,
-        errors.filter(e => e.loc).map(formatError)
+        errors.filter(e => e.loc).map(formatError),
       )
       console.log(`AST: `, ast)
       console.log(`Options: `, toRaw(compilerOptions))
@@ -110,7 +114,7 @@ window.init = () => {
       endLineNumber: loc.end.line,
       endColumn: loc.end.column,
       message: `Vue template compilation error: ${err.message}`,
-      code: String(err.code)
+      code: String(err.code),
     }
   }
 
@@ -123,7 +127,7 @@ window.init = () => {
     for (key in compilerOptions) {
       const val = compilerOptions[key]
       if (typeof val !== 'object' && val !== defaultOptions[key]) {
-        // @ts-ignore
+        // @ts-expect-error
         optionsToSave[key] = val
       }
     }
@@ -131,7 +135,7 @@ window.init = () => {
     const state = JSON.stringify({
       src,
       ssr: ssrMode.value,
-      options: optionsToSave
+      options: optionsToSave,
     } as PersistedState)
     localStorage.setItem('state', state)
     window.location.hash = btoa(unescape(encodeURIComponent(state)))
@@ -145,21 +149,21 @@ window.init = () => {
     value: persistedState?.src || `<div>Hello World</div>`,
     language: 'html',
     ...sharedEditorOptions,
-    wordWrap: 'bounded'
+    wordWrap: 'bounded',
   })
 
   editor.getModel()!.updateOptions({
-    tabSize: 2
+    tabSize: 2,
   })
 
   const output = monaco.editor.create(document.getElementById('output')!, {
     value: '',
     language: 'javascript',
     readOnly: true,
-    ...sharedEditorOptions
+    ...sharedEditorOptions,
   })
   output.getModel()!.updateOptions({
-    tabSize: 2
+    tabSize: 2,
   })
 
   // handle resize
@@ -184,7 +188,7 @@ window.init = () => {
         const pos = lastSuccessfulMap.generatedPositionFor({
           source: 'ExampleTemplate.vue',
           line: e.position.lineNumber,
-          column: e.position.column - 1
+          column: e.position.column - 1,
         })
         if (pos.line != null && pos.column != null) {
           prevOutputDecos = output.deltaDecorations(prevOutputDecos, [
@@ -193,22 +197,22 @@ window.init = () => {
                 pos.line,
                 pos.column + 1,
                 pos.line,
-                pos.lastColumn ? pos.lastColumn + 2 : pos.column + 2
+                pos.lastColumn ? pos.lastColumn + 2 : pos.column + 2,
               ),
               options: {
-                inlineClassName: `highlight`
-              }
-            }
+                inlineClassName: `highlight`,
+              },
+            },
           ])
           output.revealPositionInCenter({
             lineNumber: pos.line,
-            column: pos.column + 1
+            column: pos.column + 1,
           })
         } else {
           clearOutputDecos()
         }
       }
-    }, 100)
+    }, 100),
   )
 
   let previousEditorDecos: string[] = []
@@ -222,7 +226,7 @@ window.init = () => {
       if (lastSuccessfulMap) {
         const pos = lastSuccessfulMap.originalPositionFor({
           line: e.position.lineNumber,
-          column: e.position.column - 1
+          column: e.position.column - 1,
         })
         if (
           pos.line != null &&
@@ -234,7 +238,7 @@ window.init = () => {
         ) {
           const translatedPos = {
             column: pos.column + 1,
-            lineNumber: pos.line
+            lineNumber: pos.line,
           }
           previousEditorDecos = editor.deltaDecorations(previousEditorDecos, [
             {
@@ -242,20 +246,20 @@ window.init = () => {
                 pos.line,
                 pos.column + 1,
                 pos.line,
-                pos.column + 1
+                pos.column + 1,
               ),
               options: {
                 isWholeLine: true,
-                className: `highlight`
-              }
-            }
+                className: `highlight`,
+              },
+            },
           ])
           editor.revealPositionInCenter(translatedPos)
         } else {
           clearEditorDecos()
         }
       }
-    }, 100)
+    }, 100),
   )
 
   initOptions()
@@ -264,7 +268,7 @@ window.init = () => {
 
 function debounce<T extends (...args: any[]) => any>(
   fn: T,
-  delay: number = 300
+  delay: number = 300,
 ): T {
   let prevTimer: number | null = null
   return ((...args: any[]) => {
index 73e0a959f79297e097f25a75c4ab44ff6cf0acff..e3cc6173a8a3fc95860116a011aa7ed7d76c7a45 100644 (file)
@@ -1,5 +1,5 @@
-import { h, reactive, createApp, ref } from 'vue'
-import { CompilerOptions } from '@vue/compiler-dom'
+import { createApp, h, reactive, ref } from 'vue'
+import type { CompilerOptions } from '@vue/compiler-dom'
 import { BindingTypes } from '@vue/compiler-core'
 
 export const ssrMode = ref(false)
@@ -22,12 +22,12 @@ export const defaultOptions: CompilerOptions = {
     setupLet: BindingTypes.SETUP_LET,
     setupMaybeRef: BindingTypes.SETUP_MAYBE_REF,
     setupProp: BindingTypes.PROPS,
-    vMySetupDir: BindingTypes.SETUP_CONST
-  }
+    vMySetupDir: BindingTypes.SETUP_CONST,
+  },
 }
 
 export const compilerOptions: CompilerOptions = reactive(
-  Object.assign({}, defaultOptions)
+  Object.assign({}, defaultOptions),
 )
 
 const App = {
@@ -44,18 +44,18 @@ const App = {
           'a',
           {
             href: `https://github.com/vuejs/core/tree/${__COMMIT__}`,
-            target: `_blank`
+            target: `_blank`,
           },
-          `@${__COMMIT__}`
+          `@${__COMMIT__}`,
         ),
         ' | ',
         h(
           'a',
           {
             href: 'https://app.netlify.com/sites/vue-next-template-explorer/deploys',
-            target: `_blank`
+            target: `_blank`,
           },
-          'History'
+          'History',
         ),
 
         h('div', { id: 'options-wrapper' }, [
@@ -71,7 +71,7 @@ const App = {
                 checked: isModule,
                 onChange() {
                   compilerOptions.mode = 'module'
-                }
+                },
               }),
               h('label', { for: 'mode-module' }, 'module'),
               ' ',
@@ -82,9 +82,9 @@ const App = {
                 checked: !isModule,
                 onChange() {
                   compilerOptions.mode = 'function'
-                }
+                },
               }),
-              h('label', { for: 'mode-function' }, 'function')
+              h('label', { for: 'mode-function' }, 'function'),
             ]),
 
             // whitespace handling
@@ -97,7 +97,7 @@ const App = {
                 checked: compilerOptions.whitespace === 'condense',
                 onChange() {
                   compilerOptions.whitespace = 'condense'
-                }
+                },
               }),
               h('label', { for: 'whitespace-condense' }, 'condense'),
               ' ',
@@ -108,9 +108,9 @@ const App = {
                 checked: compilerOptions.whitespace === 'preserve',
                 onChange() {
                   compilerOptions.whitespace = 'preserve'
-                }
+                },
               }),
-              h('label', { for: 'whitespace-preserve' }, 'preserve')
+              h('label', { for: 'whitespace-preserve' }, 'preserve'),
             ]),
 
             // SSR
@@ -122,9 +122,9 @@ const App = {
                 checked: ssrMode.value,
                 onChange(e: Event) {
                   ssrMode.value = (e.target as HTMLInputElement).checked
-                }
+                },
               }),
-              h('label', { for: 'ssr' }, 'SSR')
+              h('label', { for: 'ssr' }, 'SSR'),
             ]),
 
             // toggle prefixIdentifiers
@@ -137,9 +137,9 @@ const App = {
                 onChange(e: Event) {
                   compilerOptions.prefixIdentifiers =
                     (e.target as HTMLInputElement).checked || isModule
-                }
+                },
               }),
-              h('label', { for: 'prefix' }, 'prefixIdentifiers')
+              h('label', { for: 'prefix' }, 'prefixIdentifiers'),
             ]),
 
             // toggle hoistStatic
@@ -153,9 +153,9 @@ const App = {
                   compilerOptions.hoistStatic = (
                     e.target as HTMLInputElement
                   ).checked
-                }
+                },
               }),
-              h('label', { for: 'hoist' }, 'hoistStatic')
+              h('label', { for: 'hoist' }, 'hoistStatic'),
             ]),
 
             // toggle cacheHandlers
@@ -169,9 +169,9 @@ const App = {
                   compilerOptions.cacheHandlers = (
                     e.target as HTMLInputElement
                   ).checked
-                }
+                },
               }),
-              h('label', { for: 'cache' }, 'cacheHandlers')
+              h('label', { for: 'cache' }, 'cacheHandlers'),
             ]),
 
             // toggle scopeId
@@ -186,9 +186,9 @@ const App = {
                     isModule && (e.target as HTMLInputElement).checked
                       ? 'scope-id'
                       : null
-                }
+                },
               }),
-              h('label', { for: 'scope-id' }, 'scopeId')
+              h('label', { for: 'scope-id' }, 'scopeId'),
             ]),
 
             // inline mode
@@ -201,9 +201,9 @@ const App = {
                   compilerOptions.inline = (
                     e.target as HTMLInputElement
                   ).checked
-                }
+                },
               }),
-              h('label', { for: 'inline' }, 'inline')
+              h('label', { for: 'inline' }, 'inline'),
             ]),
 
             // compat mode
@@ -218,15 +218,15 @@ const App = {
                   ).checked
                     ? 2
                     : 3
-                }
+                },
               }),
-              h('label', { for: 'compat' }, 'v2 compat mode')
-            ])
-          ])
-        ])
+              h('label', { for: 'compat' }, 'v2 compat mode'),
+            ]),
+          ]),
+        ]),
       ]
     }
-  }
+  },
 }
 
 export function initOptions() {
index 99da1081ae90ed5ae6ac63785321039d3930371f..9027cd0c01165bdc40bfbfca40cca499b8d28413 100644 (file)
@@ -4,234 +4,234 @@ export default {
   rules: [
     {
       foreground: 'de935f',
-      token: 'number'
+      token: 'number',
     },
     {
       foreground: '969896',
-      token: 'comment'
+      token: 'comment',
     },
     {
       foreground: 'ced1cf',
-      token: 'keyword.operator.class'
+      token: 'keyword.operator.class',
     },
     {
       foreground: 'ced1cf',
-      token: 'constant.other'
+      token: 'constant.other',
     },
     {
       foreground: 'ced1cf',
-      token: 'source.php.embedded.line'
+      token: 'source.php.embedded.line',
     },
     {
       foreground: 'cc6666',
-      token: 'variable'
+      token: 'variable',
     },
     {
       foreground: 'cc6666',
-      token: 'support.other.variable'
+      token: 'support.other.variable',
     },
     {
       foreground: 'cc6666',
-      token: 'string.other.link'
+      token: 'string.other.link',
     },
     {
       foreground: 'cc6666',
-      token: 'string.regexp'
+      token: 'string.regexp',
     },
     {
       foreground: 'cc6666',
-      token: 'entity.name.tag'
+      token: 'entity.name.tag',
     },
     {
       foreground: 'cc6666',
-      token: 'entity.other.attribute-name'
+      token: 'entity.other.attribute-name',
     },
     {
       foreground: 'cc6666',
-      token: 'meta.tag'
+      token: 'meta.tag',
     },
     {
       foreground: 'cc6666',
-      token: 'declaration.tag'
+      token: 'declaration.tag',
     },
     {
       foreground: 'cc6666',
-      token: 'markup.deleted.git_gutter'
+      token: 'markup.deleted.git_gutter',
     },
     {
       foreground: 'de935f',
-      token: 'constant.numeric'
+      token: 'constant.numeric',
     },
     {
       foreground: 'de935f',
-      token: 'constant.language'
+      token: 'constant.language',
     },
     {
       foreground: 'de935f',
-      token: 'support.constant'
+      token: 'support.constant',
     },
     {
       foreground: 'de935f',
-      token: 'constant.character'
+      token: 'constant.character',
     },
     {
       foreground: 'de935f',
-      token: 'variable.parameter'
+      token: 'variable.parameter',
     },
     {
       foreground: 'de935f',
-      token: 'punctuation.section.embedded'
+      token: 'punctuation.section.embedded',
     },
     {
       foreground: 'de935f',
-      token: 'keyword.other.unit'
+      token: 'keyword.other.unit',
     },
     {
       foreground: 'f0c674',
-      token: 'entity.name.class'
+      token: 'entity.name.class',
     },
     {
       foreground: 'f0c674',
-      token: 'entity.name.type.class'
+      token: 'entity.name.type.class',
     },
     {
       foreground: 'f0c674',
-      token: 'support.type'
+      token: 'support.type',
     },
     {
       foreground: 'f0c674',
-      token: 'support.class'
+      token: 'support.class',
     },
     {
       foreground: 'b5bd68',
-      token: 'string'
+      token: 'string',
     },
     {
       foreground: 'b5bd68',
-      token: 'constant.other.symbol'
+      token: 'constant.other.symbol',
     },
     {
       foreground: 'b5bd68',
-      token: 'entity.other.inherited-class'
+      token: 'entity.other.inherited-class',
     },
     {
       foreground: 'b5bd68',
-      token: 'markup.heading'
+      token: 'markup.heading',
     },
     {
       foreground: 'b5bd68',
-      token: 'markup.inserted.git_gutter'
+      token: 'markup.inserted.git_gutter',
     },
     {
       foreground: '8abeb7',
-      token: 'keyword.operator'
+      token: 'keyword.operator',
     },
     {
       foreground: '8abeb7',
-      token: 'constant.other.color'
+      token: 'constant.other.color',
     },
     {
       foreground: '81a2be',
-      token: 'entity.name.function'
+      token: 'entity.name.function',
     },
     {
       foreground: '81a2be',
-      token: 'meta.function-call'
+      token: 'meta.function-call',
     },
     {
       foreground: '81a2be',
-      token: 'support.function'
+      token: 'support.function',
     },
     {
       foreground: '81a2be',
-      token: 'keyword.other.special-method'
+      token: 'keyword.other.special-method',
     },
     {
       foreground: '81a2be',
-      token: 'meta.block-level'
+      token: 'meta.block-level',
     },
     {
       foreground: '81a2be',
-      token: 'markup.changed.git_gutter'
+      token: 'markup.changed.git_gutter',
     },
     {
       foreground: 'b294bb',
-      token: 'keyword'
+      token: 'keyword',
     },
     {
       foreground: 'b294bb',
-      token: 'storage'
+      token: 'storage',
     },
     {
       foreground: 'b294bb',
-      token: 'storage.type'
+      token: 'storage.type',
     },
     {
       foreground: 'b294bb',
-      token: 'entity.name.tag.css'
+      token: 'entity.name.tag.css',
     },
     {
       foreground: 'ced2cf',
       background: 'df5f5f',
-      token: 'invalid'
+      token: 'invalid',
     },
     {
       foreground: 'ced2cf',
       background: '82a3bf',
-      token: 'meta.separator'
+      token: 'meta.separator',
     },
     {
       foreground: 'ced2cf',
       background: 'b798bf',
-      token: 'invalid.deprecated'
+      token: 'invalid.deprecated',
     },
     {
       foreground: 'ffffff',
-      token: 'markup.inserted.diff'
+      token: 'markup.inserted.diff',
     },
     {
       foreground: 'ffffff',
-      token: 'markup.deleted.diff'
+      token: 'markup.deleted.diff',
     },
     {
       foreground: 'ffffff',
-      token: 'meta.diff.header.to-file'
+      token: 'meta.diff.header.to-file',
     },
     {
       foreground: 'ffffff',
-      token: 'meta.diff.header.from-file'
+      token: 'meta.diff.header.from-file',
     },
     {
       foreground: '718c00',
-      token: 'markup.inserted.diff'
+      token: 'markup.inserted.diff',
     },
     {
       foreground: '718c00',
-      token: 'meta.diff.header.to-file'
+      token: 'meta.diff.header.to-file',
     },
     {
       foreground: 'c82829',
-      token: 'markup.deleted.diff'
+      token: 'markup.deleted.diff',
     },
     {
       foreground: 'c82829',
-      token: 'meta.diff.header.from-file'
+      token: 'meta.diff.header.from-file',
     },
     {
       foreground: 'ffffff',
       background: '4271ae',
-      token: 'meta.diff.header.from-file'
+      token: 'meta.diff.header.from-file',
     },
     {
       foreground: 'ffffff',
       background: '4271ae',
-      token: 'meta.diff.header.to-file'
+      token: 'meta.diff.header.to-file',
     },
     {
       foreground: '3e999f',
       fontStyle: 'italic',
-      token: 'meta.diff.range'
-    }
+      token: 'meta.diff.range',
+    },
   ],
   colors: {
     'editor.foreground': '#C5C8C6',
@@ -239,6 +239,6 @@ export default {
     'editor.selectionBackground': '#373B41',
     'editor.lineHighlightBackground': '#282A2E',
     'editorCursor.foreground': '#AEAFAD',
-    'editorWhitespace.foreground': '#4B4E55'
-  }
+    'editorWhitespace.foreground': '#4B4E55',
+  },
 }
index 795dfd5f6a599269125a66d7ecdd90612d806617..93f6f623c68ce287eb9f3fde93b88cb4212e73ad 100644 (file)
@@ -1,8 +1,9 @@
 body {
   margin: 0;
   overflow: hidden;
-  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
-  --bg: #1D1F21;
+  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
+    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
+  --bg: #1d1f21;
   --border: #333;
 }
 
index 1f2f9ae247dbc32424b223e367b62d5f821b710c..2ae2f211a108a0c7ef56d6fd97d1fa2213fc379b 100644 (file)
@@ -7,7 +7,7 @@ import { triggerEvent } from './utils'
 beforeEach(() => {
   toggleDeprecationWarning(false)
   Vue.configureCompat({
-    MODE: 2
+    MODE: 2,
   })
 })
 
@@ -21,14 +21,14 @@ afterEach(() => {
 
 test('COMPILER_IS_ON_ELEMENT', () => {
   const MyButton = {
-    template: `<div><slot/></div>`
+    template: `<div><slot/></div>`,
   }
 
   const vm = new Vue({
     template: `<button is="my-button">text</button>`,
     components: {
-      MyButton
-    }
+      MyButton,
+    },
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -38,14 +38,14 @@ test('COMPILER_IS_ON_ELEMENT', () => {
 
 test('COMPILER_IS_ON_ELEMENT (dynamic)', () => {
   const MyButton = {
-    template: `<div><slot/></div>`
+    template: `<div><slot/></div>`,
   }
 
   const vm = new Vue({
     template: `<button :is="'MyButton'">text</button>`,
     components: {
-      MyButton
-    }
+      MyButton,
+    },
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -56,19 +56,19 @@ test('COMPILER_IS_ON_ELEMENT (dynamic)', () => {
 test('COMPILER_V_BIND_SYNC', async () => {
   const MyButton = {
     props: ['foo'],
-    template: `<button @click="$emit('update:foo', 1)">{{ foo }}</button>`
+    template: `<button @click="$emit('update:foo', 1)">{{ foo }}</button>`,
   }
 
   const vm = new Vue({
     data() {
       return {
-        foo: 0
+        foo: 0,
       }
     },
     template: `<my-button :foo.sync="foo" />`,
     components: {
-      MyButton
-    }
+      MyButton,
+    },
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLButtonElement)
@@ -83,13 +83,13 @@ test('COMPILER_V_BIND_SYNC', async () => {
 
 test('COMPILER_V_BIND_OBJECT_ORDER', () => {
   const vm = new Vue({
-    template: `<div id="foo" v-bind="{ id: 'bar', class: 'baz' }" />`
+    template: `<div id="foo" v-bind="{ id: 'bar', class: 'baz' }" />`,
   }).$mount()
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
   expect(vm.$el.id).toBe('foo')
   expect(vm.$el.className).toBe('baz')
   expect(
-    CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER
+    CompilerDeprecationTypes.COMPILER_V_BIND_OBJECT_ORDER,
   ).toHaveBeenWarned()
 })
 
@@ -99,12 +99,12 @@ test('COMPILER_V_ON_NATIVE', () => {
     template: `<child @click="spy" @click.native="spy" />`,
     components: {
       child: {
-        template: `<button />`
-      }
+        template: `<button />`,
+      },
     },
     methods: {
-      spy
-    }
+      spy,
+    },
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLButtonElement)
@@ -116,13 +116,13 @@ test('COMPILER_V_ON_NATIVE', () => {
 test('COMPILER_V_IF_V_FOR_PRECEDENCE', () => {
   new Vue({ template: `<div v-if="true" v-for="i in 1"/>` }).$mount()
   expect(
-    CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE
+    CompilerDeprecationTypes.COMPILER_V_IF_V_FOR_PRECEDENCE,
   ).toHaveBeenWarned()
 })
 
 test('COMPILER_NATIVE_TEMPLATE', () => {
   const vm = new Vue({
-    template: `<div><template><div/></template></div>`
+    template: `<div><template><div/></template></div>`,
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -137,9 +137,9 @@ test('COMPILER_INLINE_TEMPLATE', () => {
       foo: {
         data() {
           return { n: 123 }
-        }
-      }
-    }
+        },
+      },
+    },
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
index 8fda196a099a24b92eddb9c273bc73b852b70128..7b85d8b1e195f2862f6deb2389e8cec87612601a 100644 (file)
@@ -2,14 +2,14 @@ import Vue from '@vue/compat'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 
 beforeEach(() => {
   toggleDeprecationWarning(true)
   Vue.configureCompat({
     MODE: 2,
-    GLOBAL_MOUNT: 'suppress-warning'
+    GLOBAL_MOUNT: 'suppress-warning',
   })
 })
 
@@ -28,7 +28,7 @@ describe('COMPONENT_ASYNC', () => {
     }
     const vm = new Vue({
       template: `<div><comp/></div>`,
-      components: { comp }
+      components: { comp },
     }).$mount()
 
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -40,8 +40,8 @@ describe('COMPONENT_ASYNC', () => {
 
     expect(
       (deprecationData[DeprecationTypes.COMPONENT_ASYNC].message as Function)(
-        comp
-      )
+        comp,
+      ),
     ).toHaveBeenWarned()
   })
 
@@ -49,7 +49,7 @@ describe('COMPONENT_ASYNC', () => {
     const comp = () => Promise.resolve({ template: 'foo' })
     const vm = new Vue({
       template: `<div><comp/></div>`,
-      components: { comp }
+      components: { comp },
     }).$mount()
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
     expect(vm.$el.innerHTML).toBe(`<!---->`)
@@ -58,19 +58,19 @@ describe('COMPONENT_ASYNC', () => {
 
     expect(
       (deprecationData[DeprecationTypes.COMPONENT_ASYNC].message as Function)(
-        comp
-      )
+        comp,
+      ),
     ).toHaveBeenWarned()
   })
 
   test('object syntax', async () => {
     const comp = () => ({
-      component: Promise.resolve({ template: 'foo' })
+      component: Promise.resolve({ template: 'foo' }),
     })
 
     const vm = new Vue({
       template: `<div><comp/></div>`,
-      components: { comp }
+      components: { comp },
     }).$mount()
 
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -80,8 +80,8 @@ describe('COMPONENT_ASYNC', () => {
 
     expect(
       (deprecationData[DeprecationTypes.COMPONENT_ASYNC].message as Function)(
-        comp
-      )
+        comp,
+      ),
     ).toHaveBeenWarned()
   })
 })
index 9932595696d782660c6028edd5fe6cf70f6bb4d6..d3d11daebbc82aee8727cabfc51081e1fff25621 100644 (file)
@@ -2,14 +2,14 @@ import Vue from '@vue/compat'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 
 beforeEach(() => {
   toggleDeprecationWarning(true)
   Vue.configureCompat({
     MODE: 2,
-    GLOBAL_MOUNT: 'suppress-warning'
+    GLOBAL_MOUNT: 'suppress-warning',
   })
 })
 
@@ -24,27 +24,27 @@ describe('COMPONENT_FUNCTIONAL', () => {
       name: 'Func',
       functional: true,
       props: {
-        x: String
+        x: String,
       },
       inject: ['foo'],
       render: (h: any, { data, props, injections, slots }: any) => {
         return h('div', { id: props.x, class: data.class }, [
           h('div', { class: 'inject' }, injections.foo),
-          h('div', { class: 'slot' }, slots().default)
+          h('div', { class: 'slot' }, slots().default),
         ])
-      }
+      },
     }
 
     const vm = new Vue({
       provide() {
         return {
-          foo: 123
+          foo: 123,
         }
       },
       components: {
-        func
+        func,
       },
-      template: `<func class="foo" x="foo">hello</func>`
+      template: `<func class="foo" x="foo">hello</func>`,
     }).$mount()
 
     expect(vm.$el.id).toBe('foo')
@@ -52,14 +52,14 @@ describe('COMPONENT_FUNCTIONAL', () => {
     expect(vm.$el.querySelector('.inject').textContent).toBe('123')
     expect(vm.$el.querySelector('.slot').textContent).toBe('hello')
     expect(vm.$el.outerHTML).toMatchInlineSnapshot(
-      `"<div id="foo" class="foo"><div class="inject">123</div><div class="slot">hello</div></div>"`
+      `"<div id="foo" class="foo"><div class="inject">123</div><div class="slot">hello</div></div>"`,
     )
 
     expect(
       (
         deprecationData[DeprecationTypes.COMPONENT_FUNCTIONAL]
           .message as Function
-      )(func)
+      )(func),
     ).toHaveBeenWarned()
   })
 
@@ -68,17 +68,17 @@ describe('COMPONENT_FUNCTIONAL', () => {
       name: 'Func',
       functional: true,
       compatConfig: {
-        ATTR_FALSE_VALUE: 'suppress-warning' as const
+        ATTR_FALSE_VALUE: 'suppress-warning' as const,
       },
       render: (h: any) => {
         // should not render required: false due to compatConfig
         return h('div', { 'data-some-attr': false })
-      }
+      },
     }
 
     const vm = new Vue({
       components: { func },
-      template: `<func class="foo" x="foo">hello</func>`
+      template: `<func class="foo" x="foo">hello</func>`,
     }).$mount()
 
     expect(vm.$el.outerHTML).toMatchInlineSnapshot(`"<div></div>"`)
@@ -86,12 +86,12 @@ describe('COMPONENT_FUNCTIONAL', () => {
       (
         deprecationData[DeprecationTypes.COMPONENT_FUNCTIONAL]
           .message as Function
-      )(func)
+      )(func),
     ).toHaveBeenWarned()
     expect(
       (deprecationData[DeprecationTypes.ATTR_FALSE_VALUE].message as Function)(
-        func
-      )
+        func,
+      ),
     ).not.toHaveBeenWarned()
   })
 })
index 05043b018d206975e44020c4b1b78770ce4d3a4e..7e4988287152c38405af237df9c8decebc70cc64 100644 (file)
@@ -1,10 +1,10 @@
 import Vue from '@vue/compat'
-import { ComponentOptions } from '../../runtime-core/src/component'
+import type { ComponentOptions } from '../../runtime-core/src/component'
 import { nextTick } from '../../runtime-core/src/scheduler'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 import { triggerEvent } from './utils'
 
@@ -12,7 +12,7 @@ beforeEach(() => {
   toggleDeprecationWarning(true)
   Vue.configureCompat({
     MODE: 2,
-    GLOBAL_MOUNT: 'suppress-warning'
+    GLOBAL_MOUNT: 'suppress-warning',
   })
 })
 
@@ -26,7 +26,7 @@ describe('COMPONENT_V_MODEL', () => {
     const vm = new Vue({
       data() {
         return {
-          text: 'foo'
+          text: 'foo',
         }
       },
       components: { CustomInput },
@@ -35,7 +35,7 @@ describe('COMPONENT_V_MODEL', () => {
         <span>{{ text }}</span>
         <custom-input v-model="text"></custom-input>
       </div>
-      `
+      `,
     }).$mount() as any
 
     const input = vm.$el.querySelector('input')
@@ -46,8 +46,8 @@ describe('COMPONENT_V_MODEL', () => {
 
     expect(
       (deprecationData[DeprecationTypes.COMPONENT_V_MODEL].message as Function)(
-        CustomInput
-      )
+        CustomInput,
+      ),
     ).toHaveBeenWarned()
 
     input.value = 'bar'
@@ -67,7 +67,7 @@ describe('COMPONENT_V_MODEL', () => {
     await runTest({
       name: 'CustomInput',
       props: ['value'],
-      template: `<input :value="value" @input="$emit('input', $event.target.value)">`
+      template: `<input :value="value" @input="$emit('input', $event.target.value)">`,
     })
   })
 
@@ -77,9 +77,9 @@ describe('COMPONENT_V_MODEL', () => {
       props: ['input'],
       model: {
         prop: 'input',
-        event: 'update'
+        event: 'update',
       },
-      template: `<input :value="input" @input="$emit('update', $event.target.value)">`
+      template: `<input :value="input" @input="$emit('update', $event.target.value)">`,
     })
   })
 })
index c1acbd899bc9a0163a04333cefd5b98b19509e3e..9942673552a1c80171c5fd58c45ff067cff31006 100644 (file)
@@ -1,9 +1,9 @@
 import Vue from '@vue/compat'
 import { CompilerDeprecationTypes } from '../../compiler-core/src'
 import {
-  deprecationData,
   DeprecationTypes,
-  toggleDeprecationWarning
+  deprecationData,
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 
 beforeEach(() => {
@@ -40,8 +40,8 @@ describe('FILTERS', () => {
     const vm = new Vue({
       template: '<div>{{ msg | globalUpper }}</div>',
       data: () => ({
-        msg: 'hi'
-      })
+        msg: 'hi',
+      }),
     }).$mount()
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
     expect(vm.$el.textContent).toBe('HI')
@@ -54,11 +54,11 @@ describe('FILTERS', () => {
     const vm = new Vue({
       template: '<div>{{ msg | upper }}</div>',
       data: () => ({
-        msg: 'hi'
+        msg: 'hi',
       }),
       filters: {
-        upper
-      }
+        upper,
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('HI')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -68,12 +68,12 @@ describe('FILTERS', () => {
     const vm = new Vue({
       template: '<div>{{ msg | upper | reverse }}</div>',
       data: () => ({
-        msg: 'hi'
+        msg: 'hi',
       }),
       filters: {
         upper,
-        reverse
-      }
+        reverse,
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('IH')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -91,13 +91,13 @@ describe('FILTERS', () => {
       filters: {
         upper,
         reverse,
-        lower
+        lower,
       },
       data: () => ({
         id: 'abc',
         cls: 'foo',
-        ref: 'BAR'
-      })
+        ref: 'BAR',
+      }),
     }).$mount()
     expect(vm.$el.id).toBe('CBA')
     expect(vm.$el.className).toBe('oof')
@@ -112,9 +112,9 @@ describe('FILTERS', () => {
       components: {
         test: {
           props: ['pattern'],
-          template: '<div></div>'
-        }
-      }
+          template: '<div></div>',
+        },
+      },
     }).$mount() as any
     expect(vm.$refs.test.pattern).toBeInstanceOf(RegExp)
     expect(vm.$refs.test.pattern.toString()).toBe('/a|b\\//')
@@ -125,7 +125,7 @@ describe('FILTERS', () => {
     const vm = new Vue({
       data: () => ({ a: 2 }),
       template: `<div>{{ 1/a / 4 | double }}</div>`,
-      filters: { double }
+      filters: { double },
     }).$mount()
     expect(vm.$el.textContent).toBe(String(1 / 4))
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -135,7 +135,7 @@ describe('FILTERS', () => {
     const vm = new Vue({
       data: () => ({ a: 20 }),
       template: `<div>{{ (a*2) / 5 | double }}</div>`,
-      filters: { double }
+      filters: { double },
     }).$mount()
     expect(vm.$el.textContent).toBe(String(16))
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -144,7 +144,7 @@ describe('FILTERS', () => {
   it('handle division with dot', () => {
     const vm = new Vue({
       template: `<div>{{ 20. / 5 | double }}</div>`,
-      filters: { double }
+      filters: { double },
     }).$mount()
     expect(vm.$el.textContent).toBe(String(8))
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -154,7 +154,7 @@ describe('FILTERS', () => {
     const vm = new Vue({
       data: () => ({ a: [20] }),
       template: `<div>{{ a[0] / 5 | double }}</div>`,
-      filters: { double }
+      filters: { double },
     }).$mount()
     expect(vm.$el.textContent).toBe(String(8))
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -164,7 +164,7 @@ describe('FILTERS', () => {
     const vm = new Vue({
       data: () => ({ a: { n: 20 } }),
       template: `<div>{{ a['n'] / 5 | double }}</div>`,
-      filters: { double }
+      filters: { double },
     }).$mount()
     expect(vm.$el.textContent).toBe(String(8))
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -174,7 +174,7 @@ describe('FILTERS', () => {
     const vm = new Vue({
       data: () => ({ a_: 8 }),
       template: `<div>{{ a_ / 2 | double }}</div>`,
-      filters: { double }
+      filters: { double },
     }).$mount()
     expect(vm.$el.textContent).toBe(String(8))
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -185,11 +185,11 @@ describe('FILTERS', () => {
       template: `<div>{{ msg | add(a, 3) }}</div>`,
       data: () => ({
         msg: 1,
-        a: 2
+        a: 2,
       }),
       filters: {
-        add: (v: number, arg1: number, arg2: number) => v + arg1 + arg2
-      }
+        add: (v: number, arg1: number, arg2: number) => v + arg1 + arg2,
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('6')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -199,11 +199,11 @@ describe('FILTERS', () => {
     const vm = new Vue({
       template: `<div>{{ msg + "b | c" + 'd' | upper }}</div>`,
       data: () => ({
-        msg: 'a'
+        msg: 'a',
       }),
       filters: {
-        upper
-      }
+        upper,
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('AB | CD')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -214,11 +214,11 @@ describe('FILTERS', () => {
       template: `<div>{{ b || msg | upper }}</div>`,
       data: () => ({
         b: false,
-        msg: 'a'
+        msg: 'a',
       }),
       filters: {
-        upper
-      }
+        upper,
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('A')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -228,8 +228,8 @@ describe('FILTERS', () => {
     const vm = new Vue({
       template: `<div>{{ { a: 123 } | pick('a') }}</div>`,
       filters: {
-        pick: (v: any, key: string) => v[key]
-      }
+        pick: (v: any, key: string) => v[key],
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('123')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -239,8 +239,8 @@ describe('FILTERS', () => {
     const vm = new Vue({
       template: `<div>{{ [1, 2, 3] | reverse }}</div>`,
       filters: {
-        reverse: (arr: any[]) => arr.reverse().join(',')
-      }
+        reverse: (arr: any[]) => arr.reverse().join(','),
+      },
     }).$mount()
     expect(vm.$el.textContent).toBe('3,2,1')
     expect(CompilerDeprecationTypes.COMPILER_FILTERS).toHaveBeenWarned()
@@ -248,7 +248,7 @@ describe('FILTERS', () => {
 
   it('bigint support', () => {
     const vm = new Vue({
-      template: `<div>{{ BigInt(BigInt(10000000)) + BigInt(2000000000n) * 3000000n }}</div>`
+      template: `<div>{{ BigInt(BigInt(10000000)) + BigInt(2000000000n) * 3000000n }}</div>`,
     }).$mount()
     expect(vm.$el.textContent).toBe('6000000010000000')
   })
index ffbea39a354d2eff52dae2b9ff22543c758ee29c..fcbdefa2f29fd6a3805f6a44931338c382842b8d 100644 (file)
@@ -4,7 +4,7 @@ import { h, nextTick } from '@vue/runtime-core'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 import { singletonApp } from '../../runtime-core/src/compat/global'
 import { createApp } from '../src/esm-index'
@@ -30,12 +30,12 @@ describe('GLOBAL_MOUNT', () => {
       compatConfig: { GLOBAL_MOUNT: true },
       data() {
         return {
-          msg: 'hello'
+          msg: 'hello',
         }
-      }
+      },
     })
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message
+      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message,
     ).toHaveBeenWarned()
     expect(el.innerHTML).toBe('hello')
   })
@@ -46,9 +46,9 @@ describe('GLOBAL_MOUNT', () => {
     new Vue({
       data() {
         return {
-          msg: 'hello'
+          msg: 'hello',
         }
-      }
+      },
     }).$mount(el)
     expect(el.innerHTML).toBe('hello')
   })
@@ -64,10 +64,10 @@ describe('GLOBAL_MOUNT_CONTAINER', () => {
     new Vue().$mount(el)
     // warning only
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message
+      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message,
     ).toHaveBeenWarned()
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_MOUNT_CONTAINER].message
+      deprecationData[DeprecationTypes.GLOBAL_MOUNT_CONTAINER].message,
     ).toHaveBeenWarned()
   })
 })
@@ -80,46 +80,46 @@ describe('GLOBAL_EXTEND', () => {
     const Test = Vue.extend({
       name: 'test',
       a: 1,
-      b: 2
+      b: 2,
     })
     expect(Test.options.a).toBe(1)
     expect(Test.options.b).toBe(2)
     expect(Test.super).toBe(Vue)
     const t = new Test({
-      a: 2
+      a: 2,
     })
     expect(t.$options.a).toBe(2)
     expect(t.$options.b).toBe(2)
     // inheritance
     const Test2 = Test.extend({
-      a: 2
+      a: 2,
     })
     expect(Test2.options.a).toBe(2)
     expect(Test2.options.b).toBe(2)
     const t2 = new Test2({
-      a: 3
+      a: 3,
     })
     expect(t2.$options.a).toBe(3)
     expect(t2.$options.b).toBe(2)
 
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message
+      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message,
     ).toHaveBeenWarned()
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_EXTEND].message
+      deprecationData[DeprecationTypes.GLOBAL_EXTEND].message,
     ).toHaveBeenWarned()
   })
 
   it('should work when used as components', () => {
     const foo = Vue.extend({
-      template: '<span>foo</span>'
+      template: '<span>foo</span>',
     })
     const bar = Vue.extend({
-      template: '<span>bar</span>'
+      template: '<span>bar</span>',
     })
     const vm = new Vue({
       template: '<div><foo></foo><bar></bar></div>',
-      components: { foo, bar }
+      components: { foo, bar },
     }).$mount()
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
     expect(vm.$el.innerHTML).toBe('<span>foo</span><span>bar</span>')
@@ -130,17 +130,17 @@ describe('GLOBAL_EXTEND', () => {
     const A = Vue.extend({
       created() {
         calls.push(1)
-      }
+      },
     })
     const B = A.extend({
       created() {
         calls.push(2)
-      }
+      },
     })
     new B({
       created() {
         calls.push(3)
-      }
+      },
     })
     expect(calls).toEqual([1, 2, 3])
   })
@@ -151,22 +151,22 @@ describe('GLOBAL_EXTEND', () => {
     const c = vi.fn()
     const d = vi.fn()
     const A = Vue.extend({
-      created: a
+      created: a,
     })
     const B = Vue.extend({
       mixins: [A],
-      created: b
+      created: b,
     })
     const C = Vue.extend({
       extends: B,
-      created: c
+      created: c,
     })
     const D = Vue.extend({
       mixins: [C],
       created: d,
       render() {
         return null
-      }
+      },
     })
     new D().$mount()
     expect(a.mock.calls.length).toStrictEqual(1)
@@ -180,23 +180,23 @@ describe('GLOBAL_EXTEND', () => {
       methods: {
         a() {
           return this.n
-        }
-      }
+        },
+      },
     })
     const B = A.extend({
       methods: {
         b() {
           return this.n + 1
-        }
-      }
+        },
+      },
     })
     const b = new B({
       data: () => ({ n: 0 }),
       methods: {
         c() {
           return this.n + 2
-        }
-      }
+        },
+      },
     }) as any
     expect(b.a()).toBe(0)
     expect(b.b()).toBe(1)
@@ -207,19 +207,19 @@ describe('GLOBAL_EXTEND', () => {
     const A = Vue.extend({
       components: {
         aa: {
-          template: '<div>A</div>'
-        }
-      }
+          template: '<div>A</div>',
+        },
+      },
     })
     const B = A.extend({
       components: {
         bb: {
-          template: '<div>B</div>'
-        }
-      }
+          template: '<div>B</div>',
+        },
+      },
     })
     const b = new B({
-      template: '<div><aa></aa><bb></bb></div>'
+      template: '<div><aa></aa><bb></bb></div>',
     }).$mount()
     expect(b.$el).toBeInstanceOf(HTMLDivElement)
     expect(b.$el.innerHTML).toBe('<div>A</div><div>B</div>')
@@ -227,7 +227,7 @@ describe('GLOBAL_EXTEND', () => {
 
   it('caching', () => {
     const options = {
-      template: '<div></div>'
+      template: '<div></div>',
     }
     const A = Vue.extend(options)
     const B = Vue.extend(options)
@@ -251,10 +251,10 @@ describe('GLOBAL_PROTOTYPE', () => {
     expect(vm.$test).toBe(1)
     delete Vue.prototype.$test
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message
+      deprecationData[DeprecationTypes.GLOBAL_MOUNT].message,
     ).toHaveBeenWarned()
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_PROTOTYPE].message
+      deprecationData[DeprecationTypes.GLOBAL_PROTOTYPE].message,
     ).toHaveBeenWarned()
   })
 
@@ -265,7 +265,7 @@ describe('GLOBAL_PROTOTYPE', () => {
     const vm = new Vue({
       data() {
         return { msg: 'method' }
-      }
+      },
     }) as any
     expect(vm.$test()).toBe('method')
     delete Vue.prototype.$test
@@ -276,12 +276,12 @@ describe('GLOBAL_PROTOTYPE', () => {
       configurable: true,
       get() {
         return this.msg
-      }
+      },
     })
     const vm = new Vue({
       data() {
         return { msg: 'getter' }
-      }
+      },
     }) as any
     expect(vm.$test).toBe('getter')
     delete Vue.prototype.$test
@@ -299,9 +299,9 @@ describe('GLOBAL_PROTOTYPE', () => {
     const vm = new Vue({
       data() {
         return {
-          msg: 'test'
+          msg: 'test',
         }
-      }
+      },
     }) as any
     expect(typeof vm.$test).toBe('function')
     expect(typeof vm.$test.additionalFn).toBe('function')
@@ -321,7 +321,7 @@ describe('GLOBAL_PROTOTYPE', () => {
   test('should affect apps created via createApp()', () => {
     Vue.prototype.$test = 1
     const vm = createApp({
-      template: 'foo'
+      template: 'foo',
     }).mount(document.createElement('div')) as any
     expect(vm.$test).toBe(1)
     delete Vue.prototype.$test
@@ -335,7 +335,7 @@ describe('GLOBAL_SET/DELETE', () => {
     Vue.set(obj, 'foo', 1)
     expect(obj.foo).toBe(1)
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_SET].message
+      deprecationData[DeprecationTypes.GLOBAL_SET].message,
     ).toHaveBeenWarned()
   })
 
@@ -345,7 +345,7 @@ describe('GLOBAL_SET/DELETE', () => {
     Vue.delete(obj, 'foo')
     expect('foo' in obj).toBe(false)
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_DELETE].message
+      deprecationData[DeprecationTypes.GLOBAL_DELETE].message,
     ).toHaveBeenWarned()
   })
 })
@@ -356,7 +356,7 @@ describe('GLOBAL_OBSERVABLE', () => {
     const obj = Vue.observable({})
     expect(isReactive(obj)).toBe(true)
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_OBSERVABLE].message
+      deprecationData[DeprecationTypes.GLOBAL_OBSERVABLE].message,
     ).toHaveBeenWarned()
   })
 })
@@ -365,7 +365,6 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
   test('defineReactive', () => {
     toggleDeprecationWarning(true)
     const obj: any = {}
-    // @ts-ignore
     Vue.util.defineReactive(obj, 'test', 1)
 
     let n
@@ -377,17 +376,16 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
     expect(n).toBe(2)
 
     expect(
-      deprecationData[DeprecationTypes.GLOBAL_PRIVATE_UTIL].message
+      deprecationData[DeprecationTypes.GLOBAL_PRIVATE_UTIL].message,
     ).toHaveBeenWarned()
   })
 
   test('defineReactive on instance', async () => {
     const vm = new Vue({
       beforeCreate() {
-        // @ts-ignore
         Vue.util.defineReactive(this, 'foo', 1)
       },
-      template: `<div>{{ foo }}</div>`
+      template: `<div>{{ foo }}</div>`,
     }).$mount() as any
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
     expect(vm.$el.textContent).toBe('1')
@@ -399,10 +397,9 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
   test('defineReactive on instance with key that starts with $', async () => {
     const vm = new Vue({
       beforeCreate() {
-        // @ts-ignore
         Vue.util.defineReactive(this, '$foo', 1)
       },
-      template: `<div>{{ $foo }}</div>`
+      template: `<div>{{ $foo }}</div>`,
     }).$mount() as any
     expect(vm.$el.textContent).toBe('1')
     vm.$foo = 2
@@ -413,7 +410,6 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
   test('defineReactive with object value', () => {
     const obj: any = {}
     const val = { a: 1 }
-    // @ts-ignore
     Vue.util.defineReactive(obj, 'foo', val)
 
     let n
@@ -429,7 +425,6 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
   test('defineReactive with array value', () => {
     const obj: any = {}
     const val = [1]
-    // @ts-ignore
     Vue.util.defineReactive(obj, 'foo', val)
 
     let n
@@ -446,7 +441,7 @@ describe('GLOBAL_PRIVATE_UTIL', () => {
 test('global asset registration should affect apps created via createApp', () => {
   Vue.component('foo', { template: 'foo' })
   const vm = createApp({
-    template: '<foo/>'
+    template: '<foo/>',
   }).mount(document.createElement('div')) as any
   expect(vm.$el.textContent).toBe('foo')
   delete singletonApp._context.components.foo
@@ -454,7 +449,7 @@ test('global asset registration should affect apps created via createApp', () =>
 
 test('post-facto global asset registration should affect apps created via createApp', () => {
   const app = createApp({
-    template: '<foo/>'
+    template: '<foo/>',
   })
   Vue.component('foo', { template: 'foo' })
   const vm = app.mount(document.createElement('div'))
@@ -470,7 +465,7 @@ test('local asset registration should not affect other local apps', () => {
   app2.component('foo', {})
 
   expect(
-    `Component "foo" has already been registered in target app`
+    `Component "foo" has already been registered in target app`,
   ).not.toHaveBeenWarned()
 })
 
@@ -495,9 +490,9 @@ test('local app config should not affect other local apps in v3 mode', () => {
     render: () => h('div'),
     provide() {
       return {
-        test: 123
+        test: 123,
       }
-    }
+    },
   })
   app1.config.globalProperties.test = () => {}
   app1.mount(document.createElement('div'))
index be7b87ea43c6fe7566f1974fafa32035fc3157b3..44cf6651527687eee706060a8f85e3c1bca6428b 100644 (file)
@@ -1,7 +1,7 @@
 import Vue from '@vue/compat'
 import {
   DeprecationTypes,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 import { createApp } from '../src/esm-index'
 import { triggerEvent } from './utils'
@@ -21,7 +21,7 @@ afterEach(() => {
 test('GLOBAL_KEY_CODES', () => {
   Vue.config.keyCodes = {
     foo: 86,
-    bar: [38, 87]
+    bar: [38, 87],
   }
 
   const onFoo = vi.fn()
@@ -33,8 +33,8 @@ test('GLOBAL_KEY_CODES', () => {
     template: `<input type="text" @keyup.foo="onFoo" @keyup.bar="onBar">`,
     methods: {
       onFoo,
-      onBar
-    }
+      onBar,
+    },
   })
 
   triggerEvent(el.children[0], 'keyup', e => {
@@ -64,7 +64,7 @@ test('GLOBAL_IGNORED_ELEMENTS', () => {
   const el = document.createElement('div')
   new Vue({
     el,
-    template: `<v-foo/><foo/>`
+    template: `<v-foo/><foo/>`,
   })
   expect(el.innerHTML).toBe(`<v-foo></v-foo><foo></foo>`)
 })
@@ -73,7 +73,7 @@ test('singleton config should affect apps created with createApp()', () => {
   Vue.config.ignoredElements = [/^v-/, 'foo']
   const el = document.createElement('div')
   createApp({
-    template: `<v-foo/><foo/>`
+    template: `<v-foo/><foo/>`,
   }).mount(el)
   expect(el.innerHTML).toBe(`<v-foo></v-foo><foo></foo>`)
 })
index 009dc7aa6f5eeff01958a10ceb67fbd2302d1a4c..63ce55812304022f832e45ad482dcaf323e51418 100644 (file)
@@ -1,19 +1,19 @@
-import { type Mock } from 'vitest'
+import type { Mock } from 'vitest'
 import Vue from '@vue/compat'
-import { Slots } from '../../runtime-core/src/componentSlots'
+import type { Slots } from '../../runtime-core/src/componentSlots'
 import { Text } from '../../runtime-core/src/vnode'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
-import { LegacyPublicInstance } from '../../runtime-core/src/compat/instance'
+import type { LegacyPublicInstance } from '../../runtime-core/src/compat/instance'
 
 beforeEach(() => {
   toggleDeprecationWarning(true)
   Vue.configureCompat({
     MODE: 2,
-    GLOBAL_MOUNT: 'suppress-warning'
+    GLOBAL_MOUNT: 'suppress-warning',
   })
 })
 
@@ -27,7 +27,7 @@ test('INSTANCE_SET', () => {
   new Vue().$set(obj, 'foo', 1)
   expect(obj.foo).toBe(1)
   expect(
-    deprecationData[DeprecationTypes.INSTANCE_SET].message
+    deprecationData[DeprecationTypes.INSTANCE_SET].message,
   ).toHaveBeenWarned()
 })
 
@@ -36,14 +36,14 @@ test('INSTANCE_DELETE', () => {
   new Vue().$delete(obj, 'foo')
   expect('foo' in obj).toBe(false)
   expect(
-    deprecationData[DeprecationTypes.INSTANCE_DELETE].message
+    deprecationData[DeprecationTypes.INSTANCE_DELETE].message,
   ).toHaveBeenWarned()
 })
 
 test('INSTANCE_DESTROY', () => {
   new Vue({ template: 'foo' }).$mount().$destroy()
   expect(
-    deprecationData[DeprecationTypes.INSTANCE_DESTROY].message
+    deprecationData[DeprecationTypes.INSTANCE_DESTROY].message,
   ).toHaveBeenWarned()
 })
 
@@ -67,7 +67,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     expect(spy).toHaveBeenCalledTimes(1)
     expect(spy).toHaveBeenCalledWith(1, 2, 3, 4)
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -83,7 +83,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     expect(spy).toHaveBeenCalledTimes(2)
     expect(spy).toHaveBeenCalledWith(5, 6, 7, 8)
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -96,7 +96,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     vm.$emit('test3', 1, 2, 3, 4)
     expect(spy).toHaveBeenCalledTimes(1)
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -106,7 +106,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     vm.$emit('test1')
     expect(spy).not.toHaveBeenCalled()
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -117,7 +117,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     expect(spy).toHaveBeenCalledTimes(1)
     expect(spy).toHaveBeenCalledWith(1, 2, 3)
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -127,7 +127,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     vm.$emit('test', 1, 2, 3)
     expect(spy).not.toHaveBeenCalled()
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -139,7 +139,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     vm.$emit('test2')
     expect(spy).not.toHaveBeenCalled()
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -153,7 +153,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     expect(spy).toHaveBeenCalledTimes(1)
     expect(spy).toHaveBeenCalledWith(2)
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 
@@ -167,7 +167,7 @@ describe('INSTANCE_EVENT_EMITTER', () => {
     expect(spy2).toHaveBeenCalledTimes(1)
     expect(spy2).toHaveBeenCalledWith(1, 2, 3)
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message
+      deprecationData[DeprecationTypes.INSTANCE_EVENT_EMITTER].message,
     ).toHaveBeenWarned()
   })
 })
@@ -183,7 +183,7 @@ describe('INSTANCE_EVENT_HOOKS', () => {
       (
         deprecationData[DeprecationTypes.INSTANCE_EVENT_HOOKS]
           .message as Function
-      )('hook:mounted')
+      )('hook:mounted'),
     ).toHaveBeenWarned()
   })
 
@@ -194,16 +194,16 @@ describe('INSTANCE_EVENT_HOOKS', () => {
       methods: { spy },
       components: {
         child: {
-          template: 'foo'
-        }
-      }
+          template: 'foo',
+        },
+      },
     }).$mount()
     expect(spy).toHaveBeenCalled()
     expect(
       (
         deprecationData[DeprecationTypes.INSTANCE_EVENT_HOOKS]
           .message as Function
-      )('hook:mounted')
+      )('hook:mounted'),
     ).toHaveBeenWarned()
   })
 })
@@ -216,16 +216,16 @@ test('INSTANCE_EVENT_CHILDREN', () => {
         template: 'foo',
         data() {
           return { n: 1 }
-        }
-      }
-    }
+        },
+      },
+    },
   }).$mount()
   expect(vm.$children.length).toBe(4)
   vm.$children.forEach((c: any) => {
     expect(c.n).toBe(1)
   })
   expect(
-    deprecationData[DeprecationTypes.INSTANCE_CHILDREN].message
+    deprecationData[DeprecationTypes.INSTANCE_CHILDREN].message,
   ).toHaveBeenWarned()
 })
 
@@ -242,9 +242,9 @@ test('INSTANCE_LISTENERS', () => {
         template: `<div/>`,
         mounted() {
           listeners = this.$listeners
-        }
-      }
-    }
+        },
+      },
+    },
   }).$mount()
 
   expect(Object.keys(listeners!)).toMatchObject(['click', 'custom'])
@@ -252,7 +252,7 @@ test('INSTANCE_LISTENERS', () => {
   expect(listeners!.custom()).toBe('bar')
 
   expect(
-    deprecationData[DeprecationTypes.INSTANCE_LISTENERS].message
+    deprecationData[DeprecationTypes.INSTANCE_LISTENERS].message,
   ).toHaveBeenWarned()
 })
 
@@ -266,20 +266,20 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
           compatConfig: { RENDER_FUNCTION: false },
           render() {
             slots = this.$scopedSlots
-          }
-        }
-      }
+          },
+        },
+      },
     }).$mount()
 
     expect(slots!.default!({ msg: 'hi' })).toMatchObject([
       {
         type: Text,
-        children: 'hi'
-      }
+        children: 'hi',
+      },
     ])
 
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message
+      deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message,
     ).toHaveBeenWarned()
   })
 
@@ -294,16 +294,16 @@ describe('INSTANCE_SCOPED_SLOTS', () => {
           render() {
             normalSlots = this.$slots
             scopedSlots = this.$scopedSlots
-          }
-        }
-      }
+          },
+        },
+      },
     }).$mount()
 
     expect('default' in normalSlots!).toBe(true)
     expect('default' in scopedSlots!).toBe(false)
 
     expect(
-      deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message
+      deprecationData[DeprecationTypes.INSTANCE_SCOPED_SLOTS].message,
     ).toHaveBeenWarned()
   })
 })
@@ -314,20 +314,20 @@ test('INSTANCE_ATTR_CLASS_STYLE', () => {
     components: {
       child: {
         inheritAttrs: false,
-        template: `<div><div v-bind="$attrs" /></div>`
-      }
-    }
+        template: `<div><div v-bind="$attrs" /></div>`,
+      },
+    },
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
   expect(vm.$el.outerHTML).toBe(
-    `<div class="foo" style="color: red;"><div id="ok"></div></div>`
+    `<div class="foo" style="color: red;"><div id="ok"></div></div>`,
   )
 
   expect(
     (
       deprecationData[DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE]
         .message as Function
-    )('Anonymous')
+    )('Anonymous'),
   ).toHaveBeenWarned()
 })
index 7c248e9ddd8f029e6b0154b9b2762047599247a8..d9598be3738c040f0fe24dbc9753cea7771027b5 100644 (file)
@@ -3,7 +3,7 @@ import { nextTick } from '../../runtime-core/src/scheduler'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 import { triggerEvent } from './utils'
 import { h } from '@vue/runtime-core'
@@ -12,7 +12,7 @@ beforeEach(() => {
   toggleDeprecationWarning(true)
   Vue.configureCompat({
     MODE: 2,
-    GLOBAL_MOUNT: 'suppress-warning'
+    GLOBAL_MOUNT: 'suppress-warning',
   })
 })
 
@@ -24,23 +24,23 @@ afterEach(() => {
 test('mode as function', () => {
   const Foo = {
     name: 'Foo',
-    render: (h: any) => h('div', 'foo')
+    render: (h: any) => h('div', 'foo'),
   }
 
   const Bar = {
     name: 'Bar',
     data: () => ({ msg: 'bar' }),
-    render: (ctx: any) => h('div', ctx.msg)
+    render: (ctx: any) => h('div', ctx.msg),
   }
 
   toggleDeprecationWarning(false)
   Vue.configureCompat({
-    MODE: comp => (comp && comp.name === 'Bar' ? 3 : 2)
+    MODE: comp => (comp && comp.name === 'Bar' ? 3 : 2),
   })
 
   const vm = new Vue({
     components: { Foo, Bar },
-    template: `<div><foo/><bar/></div>`
+    template: `<div><foo/><bar/></div>`,
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -52,15 +52,15 @@ test('WATCH_ARRAY', async () => {
   const vm = new Vue({
     data() {
       return {
-        foo: []
+        foo: [],
       }
     },
     watch: {
-      foo: spy
-    }
+      foo: spy,
+    },
   }) as any
   expect(
-    deprecationData[DeprecationTypes.WATCH_ARRAY].message
+    deprecationData[DeprecationTypes.WATCH_ARRAY].message,
   ).toHaveBeenWarned()
 
   expect(spy).not.toHaveBeenCalled()
@@ -82,21 +82,21 @@ test('PROPS_DEFAULT_THIS', () => {
           thisCtx = {
             foo: this.foo,
             $options: this.$options,
-            provided: this.provided
+            provided: this.provided,
           }
           return this.foo + 1
-        }
-      }
+        },
+      },
     },
-    template: `{{ bar }}`
+    template: `{{ bar }}`,
   }
 
   const vm = new Vue({
     components: { Child },
     provide: {
-      provided: 2
+      provided: 2,
     },
-    template: `<child :foo="0" />`
+    template: `<child :foo="0" />`,
   }).$mount()
 
   expect(vm.$el.textContent).toBe('1')
@@ -109,8 +109,8 @@ test('PROPS_DEFAULT_THIS', () => {
 
   expect(
     (deprecationData[DeprecationTypes.PROPS_DEFAULT_THIS].message as Function)(
-      'bar'
-    )
+      'bar',
+    ),
   ).toHaveBeenWarned()
 })
 
@@ -118,7 +118,7 @@ test('V_ON_KEYCODE_MODIFIER', () => {
   const spy = vi.fn()
   const vm = new Vue({
     template: `<input @keyup.1="spy">`,
-    methods: { spy }
+    methods: { spy },
   }).$mount()
   expect(vm.$el).toBeInstanceOf(HTMLInputElement)
   triggerEvent(vm.$el, 'keyup', e => {
@@ -127,7 +127,7 @@ test('V_ON_KEYCODE_MODIFIER', () => {
   })
   expect(spy).toHaveBeenCalled()
   expect(
-    deprecationData[DeprecationTypes.V_ON_KEYCODE_MODIFIER].message
+    deprecationData[DeprecationTypes.V_ON_KEYCODE_MODIFIER].message,
   ).toHaveBeenWarned()
 })
 
@@ -137,7 +137,7 @@ test('CUSTOM_DIR', async () => {
     inserted: vi.fn(),
     update: vi.fn(),
     componentUpdated: vi.fn(),
-    unbind: vi.fn()
+    unbind: vi.fn(),
   } as any
 
   const getCalls = () =>
@@ -147,13 +147,13 @@ test('CUSTOM_DIR', async () => {
     data() {
       return {
         ok: true,
-        foo: 1
+        foo: 1,
       }
     },
     template: `<div v-if="ok" v-my-dir="foo"/>`,
     directives: {
-      myDir
-    }
+      myDir,
+    },
   }).$mount() as any
 
   expect(getCalls()).toMatchObject([1, 1, 0, 0, 0])
@@ -161,14 +161,14 @@ test('CUSTOM_DIR', async () => {
   expect(
     (deprecationData[DeprecationTypes.CUSTOM_DIR].message as Function)(
       'bind',
-      'beforeMount'
-    )
+      'beforeMount',
+    ),
   ).toHaveBeenWarned()
   expect(
     (deprecationData[DeprecationTypes.CUSTOM_DIR].message as Function)(
       'inserted',
-      'mounted'
-    )
+      'mounted',
+    ),
   ).toHaveBeenWarned()
 
   vm.foo++
@@ -178,39 +178,39 @@ test('CUSTOM_DIR', async () => {
   expect(
     (deprecationData[DeprecationTypes.CUSTOM_DIR].message as Function)(
       'update',
-      'updated'
-    )
+      'updated',
+    ),
   ).toHaveBeenWarned()
   expect(
     (deprecationData[DeprecationTypes.CUSTOM_DIR].message as Function)(
       'componentUpdated',
-      'updated'
-    )
+      'updated',
+    ),
   ).toHaveBeenWarned()
 })
 
 test('ATTR_FALSE_VALUE', () => {
   const vm = new Vue({
-    template: `<div :id="false" :foo="false"/>`
+    template: `<div :id="false" :foo="false"/>`,
   }).$mount()
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
   expect(vm.$el.hasAttribute('id')).toBe(false)
   expect(vm.$el.hasAttribute('foo')).toBe(false)
   expect(
     (deprecationData[DeprecationTypes.ATTR_FALSE_VALUE].message as Function)(
-      'id'
-    )
+      'id',
+    ),
   ).toHaveBeenWarned()
   expect(
     (deprecationData[DeprecationTypes.ATTR_FALSE_VALUE].message as Function)(
-      'foo'
-    )
+      'foo',
+    ),
   ).toHaveBeenWarned()
 })
 
 test('ATTR_ENUMERATED_COERCION', () => {
   const vm = new Vue({
-    template: `<div :draggable="null" :spellcheck="0" contenteditable="foo" />`
+    template: `<div :draggable="null" :spellcheck="0" contenteditable="foo" />`,
   }).$mount()
 
   expect(vm.$el).toBeInstanceOf(HTMLDivElement)
@@ -221,18 +221,18 @@ test('ATTR_ENUMERATED_COERCION', () => {
     (
       deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
         .message as Function
-    )('draggable', null, 'false')
+    )('draggable', null, 'false'),
   ).toHaveBeenWarned()
   expect(
     (
       deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
         .message as Function
-    )('spellcheck', 0, 'true')
+    )('spellcheck', 0, 'true'),
   ).toHaveBeenWarned()
   expect(
     (
       deprecationData[DeprecationTypes.ATTR_ENUMERATED_COERCION]
         .message as Function
-    )('contenteditable', 'foo', 'true')
+    )('contenteditable', 'foo', 'true'),
   ).toHaveBeenWarned()
 })
index 238f2e2d5adddabf37d143253c9fe509e29a6153..a459d4fdfcde6c93fda3a9771b93373f9542aa98 100644 (file)
@@ -3,7 +3,7 @@ import { nextTick } from '../../runtime-core/src/scheduler'
 import {
   DeprecationTypes,
   deprecationData,
-  toggleDeprecationWarning
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 
 beforeEach(() => {
@@ -11,7 +11,7 @@ beforeEach(() => {
   Vue.configureCompat({
     MODE: 2,
     GLOBAL_MOUNT: 'suppress-warning',
-    GLOBAL_EXTEND: 'suppress-warning'
+    GLOBAL_EXTEND: 'suppress-warning',
   })
 })
 
@@ -23,11 +23,11 @@ afterEach(() => {
 test('root data plain object', () => {
   const vm = new Vue({
     data: { foo: 1 } as any,
-    template: `{{ foo }}`
+    template: `{{ foo }}`,
   }).$mount()
   expect(vm.$el.textContent).toBe('1')
   expect(
-    deprecationData[DeprecationTypes.OPTIONS_DATA_FN].message
+    deprecationData[DeprecationTypes.OPTIONS_DATA_FN].message,
   ).toHaveBeenWarned()
 })
 
@@ -36,30 +36,30 @@ test('data deep merge', () => {
     data() {
       return {
         foo: {
-          baz: 2
-        }
+          baz: 2,
+        },
       }
-    }
+    },
   }
 
   const vm = new Vue({
     mixins: [mixin],
     data: () => ({
       foo: {
-        bar: 1
+        bar: 1,
       },
-      selfData: 3
+      selfData: 3,
     }),
-    template: `{{ { selfData, foo } }}`
+    template: `{{ { selfData, foo } }}`,
   }).$mount()
 
   expect(vm.$el.textContent).toBe(
-    JSON.stringify({ selfData: 3, foo: { baz: 2, bar: 1 } }, null, 2)
+    JSON.stringify({ selfData: 3, foo: { baz: 2, bar: 1 } }, null, 2),
   )
   expect(
     (deprecationData[DeprecationTypes.OPTIONS_DATA_MERGE].message as Function)(
-      'foo'
-    )
+      'foo',
+    ),
   ).toHaveBeenWarned()
 })
 
@@ -68,18 +68,18 @@ test('data deep merge w/ extended constructor', () => {
   const App = Vue.extend({
     template: `<pre>{{ { mixinData, selfData } }}</pre>`,
     mixins: [{ data: () => ({ mixinData: 'mixinData' }) }],
-    data: () => ({ selfData: 'selfData' })
+    data: () => ({ selfData: 'selfData' }),
   })
   const vm = new App().$mount()
   expect(vm.$el.textContent).toBe(
     JSON.stringify(
       {
         mixinData: 'mixinData',
-        selfData: 'selfData'
+        selfData: 'selfData',
       },
       null,
-      2
-    )
+      2,
+    ),
   )
 })
 
@@ -90,7 +90,7 @@ test('beforeDestroy/destroyed', async () => {
   const child = {
     template: `foo`,
     beforeDestroy,
-    destroyed
+    destroyed,
   }
 
   const vm = new Vue({
@@ -98,7 +98,7 @@ test('beforeDestroy/destroyed', async () => {
     data() {
       return { ok: true }
     },
-    components: { child }
+    components: { child },
   }).$mount() as any
 
   vm.ok = false
@@ -107,11 +107,11 @@ test('beforeDestroy/destroyed', async () => {
   expect(destroyed).toHaveBeenCalled()
 
   expect(
-    deprecationData[DeprecationTypes.OPTIONS_BEFORE_DESTROY].message
+    deprecationData[DeprecationTypes.OPTIONS_BEFORE_DESTROY].message,
   ).toHaveBeenWarned()
 
   expect(
-    deprecationData[DeprecationTypes.OPTIONS_DESTROYED].message
+    deprecationData[DeprecationTypes.OPTIONS_DESTROYED].message,
   ).toHaveBeenWarned()
 })
 
@@ -122,7 +122,7 @@ test('beforeDestroy/destroyed in Vue.extend components', async () => {
   const child = Vue.extend({
     template: `foo`,
     beforeDestroy,
-    destroyed
+    destroyed,
   })
 
   const vm = new Vue({
@@ -130,7 +130,7 @@ test('beforeDestroy/destroyed in Vue.extend components', async () => {
     data() {
       return { ok: true }
     },
-    components: { child }
+    components: { child },
   }).$mount() as any
 
   vm.ok = false
@@ -139,10 +139,10 @@ test('beforeDestroy/destroyed in Vue.extend components', async () => {
   expect(destroyed).toHaveBeenCalled()
 
   expect(
-    deprecationData[DeprecationTypes.OPTIONS_BEFORE_DESTROY].message
+    deprecationData[DeprecationTypes.OPTIONS_BEFORE_DESTROY].message,
   ).toHaveBeenWarned()
 
   expect(
-    deprecationData[DeprecationTypes.OPTIONS_DESTROYED].message
+    deprecationData[DeprecationTypes.OPTIONS_DESTROYED].message,
   ).toHaveBeenWarned()
 })
index 9b3d146659753456cc1ee3e7e26e2921b884bc04..04d8aaac19e5e2a0bdb26ac3ab02c737066bb3de 100644 (file)
@@ -2,12 +2,12 @@ import { ShapeFlags } from '@vue/shared'
 import Vue from '@vue/compat'
 import { createComponentInstance } from '../../runtime-core/src/component'
 import { setCurrentRenderingInstance } from '../../runtime-core/src/componentRenderContext'
-import { DirectiveBinding } from '../../runtime-core/src/directives'
+import type { DirectiveBinding } from '../../runtime-core/src/directives'
 import { createVNode } from '../../runtime-core/src/vnode'
 import {
-  deprecationData,
   DeprecationTypes,
-  toggleDeprecationWarning
+  deprecationData,
+  toggleDeprecationWarning,
 } from '../../runtime-core/src/compat/compatConfig'
 import { compatH as h } from '../../runtime-core/src/compat/renderFn'
 
@@ -15,7 +15,7 @@ beforeEach(() => {
   toggleDeprecationWarning(false)
   Vue.configureCompat({
     MODE: 2,
-    GLOBAL_MOUNT: 'suppress-warning'
+    GLOBAL_MOUNT: 'suppress-warning',
   })
 })
 
@@ -29,16 +29,16 @@ describe('compat: render function', () => {
   const mockChildComp = {}
   const mockComponent = {
     directives: {
-      mockDir
+      mockDir,
     },
     components: {
-      foo: mockChildComp
-    }
+      foo: mockChildComp,
+    },
   }
   const mockInstance = createComponentInstance(
     createVNode(mockComponent),
     null,
-    null
+    null,
   )
   beforeEach(() => {
     setCurrentRenderingInstance(mockInstance)
@@ -49,7 +49,7 @@ describe('compat: render function', () => {
 
   test('string component lookup', () => {
     expect(h('foo')).toMatchObject({
-      type: mockChildComp
+      type: mockChildComp,
     })
   })
 
@@ -59,23 +59,23 @@ describe('compat: render function', () => {
         class: 'foo',
         style: { color: 'red' },
         attrs: {
-          id: 'foo'
+          id: 'foo',
         },
         domProps: {
-          innerHTML: 'hi'
+          innerHTML: 'hi',
         },
         props: {
-          myProp: 'foo'
-        }
-      })
+          myProp: 'foo',
+        },
+      }),
     ).toMatchObject({
       props: {
         class: 'foo',
         style: { color: 'red' },
         id: 'foo',
         innerHTML: 'hi',
-        myProp: 'foo'
-      }
+        myProp: 'foo',
+      },
     })
   })
 
@@ -83,12 +83,12 @@ describe('compat: render function', () => {
     expect(
       h('div', {
         class: { foo: true },
-        staticClass: 'bar'
-      })
+        staticClass: 'bar',
+      }),
     ).toMatchObject({
       props: {
-        class: 'bar foo'
-      }
+        class: 'bar foo',
+      },
     })
   })
 
@@ -96,15 +96,15 @@ describe('compat: render function', () => {
     expect(
       h('div', {
         style: { color: 'red' },
-        staticStyle: { fontSize: '14px' }
-      })
+        staticStyle: { fontSize: '14px' },
+      }),
     ).toMatchObject({
       props: {
         style: {
           color: 'red',
-          fontSize: '14px'
-        }
-      }
+          fontSize: '14px',
+        },
+      },
     })
   })
 
@@ -114,20 +114,20 @@ describe('compat: render function', () => {
       h('div', {
         on: {
           click: fn,
-          fooBar: fn
+          fooBar: fn,
         },
         nativeOn: {
           click: fn,
-          'bar-baz': fn
-        }
-      })
+          'bar-baz': fn,
+        },
+      }),
     ).toMatchObject({
       props: {
         onClick: fn,
         onClickNative: fn,
         onFooBar: fn,
-        'onBar-bazNative': fn
-      }
+        'onBar-bazNative': fn,
+      },
     })
   })
 
@@ -138,15 +138,15 @@ describe('compat: render function', () => {
         on: {
           '&click': fn,
           '~keyup': fn,
-          '!touchend': fn
-        }
-      })
+          '!touchend': fn,
+        },
+      }),
     ).toMatchObject({
       props: {
         onClickPassive: fn,
         onKeyupOnce: fn,
-        onTouchendCapture: fn
-      }
+        onTouchendCapture: fn,
+      },
     })
   })
 
@@ -160,11 +160,11 @@ describe('compat: render function', () => {
             // expression: '1 + 1',
             arg: 'foo',
             modifiers: {
-              bar: true
-            }
-          }
-        ]
-      })
+              bar: true,
+            },
+          },
+        ],
+      }),
     ).toMatchObject({
       dirs: [
         {
@@ -174,22 +174,22 @@ describe('compat: render function', () => {
           oldValue: void 0,
           arg: 'foo',
           modifiers: {
-            bar: true
-          }
-        }
-      ] as DirectiveBinding[]
+            bar: true,
+          },
+        },
+      ] as DirectiveBinding[],
     })
   })
 
   test('scopedSlots', () => {
     const scopedSlots = {
-      default() {}
+      default() {},
     }
     const vnode = h(mockComponent, {
-      scopedSlots
+      scopedSlots,
     })
     expect(vnode).toMatchObject({
-      children: scopedSlots
+      children: scopedSlots,
     })
     expect('scopedSlots' in vnode.props!).toBe(false)
     expect(vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN).toBeTruthy()
@@ -201,7 +201,7 @@ describe('compat: render function', () => {
       h('div', { slot: 'foo' }, 'one'),
       h('div', { slot: 'bar' }, 'two'),
       h('div', { slot: 'foo' }, 'three'),
-      h('div', 'four')
+      h('div', 'four'),
     ])
     expect(vnode.shapeFlag & ShapeFlags.SLOTS_CHILDREN).toBeTruthy()
     const slots = vnode.children as any
@@ -210,7 +210,7 @@ describe('compat: render function', () => {
     expect(slots.default()).toMatchObject(['text', { children: 'four' }])
     expect(slots.foo()).toMatchObject([
       { children: 'one' },
-      { children: 'three' }
+      { children: 'three' },
     ])
     expect(slots.bar()).toMatchObject([{ children: 'two' }])
   })
@@ -224,16 +224,16 @@ describe('compat: render function', () => {
           'div',
           {
             class: 'foo',
-            attrs: { id: 'bar' }
+            attrs: { id: 'bar' },
           },
-          'hello'
+          'hello',
         )
-      }
+      },
     }).$mount()
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
     expect(vm.$el.outerHTML).toBe(`<div class="foo" id="bar">hello</div>`)
     expect(
-      deprecationData[DeprecationTypes.RENDER_FUNCTION].message
+      deprecationData[DeprecationTypes.RENDER_FUNCTION].message,
     ).toHaveBeenWarned()
   })
 
@@ -241,13 +241,13 @@ describe('compat: render function', () => {
     const vm = new Vue({
       data() {
         return {
-          a: 'hello'
+          a: 'hello',
         }
       },
       // check is arg length based
       render(c: any, _c: any) {
         return createVNode('div', null, c.a)
-      }
+      },
     }).$mount()
     expect(vm.$el).toBeInstanceOf(HTMLDivElement)
     expect(vm.$el.outerHTML).toBe(`<div>hello</div>`)
index a7242122bcbc2a18b597d50222126fc306c3e79f..18e6516a4a66420639d26756a23c5f14ca2835ea 100644 (file)
@@ -1,11 +1,11 @@
 export function triggerEvent(
   target: Element,
   event: string,
-  process?: (e: any) => any
+  process?: (e: any) => any,
 ) {
   const e = new Event(event, {
     bubbles: true,
-    cancelable: true
+    cancelable: true,
   })
   if (process) process(e)
   target.dispatchEvent(e)
index 5815fc21dc6b2c8f02c181255312507c6c6fecfb..3144a529de66f571d8262de098a3d0e8a03f2063 100644 (file)
@@ -2,14 +2,14 @@
 // `dist/vue.esm-bundler.js` which is used by default for bundlers.
 import { initDev } from './dev'
 import {
-  compatUtils,
-  createApp,
+  DeprecationTypes,
+  KeepAlive,
   Transition,
   TransitionGroup,
-  KeepAlive,
-  DeprecationTypes,
+  compatUtils,
+  createApp,
+  vModelDynamic,
   vShow,
-  vModelDynamic
 } from '@vue/runtime-dom'
 import { extend } from '@vue/shared'
 
@@ -20,7 +20,7 @@ if (__DEV__) {
 import * as runtimeDom from '@vue/runtime-dom'
 
 function wrappedCreateApp(...args: any[]) {
-  // @ts-ignore
+  // @ts-expect-error
   const app = createApp(...args)
   if (compatUtils.isCompatEnabled(DeprecationTypes.RENDER_FUNCTION, null)) {
     // register built-in components so that they can be resolved via strings
index 99ba49a20851c03dcbd4846868be77498ad43e6a..22e1c6c3858509fc8988505222280a73fc4c574a 100644 (file)
@@ -5,7 +5,7 @@ export function initDev() {
     if (!__ESM_BUNDLER__) {
       console.info(
         `You are running a development build of Vue.\n` +
-          `Make sure to use the production build (*.prod.js) when deploying for production.`
+          `Make sure to use the production build (*.prod.js) when deploying for production.`,
       )
     }
 
index 642ecd20d1192e2e4b3a98a2f1b6420cc12224c3..70608b7e646fbb9d500ed1c6939c509bf290f8c4 100644 (file)
@@ -1,21 +1,29 @@
 // This entry is the "full-build" that includes both the runtime
 // and the compiler, and supports on-the-fly compilation of the template option.
 import { createCompatVue } from './createCompatVue'
-import { compile, CompilerError, CompilerOptions } from '@vue/compiler-dom'
-import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
-import { isString, NOOP, generateCodeFrame, extend } from '@vue/shared'
-import { InternalRenderFunction } from 'packages/runtime-core/src/component'
+import {
+  type CompilerError,
+  type CompilerOptions,
+  compile,
+} from '@vue/compiler-dom'
+import {
+  type RenderFunction,
+  registerRuntimeCompiler,
+  warn,
+} from '@vue/runtime-dom'
+import { NOOP, extend, generateCodeFrame, isString } from '@vue/shared'
+import type { InternalRenderFunction } from 'packages/runtime-core/src/component'
 import * as runtimeDom from '@vue/runtime-dom'
 import {
   DeprecationTypes,
-  warnDeprecation
+  warnDeprecation,
 } from '../../runtime-core/src/compat/compatConfig'
 
 const compileCache: Record<string, RenderFunction> = Object.create(null)
 
 function compileToFunction(
   template: string | HTMLElement,
-  options?: CompilerOptions
+  options?: CompilerOptions,
 ): RenderFunction {
   if (!isString(template)) {
     if (template.nodeType) {
@@ -55,10 +63,10 @@ function compileToFunction(
         hoistStatic: true,
         whitespace: 'preserve',
         onError: __DEV__ ? onError : undefined,
-        onWarn: __DEV__ ? e => onError(e, true) : NOOP
+        onWarn: __DEV__ ? e => onError(e, true) : NOOP,
       } as CompilerOptions,
-      options
-    )
+      options,
+    ),
   )
 
   function onError(err: CompilerError, asWarning = false) {
@@ -70,7 +78,7 @@ function compileToFunction(
       generateCodeFrame(
         template as string,
         err.loc.start.offset,
-        err.loc.end.offset
+        err.loc.end.offset,
       )
     warn(codeFrame ? `${message}\n${codeFrame}` : message)
   }
index 76370b84784162272551a750f055eb05aeaa35bb..9b52d0de6c3b64541069e71f31c2a802025d70f2 100644 (file)
@@ -15,7 +15,7 @@ Vue.compile = (() => {
             ? ` Use "vue.esm-browser.js" instead.`
             : __GLOBAL__
               ? ` Use "vue.global.js" instead.`
-              : ``) /* should not happen */
+              : ``) /* should not happen */,
     )
   }
 }) as any
index cf3efd094e47faa468b622d34bdae701a0301f5b..7712099bff44c8d79fe1e8df69ad0aca6274a73a 100644 (file)
@@ -12,7 +12,7 @@ test('custom element event casing', () => {
         this.dispatchEvent(new Event('CAPScase'))
         this.dispatchEvent(new Event('PascalCase'))
       }
-    }
+    },
   )
 
   const container = document.createElement('div')
@@ -33,8 +33,8 @@ test('custom element event casing', () => {
       }" />`,
     methods: {
       handler,
-      handler2
-    }
+      handler2,
+    },
   }).mount(container)
 
   expect(handler).toHaveBeenCalledTimes(3)
index 58797d82e732629a4be0d9a465dfbaba948022cd..24c818e2eede83c7ded8992aa7dc701109f36caf 100644 (file)
@@ -1,6 +1,6 @@
 import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
-import path from 'path'
-import { h, createApp, Transition, ref, nextTick } from 'vue'
+import path from 'node:path'
+import { Transition, createApp, h, nextTick, ref } from 'vue'
 
 describe('e2e: Transition', () => {
   const { page, html, classList, isVisible, timeout, nextFrame, click } =
@@ -46,7 +46,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -55,13 +55,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'v-leave-from',
-          'v-leave-active'
+          'v-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'v-leave-active',
-          'v-leave-to'
+          'v-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -70,18 +70,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'v-enter-from',
-          'v-enter-active'
+          'v-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'v-enter-active',
-          'v-enter-to'
+          'v-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -102,7 +102,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -111,13 +111,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -126,18 +126,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -163,7 +163,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -172,13 +172,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'bye-from',
-          'bye-active'
+          'bye-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'bye-active',
-          'bye-to'
+          'bye-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -187,18 +187,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'hello-from',
-          'hello-active'
+          'hello-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'hello-active',
-          'hello-to'
+          'hello-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -222,7 +222,7 @@ describe('e2e: Transition', () => {
               const click = () => (toggle.value = !toggle.value)
               const changeName = () => (name.value = 'changed')
               return { toggle, click, name, changeName }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -231,13 +231,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -249,18 +249,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'changed-enter-from',
-          'changed-enter-active'
+          'changed-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'changed-enter-active',
-          'changed-enter-to'
+          'changed-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -287,7 +287,7 @@ describe('e2e: Transition', () => {
             afterEnterSpy,
             beforeLeaveSpy,
             onLeaveSpy,
-            afterLeaveSpy
+            afterLeaveSpy,
           } = window as any
           const { createApp, ref } = (window as any).Vue
           createApp({
@@ -317,9 +317,9 @@ describe('e2e: Transition', () => {
                 afterEnterSpy,
                 beforeLeaveSpy,
                 onLeaveSpy,
-                afterLeaveSpy
+                afterLeaveSpy,
               }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -328,7 +328,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         expect(beforeLeaveSpy).toBeCalled()
         expect(onLeaveSpy).toBeCalled()
@@ -337,7 +337,7 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         expect(afterLeaveSpy).not.toBeCalled()
         await transitionFinish()
@@ -348,7 +348,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         expect(beforeEnterSpy).toBeCalled()
         expect(onEnterSpy).toBeCalled()
@@ -357,14 +357,14 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         expect(afterEnterSpy).not.toBeCalled()
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
         expect(afterEnterSpy).toBeCalled()
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -391,7 +391,7 @@ describe('e2e: Transition', () => {
             afterEnterSpy,
             beforeLeaveSpy,
             onLeaveSpy,
-            afterLeaveSpy
+            afterLeaveSpy,
           } = window as any
           const { createApp, ref } = (window as any).Vue
           createApp({
@@ -441,9 +441,9 @@ describe('e2e: Transition', () => {
                 },
                 afterLeaveSpy: (el: Element) => {
                   afterLeaveSpy()
-                }
+                },
               }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -456,7 +456,7 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'before-leave',
-          'leave'
+          'leave',
         ])
 
         await timeout(200 + buffer)
@@ -471,16 +471,16 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'before-enter',
-          'enter'
+          'enter',
         ])
 
         await timeout(200 + buffer)
         expect(afterEnterSpy).toBeCalled()
         expect(await html('#container')).toBe(
-          '<div class="test before-enter enter after-enter">content</div>'
+          '<div class="test before-enter enter after-enter">content</div>',
         )
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test('onEnterCancelled', async () => {
@@ -508,9 +508,9 @@ describe('e2e: Transition', () => {
             return {
               toggle,
               click,
-              enterCancelledSpy
+              enterCancelledSpy,
             }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe('<!--v-if-->')
@@ -519,27 +519,27 @@ describe('e2e: Transition', () => {
       expect(await classWhenTransitionStart()).toStrictEqual([
         'test',
         'test-enter-from',
-        'test-enter-active'
+        'test-enter-active',
       ])
       await nextFrame()
       expect(await classList('.test')).toStrictEqual([
         'test',
         'test-enter-active',
-        'test-enter-to'
+        'test-enter-to',
       ])
 
       // cancel (leave)
       expect(await classWhenTransitionStart()).toStrictEqual([
         'test',
         'test-leave-from',
-        'test-leave-active'
+        'test-leave-active',
       ])
       expect(enterCancelledSpy).toBeCalled()
       await nextFrame()
       expect(await classList('.test')).toStrictEqual([
         'test',
         'test-leave-active',
-        'test-leave-to'
+        'test-leave-to',
       ])
       await transitionFinish()
       expect(await html('#container')).toBe('<!--v-if-->')
@@ -567,7 +567,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
           return Promise.resolve().then(() => {
             return document.querySelector('.test')!.className.split(/\s+/g)
@@ -577,13 +577,13 @@ describe('e2e: Transition', () => {
         expect(appearClass).toStrictEqual([
           'test',
           'test-appear-from',
-          'test-appear-active'
+          'test-appear-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-appear-active',
-          'test-appear-to'
+          'test-appear-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -592,13 +592,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -607,18 +607,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -654,7 +654,7 @@ describe('e2e: Transition', () => {
             afterEnterSpy,
             beforeLeaveSpy,
             onLeaveSpy,
-            afterLeaveSpy
+            afterLeaveSpy,
           } = window as any
           const { createApp, ref } = (window as any).Vue
           createApp({
@@ -694,9 +694,9 @@ describe('e2e: Transition', () => {
                 afterEnterSpy,
                 beforeLeaveSpy,
                 onLeaveSpy,
-                afterLeaveSpy
+                afterLeaveSpy,
               }
-            }
+            },
           }).mount('#app')
           return Promise.resolve().then(() => {
             return document.querySelector('.test')!.className.split(/\s+/g)
@@ -706,7 +706,7 @@ describe('e2e: Transition', () => {
         expect(appearClass).toStrictEqual([
           'test',
           'test-appear-from',
-          'test-appear-active'
+          'test-appear-active',
         ])
         expect(beforeAppearSpy).toBeCalled()
         expect(onAppearSpy).toBeCalled()
@@ -715,7 +715,7 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-appear-active',
-          'test-appear-to'
+          'test-appear-to',
         ])
         expect(afterAppearSpy).not.toBeCalled()
         await transitionFinish()
@@ -730,7 +730,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         expect(beforeLeaveSpy).toBeCalled()
         expect(onLeaveSpy).toBeCalled()
@@ -739,7 +739,7 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         expect(afterLeaveSpy).not.toBeCalled()
         await transitionFinish()
@@ -750,7 +750,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         expect(beforeEnterSpy).toBeCalled()
         expect(onEnterSpy).toBeCalled()
@@ -759,14 +759,14 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         expect(afterEnterSpy).not.toBeCalled()
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
         expect(afterEnterSpy).toBeCalled()
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -793,7 +793,7 @@ describe('e2e: Transition', () => {
             onAfterEnterSpy,
             onBeforeLeaveSpy,
             onLeaveSpy,
-            onAfterLeaveSpy
+            onAfterLeaveSpy,
           } = window as any
           const { createApp, ref } = (window as any).Vue
           createApp({
@@ -824,9 +824,9 @@ describe('e2e: Transition', () => {
                 onAfterEnterSpy,
                 onBeforeLeaveSpy,
                 onLeaveSpy,
-                onAfterLeaveSpy
+                onAfterLeaveSpy,
               }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -844,7 +844,7 @@ describe('e2e: Transition', () => {
         expect(onAfterEnterSpy).toBeCalled()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -865,7 +865,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div>content</div>')
@@ -873,7 +873,7 @@ describe('e2e: Transition', () => {
         // leave
         expect(await classWhenTransitionStart()).toStrictEqual([
           'noop-leave-from',
-          'noop-leave-active'
+          'noop-leave-active',
         ])
         await nextFrame()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -881,12 +881,12 @@ describe('e2e: Transition', () => {
         // enter
         expect(await classWhenTransitionStart()).toStrictEqual([
           'noop-enter-from',
-          'noop-enter-active'
+          'noop-enter-active',
         ])
         await nextFrame()
         expect(await html('#container')).toBe('<div class="">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -907,7 +907,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div>content</div>')
@@ -915,12 +915,12 @@ describe('e2e: Transition', () => {
         // leave
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test-anim-leave-from',
-          'test-anim-leave-active'
+          'test-anim-leave-active',
         ])
         await nextFrame()
         expect(await classList('#container div')).toStrictEqual([
           'test-anim-leave-active',
-          'test-anim-leave-to'
+          'test-anim-leave-to',
         ])
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -928,17 +928,17 @@ describe('e2e: Transition', () => {
         // enter
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test-anim-enter-from',
-          'test-anim-enter-active'
+          'test-anim-enter-active',
         ])
         await nextFrame()
         expect(await classList('#container div')).toStrictEqual([
           'test-anim-enter-active',
-          'test-anim-enter-to'
+          'test-anim-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -955,7 +955,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div>content</div>')
@@ -963,12 +963,12 @@ describe('e2e: Transition', () => {
         // leave
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test-anim-long-leave-from',
-          'test-anim-long-leave-active'
+          'test-anim-long-leave-active',
         ])
         await nextFrame()
         expect(await classList('#container div')).toStrictEqual([
           'test-anim-long-leave-active',
-          'test-anim-long-leave-to'
+          'test-anim-long-leave-to',
         ])
 
         if (!process.env.CI) {
@@ -977,7 +977,7 @@ describe('e2e: Transition', () => {
           })
           expect(await classList('#container div')).toStrictEqual([
             'test-anim-long-leave-active',
-            'test-anim-long-leave-to'
+            'test-anim-long-leave-to',
           ])
         }
 
@@ -987,12 +987,12 @@ describe('e2e: Transition', () => {
         // enter
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test-anim-long-enter-from',
-          'test-anim-long-enter-active'
+          'test-anim-long-enter-active',
         ])
         await nextFrame()
         expect(await classList('#container div')).toStrictEqual([
           'test-anim-long-enter-active',
-          'test-anim-long-enter-to'
+          'test-anim-long-enter-to',
         ])
 
         if (!process.env.CI) {
@@ -1001,14 +1001,14 @@ describe('e2e: Transition', () => {
           })
           expect(await classList('#container div')).toStrictEqual([
             'test-anim-long-enter-active',
-            'test-anim-long-enter-to'
+            'test-anim-long-enter-to',
           ])
         }
 
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<div class="">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1029,11 +1029,11 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe(
-          '<circle cx="0" cy="0" r="10" class="test"></circle>'
+          '<circle cx="0" cy="0" r="10" class="test"></circle>',
         )
 
         const svgTransitionStart = () =>
@@ -1051,13 +1051,13 @@ describe('e2e: Transition', () => {
         expect(await svgTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -1066,20 +1066,20 @@ describe('e2e: Transition', () => {
         expect(await svgTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe(
-          '<circle cx="0" cy="0" r="10" class="test"></circle>'
+          '<circle cx="0" cy="0" r="10" class="test"></circle>',
         )
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1095,13 +1095,13 @@ describe('e2e: Transition', () => {
             components: {
               'my-transition': (props: any, { slots }: any) => {
                 return h(Transition, { name: 'test' }, slots)
-              }
+              },
             },
             setup: () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1110,13 +1110,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -1125,18 +1125,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1156,11 +1156,11 @@ describe('e2e: Transition', () => {
             `,
             components: {
               one: {
-                template: '<div v-if="false">one</div>'
+                template: '<div v-if="false">one</div>',
               },
               two: {
-                template: '<div>two</div>'
-              }
+                template: '<div>two</div>',
+              },
             },
             setup: () => {
               const toggle = ref(true)
@@ -1169,7 +1169,7 @@ describe('e2e: Transition', () => {
               const change = () =>
                 (view.value = view.value === 'one' ? 'two' : 'one')
               return { toggle, click, change, view }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -1182,13 +1182,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">two</div>')
@@ -1201,18 +1201,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
   })
 
@@ -1245,21 +1245,21 @@ describe('e2e: Transition', () => {
               Comp: {
                 async setup() {
                   return () => h('div', { class: 'test' }, 'content')
-                }
-              }
+                },
+              },
             },
             setup: () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click, onEnterSpy, onLeaveSpy }
-            }
+            },
           }).mount('#app')
         })
 
         expect(onEnterSpy).toBeCalledTimes(1)
         await nextFrame()
         expect(await html('#container')).toBe(
-          '<div class="test v-enter-active v-enter-to">content</div>'
+          '<div class="test v-enter-active v-enter-to">content</div>',
         )
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1268,14 +1268,14 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'v-leave-from',
-          'v-leave-active'
+          'v-leave-active',
         ])
         expect(onLeaveSpy).toBeCalledTimes(1)
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'v-leave-active',
-          'v-leave-to'
+          'v-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -1296,19 +1296,19 @@ describe('e2e: Transition', () => {
         expect(enterClass).toStrictEqual([
           'test',
           'v-enter-from',
-          'v-enter-active'
+          'v-enter-active',
         ])
         expect(onEnterSpy).toBeCalledTimes(2)
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'v-enter-active',
-          'v-enter-to'
+          'v-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     // #1689
@@ -1332,7 +1332,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1341,13 +1341,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'v-leave-from',
-          'v-leave-active'
+          'v-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'v-leave-active',
-          'v-leave-to'
+          'v-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -1356,18 +1356,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'v-enter-from',
-          'v-enter-active'
+          'v-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'v-enter-active',
-          'v-enter-to'
+          'v-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1384,12 +1384,12 @@ describe('e2e: Transition', () => {
           const One = {
             async setup() {
               return () => h('div', { class: 'test' }, 'one')
-            }
+            },
           }
           const Two = {
             async setup() {
               return () => h('div', { class: 'test' }, 'two')
-            }
+            },
           }
           createApp({
             template: `
@@ -1408,13 +1408,13 @@ describe('e2e: Transition', () => {
                 view.value = view.value === One ? Two : One
               }
               return { view, click }
-            }
+            },
           }).mount('#app')
         })
 
         await nextFrame()
         expect(await html('#container')).toBe(
-          '<div class="test v-enter-active v-enter-to">one</div>'
+          '<div class="test v-enter-active v-enter-to">one</div>',
         )
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">one</div>')
@@ -1423,7 +1423,7 @@ describe('e2e: Transition', () => {
         await classWhenTransitionStart()
         await nextFrame()
         expect(await html('#container')).toBe(
-          '<div class="test v-leave-active v-leave-to">one</div>'
+          '<div class="test v-leave-active v-leave-to">one</div>',
         )
         await transitionFinish()
         await nextFrame()
@@ -1433,7 +1433,7 @@ describe('e2e: Transition', () => {
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">two</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     // #3963
@@ -1447,13 +1447,13 @@ describe('e2e: Transition', () => {
             template: `<div>{{ msg }}</div>`,
             setup() {
               return new Promise(_resolve => {
-                // @ts-ignore
+                // @ts-expect-error
                 window.resolve = () =>
                   _resolve({
-                    msg: 'success'
+                    msg: 'success',
                   })
               })
-            }
+            },
           }
 
           createApp({
@@ -1478,7 +1478,7 @@ describe('e2e: Transition', () => {
                 view.value = view.value ? null : h(One)
               }
               return { view, click }
-            }
+            },
           }).mount('#app')
         })
 
@@ -1489,14 +1489,14 @@ describe('e2e: Transition', () => {
         expect(await html('#container')).toBe('<div class="">Loading...</div>')
 
         await page().evaluate(() => {
-          // @ts-ignore
+          // @ts-expect-error
           window.resolve()
         })
 
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<div class="">success</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     // #5844
@@ -1530,12 +1530,12 @@ describe('e2e: Transition', () => {
                   fooMountSpy(
                     !!el.value,
                     !!document.getElementById('foo'),
-                    !!document.getElementById('bar')
+                    !!document.getElementById('bar'),
                   )
                 })
 
                 return () => h('div', { ref: el, id: 'foo' }, 'Foo')
-              }
+              },
             },
             Bar: {
               setup() {
@@ -1544,19 +1544,19 @@ describe('e2e: Transition', () => {
                   barMountSpy(
                     !!el.value,
                     !!document.getElementById('foo'),
-                    !!document.getElementById('bar')
+                    !!document.getElementById('bar'),
                   )
                 })
 
                 return () => h('div', { ref: el, id: 'bar' }, 'Bar')
-              }
-            }
+              },
+            },
           },
           setup: () => {
             const toggle = ref(true)
             const click = () => (toggle.value = !toggle.value)
             return { toggle, click }
-          }
+          },
         }).mount('#app')
       })
 
@@ -1596,12 +1596,12 @@ describe('e2e: Transition', () => {
           const One = {
             async setup() {
               return () => h('div', { class: 'test' }, 'one')
-            }
+            },
           }
           const Two = {
             async setup() {
               return () => h('div', { class: 'test' }, 'two')
-            }
+            },
           }
           createApp({
             template: `
@@ -1620,13 +1620,13 @@ describe('e2e: Transition', () => {
                 view.value = view.value === One ? Two : One
               }
               return { view, click }
-            }
+            },
           }).mount('#app')
         }, duration)
 
         await nextFrame()
         expect(await html('#container')).toBe(
-          '<div class="test test-enter-active test-enter-to">one</div>'
+          '<div class="test test-enter-active test-enter-to">one</div>',
         )
 
         await transitionFinish()
@@ -1637,20 +1637,20 @@ describe('e2e: Transition', () => {
         classWhenTransitionStart()
         await nextFrame()
         expect(await html('#container')).toBe(
-          '<div class="test test-leave-active test-leave-to">one</div>'
+          '<div class="test test-leave-active test-leave-to">one</div>',
         )
 
         await transitionFinish()
         await nextFrame()
         expect(await html('#container')).toBe(
-          '<div class="test test-enter-active test-enter-to">one</div>'
+          '<div class="test test-enter-active test-enter-to">one</div>',
         )
 
         await transitionFinish()
         await nextFrame()
         expect(await html('#container')).toBe('<div class="test">one</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
   })
 
@@ -1673,7 +1673,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1683,13 +1683,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await isVisible('.test')).toBe(false)
@@ -1698,20 +1698,20 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe(
-          '<div class="test" style="">content</div>'
+          '<div class="test" style="">content</div>',
         )
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1738,7 +1738,7 @@ describe('e2e: Transition', () => {
             afterEnterSpy,
             beforeLeaveSpy,
             onLeaveSpy,
-            afterLeaveSpy
+            afterLeaveSpy,
           } = window as any
           const { createApp, ref } = (window as any).Vue
           createApp({
@@ -1768,9 +1768,9 @@ describe('e2e: Transition', () => {
                 afterEnterSpy,
                 beforeLeaveSpy,
                 onLeaveSpy,
-                afterLeaveSpy
+                afterLeaveSpy,
               }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1779,7 +1779,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         expect(beforeLeaveSpy).toBeCalled()
         expect(onLeaveSpy).toBeCalled()
@@ -1788,7 +1788,7 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         expect(afterLeaveSpy).not.toBeCalled()
         await transitionFinish()
@@ -1799,7 +1799,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         expect(beforeEnterSpy).toBeCalled()
         expect(onEnterSpy).toBeCalled()
@@ -1808,16 +1808,16 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         expect(afterEnterSpy).not.toBeCalled()
         await transitionFinish()
         expect(await html('#container')).toBe(
-          '<div class="test" style="">content</div>'
+          '<div class="test" style="">content</div>',
         )
         expect(afterEnterSpy).toBeCalled()
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1842,7 +1842,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click, onLeaveCancelledSpy }
-            }
+            },
           }).mount('#app')
         })
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1852,34 +1852,34 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
 
         // cancel (enter)
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         expect(onLeaveCancelledSpy).toBeCalled()
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe(
-          '<div class="test" style="">content</div>'
+          '<div class="test" style="">content</div>',
         )
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -1920,9 +1920,9 @@ describe('e2e: Transition', () => {
                 click,
                 beforeEnterSpy,
                 onEnterSpy,
-                afterEnterSpy
+                afterEnterSpy,
               }
-            }
+            },
           }).mount('#app')
           return Promise.resolve().then(() => {
             return document.querySelector('.test')!.className.split(/\s+/g)
@@ -1937,13 +1937,13 @@ describe('e2e: Transition', () => {
         expect(appearClass).toStrictEqual([
           'test',
           'test-appear-from',
-          'test-appear-active'
+          'test-appear-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-appear-active',
-          'test-appear-to'
+          'test-appear-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -1956,13 +1956,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await isVisible('.test')).toBe(false)
@@ -1971,20 +1971,20 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe(
-          '<div class="test" style="">content</div>'
+          '<div class="test" style="">content</div>',
         )
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     // #4845
@@ -2024,9 +2024,9 @@ describe('e2e: Transition', () => {
                 click,
                 beforeEnterSpy,
                 onEnterSpy,
-                afterEnterSpy
+                afterEnterSpy,
               }
-            }
+            },
           }).mount('#app')
         })
         await nextTick()
@@ -2039,7 +2039,7 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         expect(beforeEnterSpy).toBeCalledTimes(1)
         expect(onEnterSpy).toBeCalledTimes(1)
@@ -2048,16 +2048,16 @@ describe('e2e: Transition', () => {
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         expect(afterEnterSpy).not.toBeCalled()
         await transitionFinish()
         expect(await html('#container')).toBe(
-          '<div class="test" style="">content</div>'
+          '<div class="test" style="">content</div>',
         )
         expect(afterEnterSpy).toBeCalled()
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
   })
 
@@ -2080,7 +2080,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         }, duration)
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -2089,13 +2089,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -2104,18 +2104,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -2136,7 +2136,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         }, duration)
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -2145,13 +2145,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -2160,18 +2160,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -2192,7 +2192,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         }, duration)
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -2201,13 +2201,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -2216,18 +2216,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish()
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -2251,7 +2251,7 @@ describe('e2e: Transition', () => {
               const toggle = ref(true)
               const click = () => (toggle.value = !toggle.value)
               return { toggle, click }
-            }
+            },
           }).mount('#app')
         }, duration)
         expect(await html('#container')).toBe('<div class="test">content</div>')
@@ -2260,13 +2260,13 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-leave-from',
-          'test-leave-active'
+          'test-leave-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-leave-active',
-          'test-leave-to'
+          'test-leave-to',
         ])
         await transitionFinish(duration * 2)
         expect(await html('#container')).toBe('<!--v-if-->')
@@ -2275,18 +2275,18 @@ describe('e2e: Transition', () => {
         expect(await classWhenTransitionStart()).toStrictEqual([
           'test',
           'test-enter-from',
-          'test-enter-active'
+          'test-enter-active',
         ])
         await nextFrame()
         expect(await classList('.test')).toStrictEqual([
           'test',
           'test-enter-active',
-          'test-enter-to'
+          'test-enter-to',
         ])
         await transitionFinish(duration * 4)
         expect(await html('#container')).toBe('<div class="test">content</div>')
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
 
     test(
@@ -2299,11 +2299,11 @@ describe('e2e: Transition', () => {
                 <div class="test">content</div>
               </transition>
             </div>
-          `
+          `,
         }).mount(document.createElement('div'))
         expect(
           `[Vue warn]: <transition> explicit duration is NaN - ` +
-            'the duration expression might be incorrect.'
+            'the duration expression might be incorrect.',
         ).toHaveBeenWarned()
 
         createApp({
@@ -2316,14 +2316,14 @@ describe('e2e: Transition', () => {
                 <div class="test">content</div>
               </transition>
             </div>
-          `
+          `,
         }).mount(document.createElement('div'))
         expect(
           `[Vue warn]: <transition> explicit duration is not a valid number - ` +
-            `got ${JSON.stringify({})}`
+            `got ${JSON.stringify({})}`,
         ).toHaveBeenWarned()
       },
-      E2E_TIMEOUT
+      E2E_TIMEOUT,
     )
   })
 
@@ -2331,12 +2331,12 @@ describe('e2e: Transition', () => {
     createApp({
       render() {
         return h(Transition, null, {
-          default: () => [h('div'), h('div')]
+          default: () => [h('div'), h('div')],
         })
-      }
+      },
     }).mount(document.createElement('div'))
     expect(
-      '<transition> can only be used on a single element or component'
+      '<transition> can only be used on a single element or component',
     ).toHaveBeenWarned()
   })
 
@@ -2348,7 +2348,7 @@ describe('e2e: Transition', () => {
             <div class="test">content</div>
           </transition>
         </div>
-      `
+      `,
     }).mount(document.createElement('div'))
     expect(`invalid <transition> mode: none`).toHaveBeenWarned()
   })
@@ -2366,11 +2366,11 @@ describe('e2e: Transition', () => {
             onLeave(el, end) {
               innerSpy()
               end()
-            }
+            },
           },
-          this.$slots.default
+          this.$slots.default,
         )
-      }
+      },
     }
 
     const toggle = ref(true)
@@ -2379,9 +2379,9 @@ describe('e2e: Transition', () => {
     createApp({
       render() {
         return h(MyTransition, { onLeave: () => outerSpy() }, () =>
-          toggle.value ? h('div') : null
+          toggle.value ? h('div') : null,
         )
-      }
+      },
     }).mount(root)
 
     expect(root.innerHTML).toBe(`<div></div>`)
@@ -2404,8 +2404,8 @@ describe('e2e: Transition', () => {
               template: `
                   <!-- Broken! -->
                   <div><slot /></div>
-                `
-            }
+                `,
+            },
           },
           template: `
             <div id="container">
@@ -2421,24 +2421,24 @@ describe('e2e: Transition', () => {
             const toggle = ref(true)
             const click = () => (toggle.value = !toggle.value)
             return { toggle, click }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe(
-        '<!-- Broken! --><div class="test"><div>content</div></div>'
+        '<!-- Broken! --><div class="test"><div>content</div></div>',
       )
 
       // leave
       expect(await classWhenTransitionStart()).toStrictEqual([
         'test',
         'v-leave-from',
-        'v-leave-active'
+        'v-leave-active',
       ])
       await nextFrame()
       expect(await classList('.test')).toStrictEqual([
         'test',
         'v-leave-active',
-        'v-leave-to'
+        'v-leave-to',
       ])
       await transitionFinish()
       expect(await html('#container')).toBe('<!--v-if-->')
@@ -2447,19 +2447,19 @@ describe('e2e: Transition', () => {
       expect(await classWhenTransitionStart()).toStrictEqual([
         'test',
         'v-enter-from',
-        'v-enter-active'
+        'v-enter-active',
       ])
       await nextFrame()
       expect(await classList('.test')).toStrictEqual([
         'test',
         'v-enter-active',
-        'v-enter-to'
+        'v-enter-to',
       ])
       await transitionFinish()
       expect(await html('#container')).toBe(
-        '<!-- Broken! --><div class="test"><div>content</div></div>'
+        '<!-- Broken! --><div class="test"><div>content</div></div>',
       )
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index 1a61c23a44ec96845d1ca84a6135458e760a42b1..febc9d3c20ab0c306ba904c20829d790625580ee 100644 (file)
@@ -1,5 +1,5 @@
 import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
-import path from 'path'
+import path from 'node:path'
 import { createApp, ref } from 'vue'
 
 describe('e2e: TransitionGroup', () => {
@@ -42,13 +42,13 @@ describe('e2e: TransitionGroup', () => {
             const items = ref(['a', 'b', 'c'])
             const click = () => items.value.push('d', 'e')
             return { click, items }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe(
         `<div class="test">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test">c</div>`
+          `<div class="test">c</div>`,
       )
 
       expect(await htmlWhenTransitionStart()).toBe(
@@ -56,7 +56,7 @@ describe('e2e: TransitionGroup', () => {
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
           `<div class="test test-enter-from test-enter-active">d</div>` +
-          `<div class="test test-enter-from test-enter-active">e</div>`
+          `<div class="test test-enter-from test-enter-active">e</div>`,
       )
       await nextFrame()
       expect(await html('#container')).toBe(
@@ -64,7 +64,7 @@ describe('e2e: TransitionGroup', () => {
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
           `<div class="test test-enter-active test-enter-to">d</div>` +
-          `<div class="test test-enter-active test-enter-to">e</div>`
+          `<div class="test test-enter-active test-enter-to">e</div>`,
       )
       await transitionFinish()
       expect(await html('#container')).toBe(
@@ -72,10 +72,10 @@ describe('e2e: TransitionGroup', () => {
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
           `<div class="test">d</div>` +
-          `<div class="test">e</div>`
+          `<div class="test">e</div>`,
       )
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -96,30 +96,30 @@ describe('e2e: TransitionGroup', () => {
             const items = ref(['a', 'b', 'c'])
             const click = () => (items.value = ['b'])
             return { click, items }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe(
         `<div class="test">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test">c</div>`
+          `<div class="test">c</div>`,
       )
 
       expect(await htmlWhenTransitionStart()).toBe(
         `<div class="test test-leave-from test-leave-active">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test test-leave-from test-leave-active">c</div>`
+          `<div class="test test-leave-from test-leave-active">c</div>`,
       )
       await nextFrame()
       expect(await html('#container')).toBe(
         `<div class="test test-leave-active test-leave-to">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test test-leave-active test-leave-to">c</div>`
+          `<div class="test test-leave-active test-leave-to">c</div>`,
       )
       await transitionFinish()
       expect(await html('#container')).toBe(`<div class="test">b</div>`)
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -140,36 +140,36 @@ describe('e2e: TransitionGroup', () => {
             const items = ref(['a', 'b', 'c'])
             const click = () => (items.value = ['b', 'c', 'd'])
             return { click, items }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe(
         `<div class="test">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test">c</div>`
+          `<div class="test">c</div>`,
       )
 
       expect(await htmlWhenTransitionStart()).toBe(
         `<div class="test test-leave-from test-leave-active">a</div>` +
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
-          `<div class="test test-enter-from test-enter-active">d</div>`
+          `<div class="test test-enter-from test-enter-active">d</div>`,
       )
       await nextFrame()
       expect(await html('#container')).toBe(
         `<div class="test test-leave-active test-leave-to">a</div>` +
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
-          `<div class="test test-enter-active test-enter-to">d</div>`
+          `<div class="test test-enter-active test-enter-to">d</div>`,
       )
       await transitionFinish()
       expect(await html('#container')).toBe(
         `<div class="test">b</div>` +
           `<div class="test">c</div>` +
-          `<div class="test">d</div>`
+          `<div class="test">d</div>`,
       )
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -194,7 +194,7 @@ describe('e2e: TransitionGroup', () => {
             const items = ref(['a', 'b', 'c'])
             const click = () => items.value.push('d', 'e')
             return { click, items }
-          }
+          },
         }).mount('#app')
         return Promise.resolve().then(() => {
           return document.querySelector('#container')!.innerHTML
@@ -204,19 +204,19 @@ describe('e2e: TransitionGroup', () => {
       expect(appearHtml).toBe(
         `<div class="test test-appear-from test-appear-active">a</div>` +
           `<div class="test test-appear-from test-appear-active">b</div>` +
-          `<div class="test test-appear-from test-appear-active">c</div>`
+          `<div class="test test-appear-from test-appear-active">c</div>`,
       )
       await nextFrame()
       expect(await html('#container')).toBe(
         `<div class="test test-appear-active test-appear-to">a</div>` +
           `<div class="test test-appear-active test-appear-to">b</div>` +
-          `<div class="test test-appear-active test-appear-to">c</div>`
+          `<div class="test test-appear-active test-appear-to">c</div>`,
       )
       await transitionFinish()
       expect(await html('#container')).toBe(
         `<div class="test">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test">c</div>`
+          `<div class="test">c</div>`,
       )
 
       // enter
@@ -225,7 +225,7 @@ describe('e2e: TransitionGroup', () => {
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
           `<div class="test test-enter-from test-enter-active">d</div>` +
-          `<div class="test test-enter-from test-enter-active">e</div>`
+          `<div class="test test-enter-from test-enter-active">e</div>`,
       )
       await nextFrame()
       expect(await html('#container')).toBe(
@@ -233,7 +233,7 @@ describe('e2e: TransitionGroup', () => {
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
           `<div class="test test-enter-active test-enter-to">d</div>` +
-          `<div class="test test-enter-active test-enter-to">e</div>`
+          `<div class="test test-enter-active test-enter-to">e</div>`,
       )
       await transitionFinish()
       expect(await html('#container')).toBe(
@@ -241,10 +241,10 @@ describe('e2e: TransitionGroup', () => {
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
           `<div class="test">d</div>` +
-          `<div class="test">e</div>`
+          `<div class="test">e</div>`,
       )
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -265,36 +265,36 @@ describe('e2e: TransitionGroup', () => {
             const items = ref(['a', 'b', 'c'])
             const click = () => (items.value = ['d', 'b', 'a'])
             return { click, items }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe(
         `<div class="test">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test">c</div>`
+          `<div class="test">c</div>`,
       )
 
       expect(await htmlWhenTransitionStart()).toBe(
         `<div class="test group-enter-from group-enter-active">d</div>` +
           `<div class="test">b</div>` +
           `<div class="test group-move" style="">a</div>` +
-          `<div class="test group-leave-from group-leave-active group-move" style="">c</div>`
+          `<div class="test group-leave-from group-leave-active group-move" style="">c</div>`,
       )
       await nextFrame()
       expect(await html('#container')).toBe(
         `<div class="test group-enter-active group-enter-to">d</div>` +
           `<div class="test">b</div>` +
           `<div class="test group-move" style="">a</div>` +
-          `<div class="test group-leave-active group-move group-leave-to" style="">c</div>`
+          `<div class="test group-leave-active group-move group-leave-to" style="">c</div>`,
       )
       await transitionFinish(duration * 2)
       expect(await html('#container')).toBe(
         `<div class="test">d</div>` +
           `<div class="test">b</div>` +
-          `<div class="test" style="">a</div>`
+          `<div class="test" style="">a</div>`,
       )
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -321,16 +321,16 @@ describe('e2e: TransitionGroup', () => {
               items.value = ['a', 'b', 'c']
             }
             return { click, items, name, changeName }
-          }
+          },
         }).mount('#app')
       })
       expect(await html('#container')).toBe(
-        `<div>a</div>` + `<div>b</div>` + `<div>c</div>`
+        `<div>a</div>` + `<div>b</div>` + `<div>c</div>`,
       )
 
       // invalid name
       expect(await htmlWhenTransitionStart()).toBe(
-        `<div>b</div>` + `<div>c</div>` + `<div>a</div>`
+        `<div>b</div>` + `<div>c</div>` + `<div>a</div>`,
       )
       // change name
       const moveHtml = await page().evaluate(() => {
@@ -342,7 +342,7 @@ describe('e2e: TransitionGroup', () => {
       expect(moveHtml).toBe(
         `<div class="group-move" style="">a</div>` +
           `<div class="group-move" style="">b</div>` +
-          `<div class="group-move" style="">c</div>`
+          `<div class="group-move" style="">c</div>`,
       )
       // not sure why but we just have to wait really long for this to
       // pass consistently :/
@@ -350,10 +350,10 @@ describe('e2e: TransitionGroup', () => {
       expect(await html('#container')).toBe(
         `<div class="" style="">a</div>` +
           `<div class="" style="">b</div>` +
-          `<div class="" style="">c</div>`
+          `<div class="" style="">c</div>`,
       )
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -389,7 +389,7 @@ describe('e2e: TransitionGroup', () => {
           afterEnterSpy,
           beforeLeaveSpy,
           onLeaveSpy,
-          afterLeaveSpy
+          afterLeaveSpy,
         } = window as any
         const { createApp, ref } = (window as any).Vue
         createApp({
@@ -428,9 +428,9 @@ describe('e2e: TransitionGroup', () => {
               afterEnterSpy,
               beforeLeaveSpy,
               onLeaveSpy,
-              afterLeaveSpy
+              afterLeaveSpy,
             }
-          }
+          },
         }).mount('#app')
         return Promise.resolve().then(() => {
           return document.querySelector('#container')!.innerHTML
@@ -442,21 +442,21 @@ describe('e2e: TransitionGroup', () => {
       expect(appearHtml).toBe(
         `<div class="test test-appear-from test-appear-active">a</div>` +
           `<div class="test test-appear-from test-appear-active">b</div>` +
-          `<div class="test test-appear-from test-appear-active">c</div>`
+          `<div class="test test-appear-from test-appear-active">c</div>`,
       )
       await nextFrame()
       expect(afterAppearSpy).not.toBeCalled()
       expect(await html('#container')).toBe(
         `<div class="test test-appear-active test-appear-to">a</div>` +
           `<div class="test test-appear-active test-appear-to">b</div>` +
-          `<div class="test test-appear-active test-appear-to">c</div>`
+          `<div class="test test-appear-active test-appear-to">c</div>`,
       )
       await transitionFinish()
       expect(afterAppearSpy).toBeCalled()
       expect(await html('#container')).toBe(
         `<div class="test">a</div>` +
           `<div class="test">b</div>` +
-          `<div class="test">c</div>`
+          `<div class="test">c</div>`,
       )
 
       // enter + leave
@@ -464,7 +464,7 @@ describe('e2e: TransitionGroup', () => {
         `<div class="test test-leave-from test-leave-active">a</div>` +
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
-          `<div class="test test-enter-from test-enter-active">d</div>`
+          `<div class="test test-enter-from test-enter-active">d</div>`,
       )
       expect(beforeLeaveSpy).toBeCalled()
       expect(onLeaveSpy).toBeCalled()
@@ -477,7 +477,7 @@ describe('e2e: TransitionGroup', () => {
         `<div class="test test-leave-active test-leave-to">a</div>` +
           `<div class="test">b</div>` +
           `<div class="test">c</div>` +
-          `<div class="test test-enter-active test-enter-to">d</div>`
+          `<div class="test test-enter-active test-enter-to">d</div>`,
       )
       expect(afterLeaveSpy).not.toBeCalled()
       expect(afterEnterSpy).not.toBeCalled()
@@ -485,12 +485,12 @@ describe('e2e: TransitionGroup', () => {
       expect(await html('#container')).toBe(
         `<div class="test">b</div>` +
           `<div class="test">c</div>` +
-          `<div class="test">d</div>`
+          `<div class="test">d</div>`,
       )
       expect(afterLeaveSpy).toBeCalled()
       expect(afterEnterSpy).toBeCalled()
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test('warn unkeyed children', () => {
@@ -503,7 +503,7 @@ describe('e2e: TransitionGroup', () => {
       setup: () => {
         const items = ref(['a', 'b', 'c'])
         return { items }
-      }
+      },
     }).mount(document.createElement('div'))
 
     expect(`<TransitionGroup> children must be keyed`).toHaveBeenWarned()
index 8bcb8d8f97bfe2e5485836eacf07b7bd92baea5f..4a793e25aeabfee07229ba58945aff0f721d2469 100644 (file)
@@ -8,17 +8,17 @@ export default {
         author: {
           name: 'Haoqun Jiang',
           email: 'haoqunjiang@gmail.com',
-          date: '2019-12-09T19:52:20Z'
+          date: '2019-12-09T19:52:20Z',
         },
         committer: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2019-12-09T19:52:20Z'
+          date: '2019-12-09T19:52:20Z',
         },
         message: 'test: add test for runtime-dom/modules/class (#75)',
         tree: {
           sha: 'f53f761827af281db86c31d113086c068c1d0789',
-          url: 'https://api.github.com/repos/vuejs/core/git/trees/f53f761827af281db86c31d113086c068c1d0789'
+          url: 'https://api.github.com/repos/vuejs/core/git/trees/f53f761827af281db86c31d113086c068c1d0789',
         },
         url: 'https://api.github.com/repos/vuejs/core/git/commits/d1527fbee422c7170e56845e55b49c4fd6de72a7',
         comment_count: 0,
@@ -26,8 +26,8 @@ export default {
           verified: false,
           reason: 'unsigned',
           signature: null,
-          payload: null
-        }
+          payload: null,
+        },
       },
       url: 'https://api.github.com/repos/vuejs/core/commits/d1527fbee422c7170e56845e55b49c4fd6de72a7',
       html_url:
@@ -55,7 +55,7 @@ export default {
         received_events_url:
           'https://api.github.com/users/sodatea/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       committer: {
         login: 'yyx990803',
@@ -79,16 +79,16 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       parents: [
         {
           sha: '2383b45e322272ddc102d6914c149b284a25d04f',
           url: 'https://api.github.com/repos/vuejs/core/commits/2383b45e322272ddc102d6914c149b284a25d04f',
           html_url:
-            'https://github.com/vuejs/core/commit/2383b45e322272ddc102d6914c149b284a25d04f'
-        }
-      ]
+            'https://github.com/vuejs/core/commit/2383b45e322272ddc102d6914c149b284a25d04f',
+        },
+      ],
     },
     {
       sha: '2383b45e322272ddc102d6914c149b284a25d04f',
@@ -98,17 +98,17 @@ export default {
         author: {
           name: 'GCA',
           email: 'gcaaa31928@gmail.com',
-          date: '2019-12-09T19:23:57Z'
+          date: '2019-12-09T19:23:57Z',
         },
         committer: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2019-12-09T19:23:57Z'
+          date: '2019-12-09T19:23:57Z',
         },
         message: 'chore: fix typo (#530) [ci skip]',
         tree: {
           sha: '2a5872ff8dc8ccb8121abd7e890ac3c0c9f1209f',
-          url: 'https://api.github.com/repos/vuejs/core/git/trees/2a5872ff8dc8ccb8121abd7e890ac3c0c9f1209f'
+          url: 'https://api.github.com/repos/vuejs/core/git/trees/2a5872ff8dc8ccb8121abd7e890ac3c0c9f1209f',
         },
         url: 'https://api.github.com/repos/vuejs/core/git/commits/2383b45e322272ddc102d6914c149b284a25d04f',
         comment_count: 0,
@@ -116,8 +116,8 @@ export default {
           verified: false,
           reason: 'unsigned',
           signature: null,
-          payload: null
-        }
+          payload: null,
+        },
       },
       url: 'https://api.github.com/repos/vuejs/core/commits/2383b45e322272ddc102d6914c149b284a25d04f',
       html_url:
@@ -146,7 +146,7 @@ export default {
         received_events_url:
           'https://api.github.com/users/gcaaa31928/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       committer: {
         login: 'yyx990803',
@@ -170,16 +170,16 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       parents: [
         {
           sha: 'e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
           url: 'https://api.github.com/repos/vuejs/core/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
           html_url:
-            'https://github.com/vuejs/core/commit/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad'
-        }
-      ]
+            'https://github.com/vuejs/core/commit/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
+        },
+      ],
     },
     {
       sha: 'e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
@@ -189,17 +189,17 @@ export default {
         author: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2019-12-09T19:23:01Z'
+          date: '2019-12-09T19:23:01Z',
         },
         committer: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2019-12-09T19:23:01Z'
+          date: '2019-12-09T19:23:01Z',
         },
         message: 'test: fix warning',
         tree: {
           sha: 'd942b17681e2e2fbbcd2ee04092390c7f2cf534d',
-          url: 'https://api.github.com/repos/vuejs/core/git/trees/d942b17681e2e2fbbcd2ee04092390c7f2cf534d'
+          url: 'https://api.github.com/repos/vuejs/core/git/trees/d942b17681e2e2fbbcd2ee04092390c7f2cf534d',
         },
         url: 'https://api.github.com/repos/vuejs/core/git/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
         comment_count: 0,
@@ -207,8 +207,8 @@ export default {
           verified: false,
           reason: 'unsigned',
           signature: null,
-          payload: null
-        }
+          payload: null,
+        },
       },
       url: 'https://api.github.com/repos/vuejs/core/commits/e7e1314cccd1a66fcf8b8526ec21350ec16cc3ad',
       html_url:
@@ -237,7 +237,7 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       committer: {
         login: 'yyx990803',
@@ -261,17 +261,17 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       parents: [
         {
           sha: '12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e',
           url: 'https://api.github.com/repos/vuejs/core/commits/12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e',
           html_url:
-            'https://github.com/vuejs/core/commit/12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e'
-        }
-      ]
-    }
+            'https://github.com/vuejs/core/commit/12ec62e6881f83dfa6c7f8a3c3650ec2567e6b1e',
+        },
+      ],
+    },
   ],
   'v2-compat': [
     {
@@ -282,17 +282,17 @@ export default {
         author: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2018-11-13T03:42:34Z'
+          date: '2018-11-13T03:42:34Z',
         },
         committer: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2018-11-13T03:54:01Z'
+          date: '2018-11-13T03:54:01Z',
         },
         message: 'chore: fix tests',
         tree: {
           sha: '6ac7bd078a6eb0ad32b5102e0c5d2c29f2b20a48',
-          url: 'https://api.github.com/repos/vuejs/core/git/trees/6ac7bd078a6eb0ad32b5102e0c5d2c29f2b20a48'
+          url: 'https://api.github.com/repos/vuejs/core/git/trees/6ac7bd078a6eb0ad32b5102e0c5d2c29f2b20a48',
         },
         url: 'https://api.github.com/repos/vuejs/core/git/commits/ecf4da822eea97f5db5fa769d39f994755384a4b',
         comment_count: 0,
@@ -300,8 +300,8 @@ export default {
           verified: false,
           reason: 'unsigned',
           signature: null,
-          payload: null
-        }
+          payload: null,
+        },
       },
       url: 'https://api.github.com/repos/vuejs/core/commits/ecf4da822eea97f5db5fa769d39f994755384a4b',
       html_url:
@@ -330,7 +330,7 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       committer: {
         login: 'yyx990803',
@@ -354,16 +354,16 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       parents: [
         {
           sha: 'ca296812d54aff123472d7147b83fddfb634d9bc',
           url: 'https://api.github.com/repos/vuejs/core/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
           html_url:
-            'https://github.com/vuejs/core/commit/ca296812d54aff123472d7147b83fddfb634d9bc'
-        }
-      ]
+            'https://github.com/vuejs/core/commit/ca296812d54aff123472d7147b83fddfb634d9bc',
+        },
+      ],
     },
     {
       sha: 'ca296812d54aff123472d7147b83fddfb634d9bc',
@@ -373,17 +373,17 @@ export default {
         author: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2018-11-13T03:21:56Z'
+          date: '2018-11-13T03:21:56Z',
         },
         committer: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2018-11-13T03:46:06Z'
+          date: '2018-11-13T03:46:06Z',
         },
         message: 'refactor: bring back clone for reused nodes',
         tree: {
           sha: '2cec32c97686e0ee9af1b87f0abdbbbdc18b6de6',
-          url: 'https://api.github.com/repos/vuejs/core/git/trees/2cec32c97686e0ee9af1b87f0abdbbbdc18b6de6'
+          url: 'https://api.github.com/repos/vuejs/core/git/trees/2cec32c97686e0ee9af1b87f0abdbbbdc18b6de6',
         },
         url: 'https://api.github.com/repos/vuejs/core/git/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
         comment_count: 0,
@@ -391,8 +391,8 @@ export default {
           verified: false,
           reason: 'unsigned',
           signature: null,
-          payload: null
-        }
+          payload: null,
+        },
       },
       url: 'https://api.github.com/repos/vuejs/core/commits/ca296812d54aff123472d7147b83fddfb634d9bc',
       html_url:
@@ -421,7 +421,7 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       committer: {
         login: 'yyx990803',
@@ -445,16 +445,16 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       parents: [
         {
           sha: 'e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
           url: 'https://api.github.com/repos/vuejs/core/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
           html_url:
-            'https://github.com/vuejs/core/commit/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b'
-        }
-      ]
+            'https://github.com/vuejs/core/commit/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
+        },
+      ],
     },
     {
       sha: 'e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
@@ -464,17 +464,17 @@ export default {
         author: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2018-11-02T20:59:45Z'
+          date: '2018-11-02T20:59:45Z',
         },
         committer: {
           name: 'Evan You',
           email: 'yyx990803@gmail.com',
-          date: '2018-11-02T20:59:45Z'
+          date: '2018-11-02T20:59:45Z',
         },
         message: 'chore: relax render type for tsx',
         tree: {
           sha: '7e2b3bb92ab91f755b2251e4a7903e6dd2042602',
-          url: 'https://api.github.com/repos/vuejs/core/git/trees/7e2b3bb92ab91f755b2251e4a7903e6dd2042602'
+          url: 'https://api.github.com/repos/vuejs/core/git/trees/7e2b3bb92ab91f755b2251e4a7903e6dd2042602',
         },
         url: 'https://api.github.com/repos/vuejs/core/git/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
         comment_count: 0,
@@ -482,8 +482,8 @@ export default {
           verified: false,
           reason: 'unsigned',
           signature: null,
-          payload: null
-        }
+          payload: null,
+        },
       },
       url: 'https://api.github.com/repos/vuejs/core/commits/e6be55a4989edb6f8750dbaa14eb693ec1f0d67b',
       html_url:
@@ -512,7 +512,7 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       committer: {
         login: 'yyx990803',
@@ -536,16 +536,16 @@ export default {
         received_events_url:
           'https://api.github.com/users/yyx990803/received_events',
         type: 'User',
-        site_admin: false
+        site_admin: false,
       },
       parents: [
         {
           sha: 'ccc835caff0344baad3c92ce786ad4f804bf667b',
           url: 'https://api.github.com/repos/vuejs/core/commits/ccc835caff0344baad3c92ce786ad4f804bf667b',
           html_url:
-            'https://github.com/vuejs/core/commit/ccc835caff0344baad3c92ce786ad4f804bf667b'
-        }
-      ]
-    }
-  ]
+            'https://github.com/vuejs/core/commit/ccc835caff0344baad3c92ce786ad4f804bf667b',
+        },
+      ],
+    },
+  ],
 }
index 1fe26bac2f19595223c923e32ebc6782d642da02..178c918c21a573bae0f8ceec79cff3a553788858 100644 (file)
@@ -1,5 +1,5 @@
-import path from 'path'
-import { setupPuppeteer, E2E_TIMEOUT } from './e2eUtils'
+import path from 'node:path'
+import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 import mocks from './commits.mock'
 
 describe('e2e: commits', () => {
@@ -8,7 +8,7 @@ describe('e2e: commits', () => {
   async function testCommits(apiType: 'classic' | 'composition') {
     const baseUrl = `file://${path.resolve(
       __dirname,
-      `../../examples/${apiType}/commits.html`
+      `../../examples/${apiType}/commits.html`,
     )}`
 
     // intercept and mock the response to avoid hitting the actual API
@@ -22,7 +22,7 @@ describe('e2e: commits', () => {
           status: 200,
           contentType: 'application/json',
           headers: { 'Access-Control-Allow-Origin': '*' },
-          body: JSON.stringify(mocks[match[1] as 'main' | 'v2-compat'])
+          body: JSON.stringify(mocks[match[1] as 'main' | 'v2-compat']),
         })
       }
     })
@@ -51,7 +51,7 @@ describe('e2e: commits', () => {
     async () => {
       await testCommits('classic')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -59,6 +59,6 @@ describe('e2e: commits', () => {
     async () => {
       await testCommits('composition')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index 4d840a690e4c850b4fbf2ff8824a5a93a58605f9..792e4452fe3c6eb3c57b12e1de17c5b8104f0b4c 100644 (file)
@@ -1,15 +1,15 @@
 import puppeteer, {
-  Browser,
-  Page,
-  ClickOptions,
-  PuppeteerLaunchOptions
+  type Browser,
+  type ClickOptions,
+  type Page,
+  type PuppeteerLaunchOptions,
 } from 'puppeteer'
 
 export const E2E_TIMEOUT = 30 * 1000
 
 const puppeteerOptions: PuppeteerLaunchOptions = {
   args: process.env.CI ? ['--no-sandbox', '--disable-setuid-sandbox'] : [],
-  headless: 'new'
+  headless: 'new',
 }
 
 const maxTries = 30
@@ -17,7 +17,7 @@ export const timeout = (n: number) => new Promise(r => setTimeout(r, n))
 
 export async function expectByPolling(
   poll: () => Promise<any>,
-  expected: string
+  expected: string,
 ) {
   for (let tries = 0; tries < maxTries; tries++) {
     const actual = (await poll()) || ''
@@ -50,7 +50,7 @@ export function setupPuppeteer() {
         const err = e.args()[0]
         console.error(
           `Error from Puppeteer-loaded page:\n`,
-          err.remoteObject().description
+          err.remoteObject().description,
         )
       }
     })
@@ -102,7 +102,7 @@ export function setupPuppeteer() {
   async function isChecked(selector: string) {
     return await page.$eval(
       selector,
-      node => (node as HTMLInputElement).checked
+      node => (node as HTMLInputElement).checked,
     )
   }
 
@@ -117,7 +117,7 @@ export function setupPuppeteer() {
         ;(node as HTMLInputElement).value = value as string
         node.dispatchEvent(new Event('input'))
       },
-      value
+      value,
     )
   }
 
@@ -137,7 +137,7 @@ export function setupPuppeteer() {
   async function clearValue(selector: string) {
     return await page.$eval(
       selector,
-      node => ((node as HTMLInputElement).value = '')
+      node => ((node as HTMLInputElement).value = ''),
     )
   }
 
@@ -176,6 +176,6 @@ export function setupPuppeteer() {
     enterValue,
     clearValue,
     timeout,
-    nextFrame
+    nextFrame,
   }
 }
index 728804e0b507f53801b6bec52b52728e4afd1732..23b78130785ef79f3d5806f830a16a8490b7952e 100644 (file)
@@ -1,5 +1,5 @@
-import path from 'path'
-import { setupPuppeteer, E2E_TIMEOUT } from './e2eUtils'
+import path from 'node:path'
+import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 
 interface TableData {
   name: string
@@ -15,7 +15,7 @@ describe('e2e: grid', () => {
     for (let i = 0; i < data.length; i++) {
       for (let j = 0; j < columns.length; j++) {
         expect(
-          await text(`tr:nth-child(${i + 1}) td:nth-child(${j + 1})`)
+          await text(`tr:nth-child(${i + 1}) td:nth-child(${j + 1})`),
         ).toContain(`${data[i][columns[j]]}`)
       }
     }
@@ -24,7 +24,7 @@ describe('e2e: grid', () => {
   async function testGrid(apiType: 'classic' | 'composition') {
     const baseUrl = `file://${path.resolve(
       __dirname,
-      `../../examples/${apiType}/grid.html`
+      `../../examples/${apiType}/grid.html`,
     )}`
 
     await page().goto(baseUrl)
@@ -37,7 +37,7 @@ describe('e2e: grid', () => {
       { name: 'Chuck Norris', power: Infinity },
       { name: 'Bruce Lee', power: 9000 },
       { name: 'Jackie Chan', power: 7000 },
-      { name: 'Jet Li', power: 8000 }
+      { name: 'Jet Li', power: 8000 },
     ])
 
     await click('th:nth-child(1)')
@@ -49,7 +49,7 @@ describe('e2e: grid', () => {
       { name: 'Jet Li', power: 8000 },
       { name: 'Jackie Chan', power: 7000 },
       { name: 'Chuck Norris', power: Infinity },
-      { name: 'Bruce Lee', power: 9000 }
+      { name: 'Bruce Lee', power: 9000 },
     ])
 
     await click('th:nth-child(2)')
@@ -61,7 +61,7 @@ describe('e2e: grid', () => {
       { name: 'Chuck Norris', power: Infinity },
       { name: 'Bruce Lee', power: 9000 },
       { name: 'Jet Li', power: 8000 },
-      { name: 'Jackie Chan', power: 7000 }
+      { name: 'Jackie Chan', power: 7000 },
     ])
 
     await click('th:nth-child(2)')
@@ -73,7 +73,7 @@ describe('e2e: grid', () => {
       { name: 'Jackie Chan', power: 7000 },
       { name: 'Jet Li', power: 8000 },
       { name: 'Bruce Lee', power: 9000 },
-      { name: 'Chuck Norris', power: Infinity }
+      { name: 'Chuck Norris', power: Infinity },
     ])
 
     await click('th:nth-child(1)')
@@ -85,13 +85,13 @@ describe('e2e: grid', () => {
       { name: 'Bruce Lee', power: 9000 },
       { name: 'Chuck Norris', power: Infinity },
       { name: 'Jackie Chan', power: 7000 },
-      { name: 'Jet Li', power: 8000 }
+      { name: 'Jet Li', power: 8000 },
     ])
 
     await typeValue('input[name="query"]', 'j')
     await assertTable([
       { name: 'Jackie Chan', power: 7000 },
-      { name: 'Jet Li', power: 8000 }
+      { name: 'Jet Li', power: 8000 },
     ])
 
     await typeValue('input[name="query"]', 'infinity')
@@ -108,7 +108,7 @@ describe('e2e: grid', () => {
     async () => {
       await testGrid('classic')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -116,6 +116,6 @@ describe('e2e: grid', () => {
     async () => {
       await testGrid('composition')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index dc863c90785356b2501b8b3ebeeb9d79fd14d0cf..8764e66266cde2a51cd139929ac3ce93977c0d08 100644 (file)
@@ -1,5 +1,5 @@
-import path from 'path'
-import { setupPuppeteer, expectByPolling, E2E_TIMEOUT } from './e2eUtils'
+import path from 'node:path'
+import { E2E_TIMEOUT, expectByPolling, setupPuppeteer } from './e2eUtils'
 
 describe('e2e: markdown', () => {
   const { page, isVisible, value, html } = setupPuppeteer()
@@ -7,7 +7,7 @@ describe('e2e: markdown', () => {
   async function testMarkdown(apiType: 'classic' | 'composition') {
     const baseUrl = `file://${path.resolve(
       __dirname,
-      `../../examples/${apiType}/markdown.html#test`
+      `../../examples/${apiType}/markdown.html#test`,
     )}`
 
     await page().goto(baseUrl)
@@ -25,7 +25,7 @@ describe('e2e: markdown', () => {
       () => html('#editor div'),
       '<h1>hello</h1>\n' +
         '<h2>foo</h2>\n' +
-        '<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n'
+        '<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n',
     )
   }
 
@@ -34,7 +34,7 @@ describe('e2e: markdown', () => {
     async () => {
       await testMarkdown('classic')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -42,6 +42,6 @@ describe('e2e: markdown', () => {
     async () => {
       await testMarkdown('composition')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index 09b5be81a915a7beeb626dfe9914f1f4e9d6169f..37081e4c03ce7081710677ecd031231f4e4cd238 100644 (file)
@@ -1,5 +1,5 @@
-import path from 'path'
-import { setupPuppeteer, E2E_TIMEOUT } from './e2eUtils'
+import path from 'node:path'
+import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 
 declare const globalStats: {
   label: string
@@ -9,7 +9,7 @@ declare const globalStats: {
 declare function valueToPoint(
   value: number,
   index: number,
-  total: number
+  total: number,
 ): {
   x: number
   y: number
@@ -33,8 +33,8 @@ describe('e2e: svg', () => {
             document.querySelector('polygon')!.attributes[0].value === points
           )
         },
-        [total]
-      )
+        [total],
+      ),
     ).toBe(true)
   }
 
@@ -47,12 +47,12 @@ describe('e2e: svg', () => {
           return [point.x, point.y]
         })
       },
-      [total]
+      [total],
     )
     for (let i = 0; i < total; i++) {
       const textPosition = await page().$eval(
         `text:nth-child(${i + 3})`,
-        node => [+node.attributes[0].value, +node.attributes[1].value]
+        node => [+node.attributes[0].value, +node.attributes[1].value],
       )
       expect(textPosition).toEqual(positions[i])
     }
@@ -73,7 +73,7 @@ describe('e2e: svg', () => {
   async function testSvg(apiType: 'classic' | 'composition') {
     const baseUrl = `file://${path.resolve(
       __dirname,
-      `../../examples/${apiType}/svg.html`
+      `../../examples/${apiType}/svg.html`,
     )}`
 
     await page().goto(baseUrl)
@@ -144,7 +144,7 @@ describe('e2e: svg', () => {
     async () => {
       await testSvg('classic')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -152,6 +152,6 @@ describe('e2e: svg', () => {
     async () => {
       await testSvg('composition')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index 668f9d333902469cc1704ca46e4f4928c8913ce8..bd3836282d2d812325d6fcb29f1a3b69d87516db 100644 (file)
@@ -1,5 +1,5 @@
-import path from 'path'
-import { setupPuppeteer, E2E_TIMEOUT } from './e2eUtils'
+import path from 'node:path'
+import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 
 describe('e2e: todomvc', () => {
   const {
@@ -13,7 +13,7 @@ describe('e2e: todomvc', () => {
     isFocused,
     classList,
     enterValue,
-    clearValue
+    clearValue,
   } = setupPuppeteer()
 
   async function removeItemAt(n: number) {
@@ -26,7 +26,7 @@ describe('e2e: todomvc', () => {
   async function testTodomvc(apiType: 'classic' | 'composition') {
     const baseUrl = `file://${path.resolve(
       __dirname,
-      `../../examples/${apiType}/todomvc.html`
+      `../../examples/${apiType}/todomvc.html`,
     )}`
 
     await page().goto(baseUrl)
@@ -174,7 +174,7 @@ describe('e2e: todomvc', () => {
     async () => {
       await testTodomvc('classic')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -182,6 +182,6 @@ describe('e2e: todomvc', () => {
     async () => {
       await testTodomvc('composition')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index 74a3df7b0da21f964f656dab1d21cb05566ee441..8c12537aeb04758440f702263b789e259872871f 100644 (file)
@@ -1,5 +1,5 @@
-import path from 'path'
-import { setupPuppeteer, E2E_TIMEOUT } from './e2eUtils'
+import path from 'node:path'
+import { E2E_TIMEOUT, setupPuppeteer } from './e2eUtils'
 
 describe('e2e: tree', () => {
   const { page, click, count, text, children, isVisible } = setupPuppeteer()
@@ -7,7 +7,7 @@ describe('e2e: tree', () => {
   async function testTree(apiType: 'classic' | 'composition') {
     const baseUrl = `file://${path.resolve(
       __dirname,
-      `../../examples/${apiType}/tree.html`
+      `../../examples/${apiType}/tree.html`,
     )}`
 
     await page().goto(baseUrl)
@@ -23,57 +23,57 @@ describe('e2e: tree', () => {
     expect((await children('#demo li ul')).length).toBe(4)
     expect(await text('#demo li div span')).toContain('[-]')
     expect(await text('#demo > .item > ul > .item:nth-child(1)')).toContain(
-      'hello'
+      'hello',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(2)')).toContain(
-      'wat'
+      'wat',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(3)')).toContain(
-      'child folder'
+      'child folder',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(3)')).toContain(
-      '[+]'
+      '[+]',
     )
 
     // add items to root
     await click('#demo > .item > ul > .add')
     expect((await children('#demo li ul')).length).toBe(5)
     expect(await text('#demo > .item > ul > .item:nth-child(1)')).toContain(
-      'hello'
+      'hello',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(2)')).toContain(
-      'wat'
+      'wat',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(3)')).toContain(
-      'child folder'
+      'child folder',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(3)')).toContain(
-      '[+]'
+      '[+]',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(4)')).toContain(
-      'new stuff'
+      'new stuff',
     )
 
     // add another item
     await click('#demo > .item > ul > .add')
     expect((await children('#demo li ul')).length).toBe(6)
     expect(await text('#demo > .item > ul > .item:nth-child(1)')).toContain(
-      'hello'
+      'hello',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(2)')).toContain(
-      'wat'
+      'wat',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(3)')).toContain(
-      'child folder'
+      'child folder',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(3)')).toContain(
-      '[+]'
+      '[+]',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(4)')).toContain(
-      'new stuff'
+      'new stuff',
     )
     expect(await text('#demo > .item > ul > .item:nth-child(5)')).toContain(
-      'new stuff'
+      'new stuff',
     )
 
     await click('#demo ul .bold')
@@ -93,7 +93,7 @@ describe('e2e: tree', () => {
     expect(await count('.item > ul')).toBe(5)
     expect(await text('#demo ul > .item:nth-child(1)')).toContain('[-]')
     expect((await children('#demo ul > .item:nth-child(1) > ul')).length).toBe(
-      2
+      2,
     )
   }
 
@@ -102,7 +102,7 @@ describe('e2e: tree', () => {
     async () => {
       await testTree('classic')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 
   test(
@@ -110,6 +110,6 @@ describe('e2e: tree', () => {
     async () => {
       await testTree('composition')
     },
-    E2E_TIMEOUT
+    E2E_TIMEOUT,
   )
 })
index d547627de540496a86c7f675a752e8c165b70e6f..0c969f15981e4799f7fb3a139f0d1a79acb58980 100644 (file)
@@ -1,5 +1,5 @@
 import { EMPTY_ARR } from '@vue/shared'
-import { createApp, ref, nextTick, reactive } from '../src'
+import { createApp, nextTick, reactive, ref } from '../src'
 
 describe('compiler + runtime integration', () => {
   it('should support runtime template compilation', () => {
@@ -8,9 +8,9 @@ describe('compiler + runtime integration', () => {
       template: `{{ count }}`,
       data() {
         return {
-          count: 0
+          count: 0,
         }
-      }
+      },
     }
     createApp(App).mount(container)
     expect(container.innerHTML).toBe(`0`)
@@ -25,7 +25,7 @@ describe('compiler + runtime integration', () => {
       mounted: vi.fn(),
       activated: vi.fn(),
       deactivated: vi.fn(),
-      unmounted: vi.fn()
+      unmounted: vi.fn(),
     }
 
     const toggle = ref(true)
@@ -38,12 +38,12 @@ describe('compiler + runtime integration', () => {
       `,
       data() {
         return {
-          toggle
+          toggle,
         }
       },
       components: {
-        One: one
-      }
+        One: one,
+      },
     }
     createApp(App).mount(container)
     expect(container.innerHTML).toBe(`one`)
@@ -83,9 +83,9 @@ describe('compiler + runtime integration', () => {
       template: `#template`,
       data() {
         return {
-          count: 0
+          count: 0,
         }
-      }
+      },
     }
     createApp(App).mount(container)
     expect(container.innerHTML).toBe(`0`)
@@ -101,9 +101,9 @@ describe('compiler + runtime integration', () => {
       template,
       data() {
         return {
-          count: 0
+          count: 0,
         }
-      }
+      },
     }
     createApp(App).mount(container)
     expect(container.innerHTML).toBe(`0`)
@@ -112,28 +112,28 @@ describe('compiler + runtime integration', () => {
   it('should warn template compilation errors with codeframe', () => {
     const container = document.createElement('div')
     const App = {
-      template: `<div v-if>`
+      template: `<div v-if>`,
     }
     createApp(App).mount(container)
     expect(
-      `Template compilation error: Element is missing end tag`
+      `Template compilation error: Element is missing end tag`,
     ).toHaveBeenWarned()
     expect(
       `
 1  |  <div v-if>
-   |  ^`.trim()
+   |  ^`.trim(),
     ).toHaveBeenWarned()
     expect(`v-if/v-else-if is missing expression`).toHaveBeenWarned()
     expect(
       `
 1  |  <div v-if>
-   |       ^^^^`.trim()
+   |       ^^^^`.trim(),
     ).toHaveBeenWarned()
   })
 
   it('should support custom element via config.isCustomElement (deprecated)', () => {
     const app = createApp({
-      template: '<custom></custom>'
+      template: '<custom></custom>',
     })
     const container = document.createElement('div')
     app.config.isCustomElement = tag => tag === 'custom'
@@ -143,7 +143,7 @@ describe('compiler + runtime integration', () => {
 
   it('should support custom element via config.compilerOptions.isCustomElement', () => {
     const app = createApp({
-      template: '<custom></custom>'
+      template: '<custom></custom>',
     })
     const container = document.createElement('div')
     app.config.compilerOptions.isCustomElement = tag => tag === 'custom'
@@ -154,8 +154,8 @@ describe('compiler + runtime integration', () => {
   it('should support using element innerHTML as template', () => {
     const app = createApp({
       data: () => ({
-        msg: 'hello'
-      })
+        msg: 'hello',
+      }),
     })
     const container = document.createElement('div')
     container.innerHTML = '{{msg}}'
@@ -172,9 +172,9 @@ describe('compiler + runtime integration', () => {
       template: `{{ count }}`,
       data() {
         return {
-          count: 0
+          count: 0,
         }
-      }
+      },
     }
     createApp(App).mount('#app')
     expect(container.innerHTML).toBe(`0`)
@@ -183,7 +183,7 @@ describe('compiler + runtime integration', () => {
 
   it('should warn when template is not available', () => {
     const app = createApp({
-      template: {}
+      template: {},
     })
     const container = document.createElement('div')
     app.mount(container)
@@ -192,12 +192,12 @@ describe('compiler + runtime integration', () => {
 
   it('should warn when template is is not found', () => {
     const app = createApp({
-      template: '#not-exist-id'
+      template: '#not-exist-id',
     })
     const container = document.createElement('div')
     app.mount(container)
     expect(
-      '[Vue warn]: Template element not found or is empty: #not-exist-id'
+      '[Vue warn]: Template element not found or is empty: #not-exist-id',
     ).toHaveBeenWarned()
   })
 
@@ -208,14 +208,14 @@ describe('compiler + runtime integration', () => {
       template: `{{ count }}`,
       data() {
         return {
-          count: 0
+          count: 0,
         }
-      }
+      },
     }
     createApp(App).mount('#not-exist-id')
 
     expect(
-      '[Vue warn]: Failed to mount app: mount target selector "#not-exist-id" returned null.'
+      '[Vue warn]: Failed to mount app: mount target selector "#not-exist-id" returned null.',
     ).toHaveBeenWarned()
     document.querySelector = origin
   })
@@ -238,9 +238,9 @@ describe('compiler + runtime integration', () => {
       `,
       data() {
         return {
-          count
+          count,
         }
-      }
+      },
     }
     createApp(App).mount(container)
     expect(container.innerHTML).toBe(`<!--teleport start--><!--teleport end-->`)
@@ -265,7 +265,7 @@ describe('compiler + runtime integration', () => {
       setup() {
         return { ok }
       },
-      template: `<div>{{ ok }}<div v-if="ok" v-once>{{ ok }}</div></div>`
+      template: `<div>{{ ok }}<div v-if="ok" v-once>{{ ok }}</div></div>`,
     }
     const container = document.createElement('div')
     createApp(App).mount(container)
@@ -282,7 +282,7 @@ describe('compiler + runtime integration', () => {
       setup() {
         return { list }
       },
-      template: `<div>{{ list.length }}<div v-for="i in list" v-once>{{ i }}</div></div>`
+      template: `<div>{{ list.length }}<div v-for="i in list" v-once>{{ i }}</div></div>`,
     }
     const container = document.createElement('div')
     createApp(App).mount(container)
@@ -296,7 +296,7 @@ describe('compiler + runtime integration', () => {
   // #2413
   it('EMPTY_ARR should not change', () => {
     const App = {
-      template: `<div v-for="v of ['a']">{{ v }}</div>`
+      template: `<div v-for="v of ['a']">{{ v }}</div>`,
     }
     const container = document.createElement('div')
     createApp(App).mount(container)
@@ -305,7 +305,7 @@ describe('compiler + runtime integration', () => {
 
   test('BigInt support', () => {
     const app = createApp({
-      template: `<div>{{ BigInt(BigInt(100000111)) + BigInt(2000000000n) * 30000000n }}</div>`
+      template: `<div>{{ BigInt(BigInt(100000111)) + BigInt(2000000000n) * 30000000n }}</div>`,
     })
     const root = document.createElement('div')
     app.mount(root)
index 3fe1221f5342d187ad69708403143ad1f1b8116c..c3f8ab7ab3e8f6ddf23f0c0c9c5c2a8ff5c5d4be 100644 (file)
@@ -6,7 +6,7 @@
 // - compiler-core/src/transforms/transformElement.ts
 
 import { vtcKey } from '../../runtime-dom/src/components/Transition'
-import { render, h, ref, nextTick } from '../src'
+import { h, nextTick, ref, render } from '../src'
 
 describe('MathML support', () => {
   afterEach(() => {
@@ -35,7 +35,7 @@ describe('MathML support', () => {
           </annotation-xml>
         </semantics>
       </math>
-      `
+      `,
     }
     render(h(App), root)
     const e0 = document.getElementById('e0')!
@@ -61,7 +61,7 @@ describe('MathML support', () => {
             </annotation>
           </math>
         </div>
-      `
+      `,
     }
     render(h(App), root)
     const f1 = document.querySelector('#f1')!
index 3222462fea3aaf7252cbbee130b313993fb35dc6..b144be448d2274556096b7d10bcfc10f8a338910 100644 (file)
@@ -3,7 +3,7 @@ import { createApp } from 'vue'
 describe('config.compilerOptions', () => {
   test('isCustomElement', () => {
     const app = createApp({
-      template: `<foo/>`
+      template: `<foo/>`,
     })
     app.config.compilerOptions.isCustomElement = (tag: string) => tag === 'foo'
     const root = document.createElement('div')
@@ -13,7 +13,7 @@ describe('config.compilerOptions', () => {
 
   test('comments', () => {
     const app = createApp({
-      template: `<div/><!--test--><div/>`
+      template: `<div/><!--test--><div/>`,
     })
     app.config.compilerOptions.comments = true
     // the comments option is only relevant in production mode
@@ -26,7 +26,7 @@ describe('config.compilerOptions', () => {
 
   test('whitespace', () => {
     const app = createApp({
-      template: `<div><span/>\n  <span/></div>`
+      template: `<div><span/>\n  <span/></div>`,
     })
     app.config.compilerOptions.whitespace = 'preserve'
     const root = document.createElement('div')
@@ -38,7 +38,7 @@ describe('config.compilerOptions', () => {
   test('delimiters', () => {
     const app = createApp({
       data: () => ({ foo: 'hi' }),
-      template: `[[ foo ]]`
+      template: `[[ foo ]]`,
     })
     app.config.compilerOptions.delimiters = [`[[`, `]]`]
     const root = document.createElement('div')
@@ -52,8 +52,8 @@ describe('per-component compilerOptions', () => {
     const app = createApp({
       template: `<foo/>`,
       compilerOptions: {
-        isCustomElement: (tag: string) => tag === 'foo'
-      }
+        isCustomElement: (tag: string) => tag === 'foo',
+      },
     })
     const root = document.createElement('div')
     app.mount(root)
@@ -64,8 +64,8 @@ describe('per-component compilerOptions', () => {
     const app = createApp({
       template: `<div/><!--test--><div/>`,
       compilerOptions: {
-        comments: true
-      }
+        comments: true,
+      },
     })
     app.config.compilerOptions.comments = false
     // the comments option is only relevant in production mode
@@ -80,8 +80,8 @@ describe('per-component compilerOptions', () => {
     const app = createApp({
       template: `<div><span/>\n  <span/></div>`,
       compilerOptions: {
-        whitespace: 'preserve'
-      }
+        whitespace: 'preserve',
+      },
     })
     const root = document.createElement('div')
     app.mount(root)
@@ -94,8 +94,8 @@ describe('per-component compilerOptions', () => {
       data: () => ({ foo: 'hi' }),
       template: `[[ foo ]]`,
       compilerOptions: {
-        delimiters: [`[[`, `]]`]
-      }
+        delimiters: [`[[`, `]]`],
+      },
     })
     const root = document.createElement('div')
     app.mount(root)
index df52bbf60a8fdbf44a4b0f5fbb00e68e63c1f333..978f9bbb1fc92b0a7fb9ec95a2611c580de40626 100644 (file)
@@ -6,7 +6,7 @@
 // - compiler-core/src/transforms/transformElement.ts
 
 import { vtcKey } from '../../runtime-dom/src/components/Transition'
-import { render, h, ref, nextTick } from '../src'
+import { h, nextTick, ref, render } from '../src'
 
 describe('SVG support', () => {
   afterEach(() => {
@@ -27,7 +27,7 @@ describe('SVG support', () => {
             </foreignObject>
           </svg>
         </div>
-      `
+      `,
     }
     render(h(App), root)
     const e0 = document.getElementById('e0')!
@@ -53,7 +53,7 @@ describe('SVG support', () => {
             </foreignObject>
           </svg>
         </div>
-      `
+      `,
     }
     render(h(App), root)
     const f1 = document.querySelector('#f1')!
index 8b43612483a678b05513bdc4085e3822c4e21b24..fcb9204cbc7a92e094380e8c2e2372d3810db490 100644 (file)
@@ -1 +1 @@
-export * from './index.js'
\ No newline at end of file
+export * from './index.js'
index 9d022dd0c05710e12c9a0d74b9a706c16c3c8e6a..a52ac66a0dfb256c17de5160ac7eb41c003319f9 100644 (file)
@@ -1,4 +1,5 @@
-import type { VNode, ReservedProps, NativeElements } from '@vue/runtime-dom'
+/* eslint-disable @typescript-eslint/prefer-ts-expect-error */
+import type { NativeElements, ReservedProps, VNode } from '@vue/runtime-dom'
 
 /**
  * JSX namespace for usage with @jsxImportsSource directive
index 57dd60af68f12e5924bb78103a1a79db6304c991..e2528cba44757f0d89323dddc1fdeeaba5399cd3 100644 (file)
@@ -9,9 +9,4 @@ function jsx(type, props, key) {
   return h(type, props, children)
 }
 
-export {
-  Fragment,
-  jsx,
-  jsx as jsxs,
-  jsx as jsxDEV
-}
+export { Fragment, jsx, jsx as jsxs, jsx as jsxDEV }
index cec81c564d42e9f64ef12e8c046553e1ac82ed00..1fa1e32667644cad4d6a0166d450228ce764fd96 100644 (file)
@@ -1,6 +1,7 @@
+/* eslint-disable @typescript-eslint/prefer-ts-expect-error */
 // global JSX namespace registration
 // somehow we have to copy=pase the jsx-runtime types here to make TypeScript happy
-import type { VNode, ReservedProps, NativeElements } from '@vue/runtime-dom'
+import type { NativeElements, ReservedProps, VNode } from '@vue/runtime-dom'
 
 declare global {
   namespace JSX {
index 7feeb42ff581c6ad8c7f87d6dd3d50d54f7314a8..6e7a8a1dd4b4c47cda87b99e89795458151e61c4 100644 (file)
@@ -1,11 +1,11 @@
-import {
+import type {
+  ComputedRef,
+  CustomRefFactory,
+  DebuggerOptions,
   Ref,
   UnwrapRef,
-  ComputedRef,
   WritableComputedOptions,
-  DebuggerOptions,
   WritableComputedRef,
-  CustomRefFactory
 } from '@vue/runtime-dom'
 
 export declare const RefType: unique symbol
@@ -13,7 +13,7 @@ export declare const RefType: unique symbol
 export declare enum RefTypes {
   Ref = 1,
   ComputedRef = 2,
-  WritableComputedRef = 3
+  WritableComputedRef = 3,
 }
 
 type RefValue<T> = T extends null | undefined ? T : ReactiveVariable<T>
@@ -39,7 +39,7 @@ type NormalObject<T extends object> = T & { [RefType]?: never }
  */
 export declare function $<T>(arg: ComputedRef<T>): ComputedRefValue<T>
 export declare function $<T>(
-  arg: WritableComputedRef<T>
+  arg: WritableComputedRef<T>,
 ): WritableComputedRefValue<T>
 export declare function $<T>(arg: Ref<T>): RefValue<T>
 export declare function $<T extends object>(arg?: T): DestructureRefs<T>
@@ -61,7 +61,7 @@ export declare function $$<T extends object>(arg: NormalObject<T>): ToRawRefs<T>
 export declare function $$<T>(value: RefValue<T>): Ref<T>
 export declare function $$<T>(value: ComputedRefValue<T>): ComputedRef<T>
 export declare function $$<T>(
-  value: WritableComputedRefValue<T>
+  value: WritableComputedRefValue<T>,
 ): WritableComputedRef<T>
 
 type ToRawRefs<T extends object> = {
@@ -91,22 +91,22 @@ export declare function $shallowRef<T>(arg: T): RefValue<T>
 
 export declare function $toRef<T extends object, K extends keyof T>(
   object: T,
-  key: K
+  key: K,
 ): RefValue<T[K]>
 
 export declare function $toRef<T extends object, K extends keyof T>(
   object: T,
   key: K,
-  defaultValue: T[K]
+  defaultValue: T[K],
 ): RefValue<Exclude<T[K], undefined>>
 
 export declare function $customRef<T>(factory: CustomRefFactory<T>): RefValue<T>
 
 export declare function $computed<T>(
   getter: () => T,
-  debuggerOptions?: DebuggerOptions
+  debuggerOptions?: DebuggerOptions,
 ): ComputedRefValue<T>
 export declare function $computed<T>(
   options: WritableComputedOptions<T>,
-  debuggerOptions?: DebuggerOptions
+  debuggerOptions?: DebuggerOptions,
 ): WritableComputedRefValue<T>
index 3e081c15a23a35427145e0190c827a66744f377b..ac614729c756b66f3367fc4b72f144a8243c4d21 100644 (file)
@@ -1 +1 @@
-export * from '@vue/server-renderer'
\ No newline at end of file
+export * from '@vue/server-renderer'
index 79f233ed925b58f6008fb0048fa36e89027c0a86..602079a20e2165b54ad948633d694d22ca0f7daa 100644 (file)
@@ -6,7 +6,7 @@ export function initDev() {
     if (!__ESM_BUNDLER__) {
       console.info(
         `You are running a development build of Vue.\n` +
-          `Make sure to use the production build (*.prod.js) when deploying for production.`
+          `Make sure to use the production build (*.prod.js) when deploying for production.`,
       )
     }
 
index f926f140a5ec66ad9728b8567f4626330d9e434a..35077b3cf6315d3dbae2e004b1a0390fa316a874 100644 (file)
@@ -1,17 +1,25 @@
 // This entry is the "full-build" that includes both the runtime
 // and the compiler, and supports on-the-fly compilation of the template option.
 import { initDev } from './dev'
-import { compile, CompilerOptions, CompilerError } from '@vue/compiler-dom'
-import { registerRuntimeCompiler, RenderFunction, warn } from '@vue/runtime-dom'
+import {
+  type CompilerError,
+  type CompilerOptions,
+  compile,
+} from '@vue/compiler-dom'
+import {
+  type RenderFunction,
+  registerRuntimeCompiler,
+  warn,
+} from '@vue/runtime-dom'
 import * as runtimeDom from '@vue/runtime-dom'
 import {
-  isString,
+  EMPTY_OBJ,
   NOOP,
-  generateCodeFrame,
   extend,
-  EMPTY_OBJ
+  generateCodeFrame,
+  isString,
 } from '@vue/shared'
-import { InternalRenderFunction } from 'packages/runtime-core/src/component'
+import type { InternalRenderFunction } from 'packages/runtime-core/src/component'
 
 if (__DEV__) {
   initDev()
@@ -33,7 +41,7 @@ function getCache(options?: CompilerOptions) {
 
 function compileToFunction(
   template: string | HTMLElement,
-  options?: CompilerOptions
+  options?: CompilerOptions,
 ): RenderFunction {
   if (!isString(template)) {
     if (template.nodeType) {
@@ -67,9 +75,9 @@ function compileToFunction(
     {
       hoistStatic: true,
       onError: __DEV__ ? onError : undefined,
-      onWarn: __DEV__ ? e => onError(e, true) : NOOP
+      onWarn: __DEV__ ? e => onError(e, true) : NOOP,
     } as CompilerOptions,
-    options
+    options,
   )
 
   if (!opts.isCustomElement && typeof customElements !== 'undefined') {
@@ -87,7 +95,7 @@ function compileToFunction(
       generateCodeFrame(
         template as string,
         err.loc.start.offset,
-        err.loc.end.offset
+        err.loc.end.offset,
       )
     warn(codeFrame ? `${message}\n${codeFrame}` : message)
   }
index 1452fceb003156d749e6e11de3b078f5bcf2c30b..a0332bf798966171f766b54e0fc280baece44ea4 100644 (file)
@@ -19,7 +19,7 @@ export const compile = () => {
             ? ` Use "vue.esm-browser.js" instead.`
             : __GLOBAL__
               ? ` Use "vue.global.js" instead.`
-              : ``) /* should not happen */
+              : ``) /* should not happen */,
     )
   }
 }
index e654fe6dd08b16d6603b9f23a9c201682a710385..b74310a8e607548bb472db3a110dfd87a7ce0e46 100644 (file)
@@ -47,6 +47,9 @@ importers:
       '@types/semver':
         specifier: ^7.5.5
         version: 7.5.5
+      '@typescript-eslint/eslint-plugin':
+        specifier: ^6.16.0
+        version: 6.16.0(@typescript-eslint/parser@6.15.0)(eslint@8.56.0)(typescript@5.2.2)
       '@typescript-eslint/parser':
         specifier: ^6.15.0
         version: 6.15.0(eslint@8.56.0)(typescript@5.2.2)
@@ -74,9 +77,12 @@ importers:
       eslint-define-config:
         specifier: ^1.24.1
         version: 1.24.1
+      eslint-plugin-import:
+        specifier: npm:eslint-plugin-i@^2.29.1
+        version: /eslint-plugin-i@2.29.1(@typescript-eslint/parser@6.15.0)(eslint@8.56.0)
       eslint-plugin-jest:
         specifier: ^27.6.0
-        version: 27.6.0(eslint@8.56.0)(typescript@5.2.2)
+        version: 27.6.0(@typescript-eslint/eslint-plugin@6.16.0)(eslint@8.56.0)(typescript@5.2.2)
       estree-walker:
         specifier: ^2.0.2
         version: 2.0.2
@@ -1586,6 +1592,35 @@ packages:
     dev: true
     optional: true
 
+  /@typescript-eslint/eslint-plugin@6.16.0(@typescript-eslint/parser@6.15.0)(eslint@8.56.0)(typescript@5.2.2):
+    resolution: {integrity: sha512-O5f7Kv5o4dLWQtPX4ywPPa+v9G+1q1x8mz0Kr0pXUtKsevo+gIJHLkGc8RxaZWtP8RrhwhSNIWThnW42K9/0rQ==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    peerDependencies:
+      '@typescript-eslint/parser': ^6.0.0 || ^6.0.0-alpha
+      eslint: ^7.0.0 || ^8.0.0
+      typescript: '*'
+    peerDependenciesMeta:
+      typescript:
+        optional: true
+    dependencies:
+      '@eslint-community/regexpp': 4.9.1
+      '@typescript-eslint/parser': 6.15.0(eslint@8.56.0)(typescript@5.2.2)
+      '@typescript-eslint/scope-manager': 6.16.0
+      '@typescript-eslint/type-utils': 6.16.0(eslint@8.56.0)(typescript@5.2.2)
+      '@typescript-eslint/utils': 6.16.0(eslint@8.56.0)(typescript@5.2.2)
+      '@typescript-eslint/visitor-keys': 6.16.0
+      debug: 4.3.4
+      eslint: 8.56.0
+      graphemer: 1.4.0
+      ignore: 5.2.4
+      natural-compare: 1.4.0
+      semver: 7.5.4
+      ts-api-utils: 1.0.3(typescript@5.2.2)
+      typescript: 5.2.2
+    transitivePeerDependencies:
+      - supports-color
+    dev: true
+
   /@typescript-eslint/parser@6.15.0(eslint@8.56.0)(typescript@5.2.2):
     resolution: {integrity: sha512-MkgKNnsjC6QwcMdlNAel24jjkEO/0hQaMDLqP4S9zq5HBAUJNQB6y+3DwLjX7b3l2b37eNAxMPLwb3/kh8VKdA==}
     engines: {node: ^16.0.0 || >=18.0.0}
@@ -1623,6 +1658,34 @@ packages:
       '@typescript-eslint/visitor-keys': 6.15.0
     dev: true
 
+  /@typescript-eslint/scope-manager@6.16.0:
+    resolution: {integrity: sha512-0N7Y9DSPdaBQ3sqSCwlrm9zJwkpOuc6HYm7LpzLAPqBL7dmzAUimr4M29dMkOP/tEwvOCC/Cxo//yOfJD3HUiw==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    dependencies:
+      '@typescript-eslint/types': 6.16.0
+      '@typescript-eslint/visitor-keys': 6.16.0
+    dev: true
+
+  /@typescript-eslint/type-utils@6.16.0(eslint@8.56.0)(typescript@5.2.2):
+    resolution: {integrity: sha512-ThmrEOcARmOnoyQfYkHw/DX2SEYBalVECmoldVuH6qagKROp/jMnfXpAU/pAIWub9c4YTxga+XwgAkoA0pxfmg==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    peerDependencies:
+      eslint: ^7.0.0 || ^8.0.0
+      typescript: '*'
+    peerDependenciesMeta:
+      typescript:
+        optional: true
+    dependencies:
+      '@typescript-eslint/typescript-estree': 6.16.0(typescript@5.2.2)
+      '@typescript-eslint/utils': 6.16.0(eslint@8.56.0)(typescript@5.2.2)
+      debug: 4.3.4
+      eslint: 8.56.0
+      ts-api-utils: 1.0.3(typescript@5.2.2)
+      typescript: 5.2.2
+    transitivePeerDependencies:
+      - supports-color
+    dev: true
+
   /@typescript-eslint/types@5.62.0:
     resolution: {integrity: sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1633,6 +1696,11 @@ packages:
     engines: {node: ^16.0.0 || >=18.0.0}
     dev: true
 
+  /@typescript-eslint/types@6.16.0:
+    resolution: {integrity: sha512-hvDFpLEvTJoHutVl87+MG/c5C8I6LOgEx05zExTSJDEVU7hhR3jhV8M5zuggbdFCw98+HhZWPHZeKS97kS3JoQ==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    dev: true
+
   /@typescript-eslint/typescript-estree@5.62.0(typescript@5.2.2):
     resolution: {integrity: sha512-CmcQ6uY7b9y694lKdRB8FEel7JbU/40iSAPomu++SjLMntB+2Leay2LO6i8VnJk58MtE9/nQSFIH6jpyRWyYzA==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1675,6 +1743,28 @@ packages:
       - supports-color
     dev: true
 
+  /@typescript-eslint/typescript-estree@6.16.0(typescript@5.2.2):
+    resolution: {integrity: sha512-VTWZuixh/vr7nih6CfrdpmFNLEnoVBF1skfjdyGnNwXOH1SLeHItGdZDHhhAIzd3ACazyY2Fg76zuzOVTaknGA==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    peerDependencies:
+      typescript: '*'
+    peerDependenciesMeta:
+      typescript:
+        optional: true
+    dependencies:
+      '@typescript-eslint/types': 6.16.0
+      '@typescript-eslint/visitor-keys': 6.16.0
+      debug: 4.3.4
+      globby: 11.1.0
+      is-glob: 4.0.3
+      minimatch: 9.0.3
+      semver: 7.5.4
+      ts-api-utils: 1.0.3(typescript@5.2.2)
+      typescript: 5.2.2
+    transitivePeerDependencies:
+      - supports-color
+    dev: true
+
   /@typescript-eslint/utils@5.62.0(eslint@8.56.0)(typescript@5.2.2):
     resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1695,6 +1785,25 @@ packages:
       - typescript
     dev: true
 
+  /@typescript-eslint/utils@6.16.0(eslint@8.56.0)(typescript@5.2.2):
+    resolution: {integrity: sha512-T83QPKrBm6n//q9mv7oiSvy/Xq/7Hyw9SzSEhMHJwznEmQayfBM87+oAlkNAMEO7/MjIwKyOHgBJbxB0s7gx2A==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    peerDependencies:
+      eslint: ^7.0.0 || ^8.0.0
+    dependencies:
+      '@eslint-community/eslint-utils': 4.4.0(eslint@8.56.0)
+      '@types/json-schema': 7.0.14
+      '@types/semver': 7.5.5
+      '@typescript-eslint/scope-manager': 6.16.0
+      '@typescript-eslint/types': 6.16.0
+      '@typescript-eslint/typescript-estree': 6.16.0(typescript@5.2.2)
+      eslint: 8.56.0
+      semver: 7.5.4
+    transitivePeerDependencies:
+      - supports-color
+      - typescript
+    dev: true
+
   /@typescript-eslint/visitor-keys@5.62.0:
     resolution: {integrity: sha512-07ny+LHRzQXepkGg6w0mFY41fVUNBrL2Roj/++7V1txKugfjm/Ci/qSND03r2RhlJhJYMcTn9AhhSSqQp0Ysyw==}
     engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
@@ -1711,6 +1820,14 @@ packages:
       eslint-visitor-keys: 3.4.3
     dev: true
 
+  /@typescript-eslint/visitor-keys@6.16.0:
+    resolution: {integrity: sha512-QSFQLruk7fhs91a/Ep/LqRdbJCZ1Rq03rqBdKT5Ky17Sz8zRLUksqIe9DW0pKtg/Z35/ztbLQ6qpOCN6rOC11A==}
+    engines: {node: ^16.0.0 || >=18.0.0}
+    dependencies:
+      '@typescript-eslint/types': 6.16.0
+      eslint-visitor-keys: 3.4.3
+    dev: true
+
   /@ungap/structured-clone@1.2.0:
     resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==}
     dev: true
@@ -2562,6 +2679,17 @@ packages:
       ms: 2.0.0
     dev: true
 
+  /debug@3.2.7:
+    resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==}
+    peerDependencies:
+      supports-color: '*'
+    peerDependenciesMeta:
+      supports-color:
+        optional: true
+    dependencies:
+      ms: 2.1.2
+    dev: true
+
   /debug@4.3.4:
     resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
     engines: {node: '>=6.0'}
@@ -2879,7 +3007,68 @@ packages:
     engines: {node: '>=18.0.0', npm: '>=9.0.0', pnpm: '>= 8.6.0'}
     dev: true
 
-  /eslint-plugin-jest@27.6.0(eslint@8.56.0)(typescript@5.2.2):
+  /eslint-import-resolver-node@0.3.9:
+    resolution: {integrity: sha512-WFj2isz22JahUv+B788TlO3N6zL3nNJGU8CcZbPZvVEkBPaJdCV4vy5wyghty5ROFbCRnm132v8BScu5/1BQ8g==}
+    dependencies:
+      debug: 3.2.7
+      is-core-module: 2.13.1
+      resolve: 1.22.8
+    transitivePeerDependencies:
+      - supports-color
+    dev: true
+
+  /eslint-module-utils@2.8.0(@typescript-eslint/parser@6.15.0)(eslint-import-resolver-node@0.3.9)(eslint@8.56.0):
+    resolution: {integrity: sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==}
+    engines: {node: '>=4'}
+    peerDependencies:
+      '@typescript-eslint/parser': '*'
+      eslint: '*'
+      eslint-import-resolver-node: '*'
+      eslint-import-resolver-typescript: '*'
+      eslint-import-resolver-webpack: '*'
+    peerDependenciesMeta:
+      '@typescript-eslint/parser':
+        optional: true
+      eslint:
+        optional: true
+      eslint-import-resolver-node:
+        optional: true
+      eslint-import-resolver-typescript:
+        optional: true
+      eslint-import-resolver-webpack:
+        optional: true
+    dependencies:
+      '@typescript-eslint/parser': 6.15.0(eslint@8.56.0)(typescript@5.2.2)
+      debug: 3.2.7
+      eslint: 8.56.0
+      eslint-import-resolver-node: 0.3.9
+    transitivePeerDependencies:
+      - supports-color
+    dev: true
+
+  /eslint-plugin-i@2.29.1(@typescript-eslint/parser@6.15.0)(eslint@8.56.0):
+    resolution: {integrity: sha512-ORizX37MelIWLbMyqI7hi8VJMf7A0CskMmYkB+lkCX3aF4pkGV7kwx5bSEb4qx7Yce2rAf9s34HqDRPjGRZPNQ==}
+    engines: {node: '>=12'}
+    peerDependencies:
+      eslint: ^7.2.0 || ^8
+    dependencies:
+      debug: 4.3.4
+      doctrine: 3.0.0
+      eslint: 8.56.0
+      eslint-import-resolver-node: 0.3.9
+      eslint-module-utils: 2.8.0(@typescript-eslint/parser@6.15.0)(eslint-import-resolver-node@0.3.9)(eslint@8.56.0)
+      get-tsconfig: 4.7.2
+      is-glob: 4.0.3
+      minimatch: 3.1.2
+      semver: 7.5.4
+    transitivePeerDependencies:
+      - '@typescript-eslint/parser'
+      - eslint-import-resolver-typescript
+      - eslint-import-resolver-webpack
+      - supports-color
+    dev: true
+
+  /eslint-plugin-jest@27.6.0(@typescript-eslint/eslint-plugin@6.16.0)(eslint@8.56.0)(typescript@5.2.2):
     resolution: {integrity: sha512-MTlusnnDMChbElsszJvrwD1dN3x6nZl//s4JD23BxB6MgR66TZlL064su24xEIS3VACfAoHV1vgyMgPw8nkdng==}
     engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0}
     peerDependencies:
@@ -2892,6 +3081,7 @@ packages:
       jest:
         optional: true
     dependencies:
+      '@typescript-eslint/eslint-plugin': 6.16.0(@typescript-eslint/parser@6.15.0)(eslint@8.56.0)(typescript@5.2.2)
       '@typescript-eslint/utils': 5.62.0(eslint@8.56.0)(typescript@5.2.2)
       eslint: 8.56.0
     transitivePeerDependencies:
@@ -3464,6 +3654,13 @@ packages:
     resolution: {integrity: sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==}
     dev: true
 
+  /hasown@2.0.0:
+    resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==}
+    engines: {node: '>= 0.4'}
+    dependencies:
+      function-bind: 1.1.2
+    dev: true
+
   /hosted-git-info@2.8.9:
     resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==}
     dev: true
@@ -3648,6 +3845,12 @@ packages:
       has: 1.0.4
     dev: true
 
+  /is-core-module@2.13.1:
+    resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==}
+    dependencies:
+      hasown: 2.0.0
+    dev: true
+
   /is-date-object@1.0.5:
     resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==}
     engines: {node: '>= 0.4'}
index 3703faae28085d58398c020be67df8a98e79b48f..29fd844b96099568fd3242281572afd878c55ed7 100644 (file)
@@ -47,33 +47,33 @@ const [enumPlugin, enumDefines] = inlineEnums()
 const outputConfigs = {
   'esm-bundler': {
     file: resolve(`dist/${name}.esm-bundler.js`),
-    format: 'es'
+    format: 'es',
   },
   'esm-browser': {
     file: resolve(`dist/${name}.esm-browser.js`),
-    format: 'es'
+    format: 'es',
   },
   cjs: {
     file: resolve(`dist/${name}.cjs.js`),
-    format: 'cjs'
+    format: 'cjs',
   },
   global: {
     file: resolve(`dist/${name}.global.js`),
-    format: 'iife'
+    format: 'iife',
   },
   // runtime-only builds, for main "vue" package only
   'esm-bundler-runtime': {
     file: resolve(`dist/${name}.runtime.esm-bundler.js`),
-    format: 'es'
+    format: 'es',
   },
   'esm-browser-runtime': {
     file: resolve(`dist/${name}.runtime.esm-browser.js`),
-    format: 'es'
+    format: 'es',
   },
   'global-runtime': {
     file: resolve(`dist/${name}.runtime.global.js`),
-    format: 'iife'
-  }
+    format: 'iife',
+  },
 }
 
 /** @type {ReadonlyArray<PackageFormat>} */
@@ -183,7 +183,7 @@ function createConfig(format, output, plugins = []) {
         : `false`,
       __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: isBundlerESMBuild
         ? `__VUE_PROD_HYDRATION_MISMATCH_DETAILS__`
-        : `false`
+        : `false`,
     }
 
     if (!isBundlerESMBuild) {
@@ -213,14 +213,14 @@ function createConfig(format, output, plugins = []) {
         'context.onError(': `/*#__PURE__*/ context.onError(`,
         'emitError(': `/*#__PURE__*/ emitError(`,
         'createCompilerError(': `/*#__PURE__*/ createCompilerError(`,
-        'createDOMCompilerError(': `/*#__PURE__*/ createDOMCompilerError(`
+        'createDOMCompilerError(': `/*#__PURE__*/ createDOMCompilerError(`,
       })
     }
 
     if (isBundlerESMBuild) {
       Object.assign(replacements, {
         // preserve to be handled by bundlers
-        __DEV__: `!!(process.env.NODE_ENV !== 'production')`
+        __DEV__: `!!(process.env.NODE_ENV !== 'production')`,
       })
     }
 
@@ -229,7 +229,7 @@ function createConfig(format, output, plugins = []) {
       Object.assign(replacements, {
         'process.env': '({})',
         'process.platform': '""',
-        'process.stdout': 'null'
+        'process.stdout': 'null',
       })
     }
 
@@ -245,7 +245,7 @@ function createConfig(format, output, plugins = []) {
       'source-map-js',
       '@babel/parser',
       'estree-walker',
-      'entities/lib/decode.js'
+      'entities/lib/decode.js',
     ]
 
     if (isGlobalBuild || isBrowserESMBuild || isCompatPackage) {
@@ -263,7 +263,7 @@ function createConfig(format, output, plugins = []) {
         // for @vue/compiler-sfc / server-renderer
         ...['path', 'url', 'stream'],
         // somehow these throw warnings for runtime-* package builds
-        ...treeShakenDeps
+        ...treeShakenDeps,
       ]
     }
   }
@@ -285,7 +285,7 @@ function createConfig(format, output, plugins = []) {
         'teacup/lib/express',
         'arc-templates/dist/es5',
         'then-pug',
-        'then-jade'
+        'then-jade',
       ]
     }
 
@@ -295,10 +295,10 @@ function createConfig(format, output, plugins = []) {
         ? [
             commonJS({
               sourceMap: false,
-              ignore: cjsIgnores
+              ignore: cjsIgnores,
             }),
             ...(format === 'cjs' ? [] : [polyfillNode()]),
-            nodeResolve()
+            nodeResolve(),
           ]
         : []
 
@@ -312,10 +312,10 @@ function createConfig(format, output, plugins = []) {
     external: resolveExternal(),
     plugins: [
       json({
-        namedExports: false
+        namedExports: false,
       }),
       alias({
-        entries
+        entries,
       }),
       enumPlugin,
       ...resolveReplace(),
@@ -324,10 +324,10 @@ function createConfig(format, output, plugins = []) {
         sourceMap: output.sourcemap,
         minify: false,
         target: isServerRenderer || isNodeBuild ? 'es2019' : 'es2015',
-        define: resolveDefine()
+        define: resolveDefine(),
       }),
       ...resolveNodePlugins(),
-      ...plugins
+      ...plugins,
     ],
     output,
     onwarn: (msg, warn) => {
@@ -336,15 +336,15 @@ function createConfig(format, output, plugins = []) {
       }
     },
     treeshake: {
-      moduleSideEffects: false
-    }
+      moduleSideEffects: false,
+    },
   }
 }
 
 function createProductionConfig(/** @type {PackageFormat} */ format) {
   return createConfig(format, {
     file: resolve(`dist/${name}.${format}.prod.js`),
-    format: outputConfigs[format].format
+    format: outputConfigs[format].format,
   })
 }
 
@@ -353,17 +353,17 @@ function createMinifiedConfig(/** @type {PackageFormat} */ format) {
     format,
     {
       file: outputConfigs[format].file.replace(/\.js$/, '.prod.js'),
-      format: outputConfigs[format].format
+      format: outputConfigs[format].format,
     },
     [
       terser({
         module: /^esm/.test(format),
         compress: {
           ecma: 2015,
-          pure_getters: true
+          pure_getters: true,
         },
-        safari10: true
-      })
-    ]
+        safari10: true,
+      }),
+    ],
   )
 }
index a9b3a0cdad54c99fe55f5f83f0898ef965eca752..d715af4a4f81be2d5a7922d724c4b48931e07159 100644 (file)
@@ -1,13 +1,13 @@
 // @ts-check
 import assert from 'node:assert/strict'
 import { parse } from '@babel/parser'
-import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'
+import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'
 import MagicString from 'magic-string'
 import dts from 'rollup-plugin-dts'
 
 if (!existsSync('temp/packages')) {
   console.warn(
-    'no temp dts files found. run `tsc -p tsconfig.build.json` first.'
+    'no temp dts files found. run `tsc -p tsconfig.build.json` first.',
   )
   process.exit(1)
 }
@@ -25,7 +25,7 @@ export default targetPackages.map(
       input: `./temp/packages/${pkg}/src/index.d.ts`,
       output: {
         file: `packages/${pkg}/dist/${pkg}.d.ts`,
-        format: 'es'
+        format: 'es',
       },
       plugins: [dts(), patchTypes(pkg), ...(pkg === 'vue' ? [copyMts()] : [])],
       onwarn(warning, warn) {
@@ -37,9 +37,9 @@ export default targetPackages.map(
           return
         }
         warn(warning)
-      }
+      },
     }
-  }
+  },
 )
 
 /**
@@ -60,7 +60,7 @@ function patchTypes(pkg) {
       const s = new MagicString(code)
       const ast = parse(code, {
         plugins: ['typescript'],
-        sourceType: 'module'
+        sourceType: 'module',
       })
 
       /**
@@ -109,8 +109,8 @@ function patchTypes(pkg) {
             throw new Error(
               `unhandled declare const with more than one declarators:\n${code.slice(
                 node.start,
-                node.end
-              )}`
+                node.end,
+              )}`,
             )
           }
         } else if (
@@ -156,7 +156,7 @@ function patchTypes(pkg) {
                   prev
                     ? (assert(typeof prev.end === 'number'), prev.end)
                     : spec.start,
-                  spec.end
+                  spec.end,
                 )
               }
               removed++
@@ -181,7 +181,7 @@ function patchTypes(pkg) {
             .join('\n')
       }
       return code
-    }
+    },
   }
 }
 
@@ -199,6 +199,6 @@ function copyMts() {
     writeBundle(_, bundle) {
       assert('code' in bundle['vue.d.ts'])
       writeFileSync('packages/vue/dist/vue.d.mts', bundle['vue.d.ts'].code)
-    }
+    },
   }
 }
index 907196745f21c3043bd608695c91155ab4018db6..d50498a80aa3b37c53ac897c16c408d4bf714dc0 100644 (file)
@@ -7,7 +7,7 @@ import { fileURLToPath } from 'node:url'
 const resolveEntryForPkg = (/** @type {string} */ p) =>
   path.resolve(
     fileURLToPath(import.meta.url),
-    `../../packages/${p}/src/index.ts`
+    `../../packages/${p}/src/index.ts`,
   )
 
 const dirs = readdirSync(new URL('../packages', import.meta.url))
@@ -17,7 +17,7 @@ const entries = {
   vue: resolveEntryForPkg('vue'),
   'vue/compiler-sfc': resolveEntryForPkg('compiler-sfc'),
   'vue/server-renderer': resolveEntryForPkg('server-renderer'),
-  '@vue/compat': resolveEntryForPkg('vue-compat')
+  '@vue/compat': resolveEntryForPkg('vue-compat'),
 }
 
 const nonSrcPackages = ['sfc-playground', 'template-explorer', 'dts-test']
index aa56a13275be71d51c960ee69132047f61f35caf..eacabe0dee45e511bad581db506ae9813d54ce09 100644 (file)
@@ -20,7 +20,7 @@ import fs from 'node:fs/promises'
 import { existsSync } from 'node:fs'
 import path from 'node:path'
 import minimist from 'minimist'
-import { gzipSync, brotliCompressSync } from 'node:zlib'
+import { brotliCompressSync, gzipSync } from 'node:zlib'
 import pico from 'picocolors'
 import { execa, execaSync } from 'execa'
 import { cpus } from 'node:os'
@@ -64,11 +64,11 @@ async function run() {
           'build-dts',
           ...(targets.length
             ? ['--environment', `TARGETS:${resolvedTargets.join(',')}`]
-            : [])
+            : []),
         ],
         {
-          stdio: 'inherit'
-        }
+          stdio: 'inherit',
+        },
       )
     }
   } finally {
@@ -147,12 +147,12 @@ async function build(target) {
         `TARGET:${target}`,
         formats ? `FORMATS:${formats}` : ``,
         prodOnly ? `PROD_ONLY:true` : ``,
-        sourceMap ? `SOURCE_MAP:true` : ``
+        sourceMap ? `SOURCE_MAP:true` : ``,
       ]
         .filter(Boolean)
-        .join(',')
+        .join(','),
     ],
-    { stdio: 'inherit' }
+    { stdio: 'inherit' },
   )
 }
 
@@ -202,10 +202,10 @@ async function checkFileSize(filePath) {
 
   console.log(
     `${pico.gray(pico.bold(fileName))} min:${prettyBytes(
-      file.length
+      file.length,
     )} / gzip:${prettyBytes(gzipped.length)} / brotli:${prettyBytes(
-      brotli.length
-    )}`
+      brotli.length,
+    )}`,
   )
 
   if (writeSize)
@@ -215,8 +215,8 @@ async function checkFileSize(filePath) {
         file: fileName,
         size: file.length,
         gzip: gzipped.length,
-        brotli: brotli.length
+        brotli: brotli.length,
       }),
-      'utf-8'
+      'utf-8',
     )
 }
index 5f996a29831b874d925f7a1682d81b80c33bba5b..2c3cdaf95e2e7f8957e7f36f36b0f4c978357354 100644 (file)
@@ -5,7 +5,7 @@
 // smaller files and provides better tree-shaking.
 
 import esbuild from 'esbuild'
-import { resolve, relative, dirname } from 'node:path'
+import { dirname, relative, resolve } from 'node:path'
 import { fileURLToPath } from 'node:url'
 import { createRequire } from 'node:module'
 import minimist from 'minimist'
@@ -35,7 +35,7 @@ const outfile = resolve(
   __dirname,
   `../packages/${target}/dist/${
     target === 'vue-compat' ? `vue` : target
-  }.${postfix}.${prod ? `prod.` : ``}js`
+  }.${postfix}.${prod ? `prod.` : ``}js`,
 )
 const relativeOutfile = relative(process.cwd(), outfile)
 
@@ -53,7 +53,7 @@ if (!inlineDeps) {
       // for @vue/compiler-sfc / server-renderer
       'path',
       'url',
-      'stream'
+      'stream',
     ]
   }
 
@@ -61,11 +61,11 @@ if (!inlineDeps) {
     const consolidatePkgPath = require.resolve(
       '@vue/consolidate/package.json',
       {
-        paths: [resolve(__dirname, `../packages/${target}/`)]
-      }
+        paths: [resolve(__dirname, `../packages/${target}/`)],
+      },
     )
     const consolidateDeps = Object.keys(
-      require(consolidatePkgPath).devDependencies
+      require(consolidatePkgPath).devDependencies,
     )
     external = [
       ...external,
@@ -77,7 +77,7 @@ if (!inlineDeps) {
       'teacup/lib/express',
       'arc-templates/dist/es5',
       'then-pug',
-      'then-jade'
+      'then-jade',
     ]
   }
 }
@@ -89,8 +89,8 @@ const plugins = [
       build.onEnd(() => {
         console.log(`built: ${relativeOutfile}`)
       })
-    }
-  }
+    },
+  },
 ]
 
 if (format !== 'cjs' && pkg.buildOptions?.enableNonBrowserBranches) {
@@ -114,7 +114,7 @@ esbuild
       __DEV__: prod ? `false` : `true`,
       __TEST__: `false`,
       __BROWSER__: String(
-        format !== 'cjs' && !pkg.buildOptions?.enableNonBrowserBranches
+        format !== 'cjs' && !pkg.buildOptions?.enableNonBrowserBranches,
       ),
       __GLOBAL__: String(format === 'global'),
       __ESM_BUNDLER__: String(format.includes('esm-bundler')),
@@ -125,7 +125,7 @@ esbuild
       __FEATURE_SUSPENSE__: `true`,
       __FEATURE_OPTIONS_API__: `true`,
       __FEATURE_PROD_DEVTOOLS__: `false`,
-      __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: `false`
-    }
+      __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: `false`,
+    },
   })
   .then(ctx => ctx.watch())
index 0835dd8859eee4c35ffa9dfcf6e1f7baf5e668ff..40bd31bfd8ae1d987028c7b8c3f41fed6ae5dead 100644 (file)
@@ -17,7 +17,7 @@ import {
   mkdirSync,
   readFileSync,
   rmSync,
-  writeFileSync
+  writeFileSync,
 } from 'node:fs'
 import * as path from 'node:path'
 import { parse } from '@babel/parser'
@@ -58,7 +58,7 @@ export function scanEnums() {
     const content = readFileSync(file, 'utf-8')
     const ast = parse(content, {
       plugins: ['typescript'],
-      sourceType: 'module'
+      sourceType: 'module',
     })
 
     /** @type {Set<string>} */
@@ -73,7 +73,7 @@ export function scanEnums() {
         const id = decl.id.name
         if (enumIds.has(id)) {
           throw new Error(
-            `not support declaration merging for enum ${id} in ${file}`
+            `not support declaration merging for enum ${id} in ${file}`,
           )
         }
         enumIds.add(id)
@@ -95,7 +95,7 @@ export function scanEnums() {
             }
             members.push({
               name: key,
-              value
+              value,
             })
             defines[fullKey] = JSON.stringify(value)
           }
@@ -112,7 +112,7 @@ export function scanEnums() {
             // e.g. 1 << 2
             else if (init.type === 'BinaryExpression') {
               const resolveValue = (
-                /** @type {import('@babel/types').Expression | import('@babel/types').PrivateName} */ node
+                /** @type {import('@babel/types').Expression | import('@babel/types').PrivateName} */ node,
               ) => {
                 assert.ok(typeof node.start === 'number')
                 assert.ok(typeof node.end === 'number')
@@ -127,13 +127,13 @@ export function scanEnums() {
                   )
                   if (!(exp in defines)) {
                     throw new Error(
-                      `unhandled enum initialization expression ${exp} in ${file}`
+                      `unhandled enum initialization expression ${exp} in ${file}`,
                     )
                   }
                   return defines[exp]
                 } else {
                   throw new Error(
-                    `unhandled BinaryExpression operand type ${node.type} in ${file}`
+                    `unhandled BinaryExpression operand type ${node.type} in ${file}`,
                   )
                 }
               }
@@ -150,12 +150,12 @@ export function scanEnums() {
                 value = evaluate(exp)
               } else {
                 throw new Error(
-                  `unhandled UnaryExpression argument type ${init.argument.type} in ${file}`
+                  `unhandled UnaryExpression argument type ${init.argument.type} in ${file}`,
                 )
               }
             } else {
               throw new Error(
-                `unhandled initializer type ${init.type} for ${fullKey} in ${file}`
+                `unhandled initializer type ${init.type} for ${fullKey} in ${file}`,
               )
             }
             lastInitialized = value
@@ -183,7 +183,7 @@ export function scanEnums() {
         declarations[file].push({
           id,
           range: [node.start, node.end],
-          members
+          members,
         })
       }
     }
@@ -195,7 +195,7 @@ export function scanEnums() {
   /** @type {EnumData} */
   const enumData = {
     declarations,
-    defines
+    defines,
   }
 
   writeFileSync(ENUM_CACHE_PATH, JSON.stringify(enumData))
@@ -237,7 +237,7 @@ export function inlineEnums() {
           const {
             range: [start, end],
             id,
-            members
+            members,
           } = declaration
           s.update(
             start,
@@ -252,16 +252,16 @@ export function inlineEnums() {
                 // see https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
                 return typeof value === 'string'
                   ? [
-                      forwardMapping
+                      forwardMapping,
                       // string enum members do not get a reverse mapping generated at all
                     ]
                   : [
                       forwardMapping,
                       // other enum members should support enum reverse mapping
-                      reverseMapping
+                      reverseMapping,
                     ]
               })
-              .join(',\n')}}`
+              .join(',\n')}}`,
           )
         }
       }
@@ -269,10 +269,10 @@ export function inlineEnums() {
       if (s) {
         return {
           code: s.toString(),
-          map: s.generateMap()
+          map: s.generateMap(),
         }
       }
-    }
+    },
   }
 
   return [plugin, enumData.defines]
index deeb40918168a780aa54856da78ed0400334bfde..b28705f3464a4a0bf0985ff1aedf7e6d9a8840c7 100644 (file)
@@ -6,7 +6,7 @@ const packagesToCheck = [
   'compiler-core',
   'compiler-dom',
   'compiler-ssr',
-  'shared'
+  'shared',
 ]
 
 let allFilesPresent = true
@@ -14,7 +14,7 @@ let allFilesPresent = true
 for (const pkg of packagesToCheck) {
   if (
     !fs.existsSync(
-      new URL(`../packages/${pkg}/dist/${pkg}.cjs.js`, import.meta.url)
+      new URL(`../packages/${pkg}/dist/${pkg}.cjs.js`, import.meta.url),
     )
   ) {
     allFilesPresent = false
index fddf4ca67294a11fced2a4c26c67038b83c9cf50..6a962e07adfdbb8931d7514197271848234c09a5 100644 (file)
@@ -28,8 +28,8 @@ const args = minimist(process.argv.slice(2), {
     skipBuild: 'skip-build',
     skipTests: 'skip-tests',
     skipGit: 'skip-git',
-    skipPrompts: 'skip-prompts'
-  }
+    skipPrompts: 'skip-prompts',
+  },
 })
 
 const preId = args.preid || semver.prerelease(currentVersion)?.[0]
@@ -47,7 +47,7 @@ const packages = fs
     const pkgRoot = path.resolve(__dirname, '../packages', p)
     if (fs.statSync(pkgRoot).isDirectory()) {
       const pkg = JSON.parse(
-        fs.readFileSync(path.resolve(pkgRoot, 'package.json'), 'utf-8')
+        fs.readFileSync(path.resolve(pkgRoot, 'package.json'), 'utf-8'),
       )
       return !pkg.private
     }
@@ -90,7 +90,7 @@ const versionIncrements = [
   'major',
   ...(preId
     ? /** @type {const} */ (['prepatch', 'preminor', 'premajor', 'prerelease'])
-    : [])
+    : []),
 ]
 
 const inc = (/** @type {import('semver').ReleaseType} */ i) =>
@@ -98,12 +98,12 @@ const inc = (/** @type {import('semver').ReleaseType} */ i) =>
 const run = async (
   /** @type {string} */ bin,
   /** @type {ReadonlyArray<string>} */ args,
-  /** @type {import('execa').Options} */ opts = {}
+  /** @type {import('execa').Options} */ opts = {},
 ) => execa(bin, args, { stdio: 'inherit', ...opts })
 const dryRun = async (
   /** @type {string} */ bin,
   /** @type {ReadonlyArray<string>} */ args,
-  /** @type {import('execa').Options} */ opts = {}
+  /** @type {import('execa').Options} */ opts = {},
 ) => console.log(pico.blue(`[dryrun] ${bin} ${args.join(' ')}`), opts)
 const runIfNotDry = isDryRun ? dryRun : run
 const getPkgRoot = (/** @type {string} */ pkg) =>
@@ -143,7 +143,7 @@ async function main() {
       const { stdout } = await run(
         'pnpm',
         ['view', `${pkgName}@~${canaryVersion}`, 'version', '--json'],
-        { stdio: 'pipe' }
+        { stdio: 'pipe' },
       )
       let versions = JSON.parse(stdout)
       versions = Array.isArray(versions) ? versions : [versions]
@@ -177,7 +177,9 @@ async function main() {
       type: 'select',
       name: 'release',
       message: 'Select release type',
-      choices: versionIncrements.map(i => `${i} (${inc(i)})`).concat(['custom'])
+      choices: versionIncrements
+        .map(i => `${i} (${inc(i)})`)
+        .concat(['custom']),
     })
 
     if (release === 'custom') {
@@ -186,7 +188,7 @@ async function main() {
         type: 'input',
         name: 'version',
         message: 'Input custom version',
-        initial: currentVersion
+        initial: currentVersion,
       })
       targetVersion = result.version
     } else {
@@ -202,14 +204,14 @@ async function main() {
     step(
       isCanary
         ? `Releasing canary version v${targetVersion}...`
-        : `Releasing v${targetVersion}...`
+        : `Releasing v${targetVersion}...`,
     )
   } else {
     /** @type {{ yes: boolean }} */
     const { yes: confirmRelease } = await prompt({
       type: 'confirm',
       name: 'yes',
-      message: `Releasing v${targetVersion}. Confirm?`
+      message: `Releasing v${targetVersion}. Confirm?`,
     })
 
     if (!confirmRelease) {
@@ -227,7 +229,7 @@ async function main() {
       const { yes: promptSkipTests } = await prompt({
         type: 'confirm',
         name: 'yes',
-        message: `CI for this commit passed. Skip local tests?`
+        message: `CI for this commit passed. Skip local tests?`,
       })
 
       skipTests = promptSkipTests
@@ -249,7 +251,7 @@ async function main() {
   step('\nUpdating cross dependencies...')
   updateVersions(
     targetVersion,
-    isCanary ? renamePackageToCanary : keepThePackageName
+    isCanary ? renamePackageToCanary : keepThePackageName,
   )
   versionUpdated = true
 
@@ -272,7 +274,7 @@ async function main() {
     const { yes: changelogOk } = await prompt({
       type: 'confirm',
       name: 'yes',
-      message: `Changelog generated. Does it look good?`
+      message: `Changelog generated. Does it look good?`,
     })
 
     if (!changelogOk) {
@@ -335,9 +337,9 @@ async function main() {
     console.log(
       pico.yellow(
         `The following packages are skipped and NOT published:\n- ${skippedPackages.join(
-          '\n- '
-        )}`
-      )
+          '\n- ',
+        )}`,
+      ),
     )
   }
   console.log()
@@ -348,7 +350,7 @@ async function getCIResult() {
     const sha = await getSha()
     const res = await fetch(
       `https://api.github.com/repos/vuejs/core/actions/runs?head_sha=${sha}` +
-        `&status=success&exclude_pull_requests=true`
+        `&status=success&exclude_pull_requests=true`,
     )
     const data = await res.json()
     return data.workflow_runs.length > 0
@@ -362,7 +364,7 @@ async function isInSyncWithRemote() {
   try {
     const branch = await getBranch()
     const res = await fetch(
-      `https://api.github.com/repos/vuejs/core/commits/${branch}?per_page=1`
+      `https://api.github.com/repos/vuejs/core/commits/${branch}?per_page=1`,
     )
     const data = await res.json()
     if (data.sha === (await getSha())) {
@@ -373,14 +375,14 @@ async function isInSyncWithRemote() {
         type: 'confirm',
         name: 'yes',
         message: pico.red(
-          `Local HEAD is not up-to-date with remote. Are you sure you want to continue?`
-        )
+          `Local HEAD is not up-to-date with remote. Are you sure you want to continue?`,
+        ),
       })
       return yes
     }
   } catch (e) {
     console.error(
-      pico.red('Failed to check whether local HEAD is up-to-date with remote.')
+      pico.red('Failed to check whether local HEAD is up-to-date with remote.'),
     )
     return false
   }
@@ -403,7 +405,7 @@ function updateVersions(version, getNewPackageName = keepThePackageName) {
   updatePackage(path.resolve(__dirname, '..'), version, getNewPackageName)
   // 2. update all packages
   packages.forEach(p =>
-    updatePackage(getPkgRoot(p), version, getNewPackageName)
+    updatePackage(getPkgRoot(p), version, getNewPackageName),
   )
 }
 
@@ -439,7 +441,7 @@ function updateDeps(pkg, depType, version, getNewPackageName) {
       const newName = getNewPackageName(dep)
       const newVersion = newName === dep ? version : `npm:${newName}@${version}`
       console.log(
-        pico.yellow(`${pkg.name} -> ${depType} -> ${dep}@${newVersion}`)
+        pico.yellow(`${pkg.name} -> ${depType} -> ${dep}@${newVersion}`),
       )
       deps[dep] = newVersion
     }
@@ -478,12 +480,12 @@ async function publishPackage(pkgName, version, additionalFlags) {
         ...(releaseTag ? ['--tag', releaseTag] : []),
         '--access',
         'public',
-        ...additionalFlags
+        ...additionalFlags,
       ],
       {
         cwd: getPkgRoot(pkgName),
-        stdio: 'pipe'
-      }
+        stdio: 'pipe',
+      },
     )
     console.log(pico.green(`Successfully published ${pkgName}@${version}`))
   } catch (/** @type {any} */ e) {
index c0b0aa92376f258a18db5bb892078804ba2fa294..d5c65f0d3c0b23672df0329d4e2351c9d7bf1fca 100644 (file)
@@ -1,4 +1,4 @@
-import { type MockInstance } from 'vitest'
+import type { MockInstance } from 'vitest'
 
 vi.stubGlobal('MathMLElement', class MathMLElement {})
 
@@ -9,7 +9,7 @@ expect.extend({
     if (passed) {
       return {
         pass: true,
-        message: () => `expected "${received}" not to have been warned.`
+        message: () => `expected "${received}" not to have been warned.`,
       }
     } else {
       const msgs = warn.mock.calls.map(args => args[0]).join('\n - ')
@@ -19,7 +19,7 @@ expect.extend({
           `expected "${received}" to have been warned` +
           (msgs.length
             ? `.\n\nActual messages:\n\n - ${msgs}`
-            : ` but no warning was recorded.`)
+            : ` but no warning was recorded.`),
       }
     }
   },
@@ -31,14 +31,14 @@ expect.extend({
     if (passed) {
       return {
         pass: true,
-        message: () => `expected "${received}" not to have been warned last.`
+        message: () => `expected "${received}" not to have been warned last.`,
       }
     } else {
       const msgs = warn.mock.calls.map(args => args[0]).join('\n - ')
       return {
         pass: false,
         message: () =>
-          `expected "${received}" to have been warned last.\n\nActual messages:\n\n - ${msgs}`
+          `expected "${received}" to have been warned last.\n\nActual messages:\n\n - ${msgs}`,
       }
     }
   },
@@ -55,16 +55,16 @@ expect.extend({
     if (found === n) {
       return {
         pass: true,
-        message: () => `expected "${received}" to have been warned ${n} times.`
+        message: () => `expected "${received}" to have been warned ${n} times.`,
       }
     } else {
       return {
         pass: false,
         message: () =>
-          `expected "${received}" to have been warned ${n} times but got ${found}.`
+          `expected "${received}" to have been warned ${n} times but got ${found}.`,
       }
     }
-  }
+  },
 })
 
 let warn: MockInstance
@@ -89,8 +89,8 @@ afterEach(() => {
   if (nonAssertedWarnings.length) {
     throw new Error(
       `test case threw unexpected warnings:\n - ${nonAssertedWarnings.join(
-        '\n - '
-      )}`
+        '\n - ',
+      )}`,
     )
   }
 })
index 56e4491a19c99215ff3837d85ed0d08a0e7e8b81..a67aa3dd67c315d9bcdaee3407e1980d6cef1fd1 100644 (file)
@@ -54,7 +54,7 @@ async function renderFiles() {
         fileName,
         `${prettyBytes(curr.size)}${getDiff(curr.size, prev?.size)}`,
         `${prettyBytes(curr.gzip)}${getDiff(curr.gzip, prev?.gzip)}`,
-        `${prettyBytes(curr.brotli)}${getDiff(curr.brotli, prev?.brotli)}`
+        `${prettyBytes(curr.brotli)}${getDiff(curr.brotli, prev?.brotli)}`,
       ])
   }
 
@@ -65,10 +65,10 @@ async function renderFiles() {
 
 async function renderUsages() {
   const curr = (await importJSON<UsageResult>(
-    path.resolve(currDir, '_usages.json')
+    path.resolve(currDir, '_usages.json'),
   ))!
   const prev = await importJSON<UsageResult>(
-    path.resolve(prevDir, '_usages.json')
+    path.resolve(prevDir, '_usages.json'),
   )
   output += '\n### Usages\n\n'
 
@@ -83,7 +83,7 @@ async function renderUsages() {
         usage.name,
         `${prettyBytes(usage.size)}${diffSize}`,
         `${prettyBytes(usage.gzip)}${diffGzipped}`,
-        `${prettyBytes(usage.brotli)}${diffBrotli}`
+        `${prettyBytes(usage.brotli)}${diffBrotli}`,
       ]
     })
     .filter((usage): usage is string[] => !!usage)
index 31ee85daebb3ab575aea2f626c13201672057b9b..7eddbeb6696421f68640c8ca35da405aad53daf8 100644 (file)
@@ -1,4 +1,4 @@
-import { mkdir, writeFile } from 'fs/promises'
+import { mkdir, writeFile } from 'node:fs/promises'
 import path from 'node:path'
 import { rollup } from 'rollup'
 import nodeResolve from '@rollup/plugin-node-resolve'
@@ -26,9 +26,9 @@ const presets: Preset[] = [
       'watch',
       'Transition',
       'KeepAlive',
-      'Suspense'
-    ]
-  }
+      'Suspense',
+    ],
+  },
 ]
 
 main()
@@ -40,14 +40,14 @@ async function main() {
   }
 
   const results = Object.fromEntries(
-    (await Promise.all(tasks)).map(r => [r.name, r])
+    (await Promise.all(tasks)).map(r => [r.name, r]),
   )
 
   await mkdir(sizeDir, { recursive: true })
   await writeFile(
     path.resolve(sizeDir, '_usages.json'),
     JSON.stringify(results),
-    'utf-8'
+    'utf-8',
   )
 }
 
@@ -65,7 +65,7 @@ async function generateBundle(preset: Preset) {
         },
         load(_id) {
           if (_id === id) return content
-        }
+        },
       },
       nodeResolve(),
       replace({
@@ -73,9 +73,9 @@ async function generateBundle(preset: Preset) {
         __VUE_PROD_DEVTOOLS__: 'false',
         __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false',
         __VUE_OPTIONS_API__: 'true',
-        preventAssignment: true
-      })
-    ]
+        preventAssignment: true,
+      }),
+    ],
   })
 
   const generated = await result.generate({})
@@ -83,7 +83,7 @@ async function generateBundle(preset: Preset) {
   const minified = (
     await minify(bundled, {
       module: true,
-      toplevel: true
+      toplevel: true,
     })
   ).code!
 
@@ -95,6 +95,6 @@ async function generateBundle(preset: Preset) {
     name: preset.name,
     size,
     gzip,
-    brotli
+    brotli,
   }
 }
index 789e1bcf680ac6ab64a5dcc2ffea5b9da2546674..8b6566253882b31b3b8c4e4295a8e331359fe3bb 100644 (file)
@@ -40,8 +40,8 @@ export function fuzzyMatchTarget(partialTargets, includeAllMatching) {
     console.log()
     console.error(
       `  ${pico.white(pico.bgRed(' ERROR '))} ${pico.red(
-        `Target ${pico.underline(partialTargets.toString())} not found!`
-      )}`
+        `Target ${pico.underline(partialTargets.toString())} not found!`,
+      )}`,
     )
     console.log()
 
index 62af7fd1cf942365ca98f39f7c245055cae785cf..d37370df0233ad5bff5388dcb198908161861ac4 100644 (file)
@@ -1,7 +1,7 @@
 // @ts-check
 import pico from 'picocolors'
-import { readFileSync } from 'fs'
-import path from 'path'
+import { readFileSync } from 'node:fs'
+import path from 'node:path'
 
 const msgPath = path.resolve('.git/COMMIT_EDITMSG')
 const msg = readFileSync(msgPath, 'utf-8').trim()
@@ -13,16 +13,16 @@ if (!commitRE.test(msg)) {
   console.log()
   console.error(
     `  ${pico.white(pico.bgRed(' ERROR '))} ${pico.red(
-      `invalid commit message format.`
+      `invalid commit message format.`,
     )}\n\n` +
       pico.red(
-        `  Proper commit message format is required for automated changelog generation. Examples:\n\n`
+        `  Proper commit message format is required for automated changelog generation. Examples:\n\n`,
       ) +
       `    ${pico.green(`feat(compiler): add 'comments' option`)}\n` +
       `    ${pico.green(
-        `fix(v-model): handle events on blur (close #28)`
+        `fix(v-model): handle events on blur (close #28)`,
       )}\n\n` +
-      pico.red(`  See .github/commit-convention.md for more details.\n`)
+      pico.red(`  See .github/commit-convention.md for more details.\n`),
   )
   process.exit(1)
 }
index d1a7188a3d8f0594f12bcee4eb7127e5fb59cee4..a93b8bbbd614298a78b5bec16c721d4f401c3a2e 100644 (file)
@@ -7,26 +7,26 @@ execa('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => {
 
   const devBuild = fs.readFileSync(
     'packages/vue/dist/vue.runtime.global.js',
-    'utf-8'
+    'utf-8',
   )
 
   if (devBuild.includes('__spreadValues')) {
     errors.push(
       'dev build contains unexpected esbuild object spread helper.\n' +
         'This means { ...obj } syntax is used in runtime code. This should be ' +
-        'refactoed to use the `extend` helper to avoid the extra code.'
+        'refactoed to use the `extend` helper to avoid the extra code.',
     )
   }
 
   const prodBuild = fs.readFileSync(
     'packages/vue/dist/vue.runtime.global.prod.js',
-    'utf-8'
+    'utf-8',
   )
 
   if (prodBuild.includes('Vue warn')) {
     errors.push(
       'prod build contains unexpected warning-related code.\n' +
-        'This means there are calls of warn() that are not guarded by the __DEV__ condition.'
+        'This means there are calls of warn() that are not guarded by the __DEV__ condition.',
     )
   }
 
@@ -37,13 +37,13 @@ execa('pnpm', ['build', 'vue', '-f', 'global-runtime']).then(() => {
   ) {
     errors.push(
       'prod build contains unexpected domTagConifg lists.\n' +
-        'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.'
+        'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.',
     )
   }
 
   if (errors.length) {
     throw new Error(
-      `Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`
+      `Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`,
     )
   }
 })
index e6839a09eed665efb3c4b5c63b737331fcbd7775..6b5b93a45f9f80fc3536f92e08b5f9d0f2734377 100644 (file)
@@ -17,20 +17,20 @@ export default defineConfig({
     __FEATURE_SUSPENSE__: true,
     __FEATURE_PROD_DEVTOOLS__: false,
     __FEATURE_PROD_HYDRATION_MISMATCH_DETAILS__: false,
-    __COMPAT__: true
+    __COMPAT__: true,
   },
   resolve: {
-    alias: entries
+    alias: entries,
   },
   plugins: [codspeedPlugin()],
   test: {
     globals: true,
     setupFiles: 'scripts/setup-vitest.ts',
     environmentMatchGlobs: [
-      ['packages/{vue,vue-compat,runtime-dom}/**', 'jsdom']
+      ['packages/{vue,vue-compat,runtime-dom}/**', 'jsdom'],
     ],
     sequence: {
-      hooks: 'list'
+      hooks: 'list',
     },
     coverage: {
       provider: 'istanbul',
@@ -40,8 +40,8 @@ export default defineConfig({
         // DOM transitions are tested via e2e so no coverage is collected
         'packages/runtime-dom/src/components/Transition*',
         // mostly entries
-        'packages/vue-compat/**'
-      ]
-    }
-  }
+        'packages/vue-compat/**',
+      ],
+    },
+  },
 })
index a75631d58085663e1fc96ddb194f1e8660538a93..ecf1c9d95f0c7cd09b3cb9c3bb4dd50c79fe1588 100644 (file)
@@ -3,6 +3,6 @@ import config from './vitest.config'
 
 export default mergeConfig(config, {
   test: {
-    include: ['packages/vue/__tests__/e2e/*.spec.ts']
-  }
+    include: ['packages/vue/__tests__/e2e/*.spec.ts'],
+  },
 })
index 60648540c100f0da8880bd2deec1857a24f79a65..80549766c50dfd5eb67550cc5a44513d261fd70a 100644 (file)
@@ -3,6 +3,6 @@ import config from './vitest.config'
 
 export default mergeConfig(config, {
   test: {
-    exclude: [...configDefaults.exclude, '**/e2e/**']
-  }
+    exclude: [...configDefaults.exclude, '**/e2e/**'],
+  },
 })