]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
refactor(compiler-vapor): remove redundant empty strings (#13993) vapor-alpha-branch
authorzhiyuanzmj <260480378@qq.com>
Fri, 17 Oct 2025 02:38:30 +0000 (10:38 +0800)
committerGitHub <noreply@github.com>
Fri, 17 Oct 2025 02:38:30 +0000 (10:38 +0800)
packages/compiler-vapor/__tests__/transforms/__snapshots__/transformElement.spec.ts.snap
packages/compiler-vapor/__tests__/transforms/__snapshots__/transformSlotOutlet.spec.ts.snap
packages/compiler-vapor/__tests__/transforms/__snapshots__/vModel.spec.ts.snap
packages/compiler-vapor/__tests__/transforms/__snapshots__/vOn.spec.ts.snap
packages/compiler-vapor/__tests__/transforms/__snapshots__/vSlot.spec.ts.snap
packages/compiler-vapor/__tests__/transforms/transformElement.spec.ts
packages/compiler-vapor/__tests__/transforms/vOn.spec.ts
packages/compiler-vapor/src/generators/utils.ts

index 3188a866070b762926636a68204f4fd9f157758e..2b9ed3bdbb09473450246bd80d52410425b4bb55 100644 (file)
@@ -125,7 +125,7 @@ exports[`compiler: element transform > component > static props 1`] = `
 export function render(_ctx) {
   const _component_Foo = _resolveComponent("Foo")
   const n0 = _createComponentWithFallback(_component_Foo, {
-    id: () => ("foo"), 
+    id: () => ("foo"),
     class: () => ("bar")
   }, null, true)
   return n0
@@ -150,7 +150,7 @@ exports[`compiler: element transform > component > v-bind="obj" after static pro
 export function render(_ctx) {
   const _component_Foo = _resolveComponent("Foo")
   const n0 = _createComponentWithFallback(_component_Foo, {
-    id: () => ("foo"), 
+    id: () => ("foo"),
     $: [
       () => (_ctx.obj)
     ]
@@ -165,7 +165,7 @@ exports[`compiler: element transform > component > v-bind="obj" before static pr
 export function render(_ctx) {
   const _component_Foo = _resolveComponent("Foo")
   const n0 = _createComponentWithFallback(_component_Foo, { $: [
-    () => (_ctx.obj), 
+    () => (_ctx.obj),
     { id: () => ("foo") }
   ] }, null, true)
   return n0
@@ -178,9 +178,9 @@ exports[`compiler: element transform > component > v-bind="obj" between static p
 export function render(_ctx) {
   const _component_Foo = _resolveComponent("Foo")
   const n0 = _createComponentWithFallback(_component_Foo, {
-    id: () => ("foo"), 
+    id: () => ("foo"),
     $: [
-      () => (_ctx.obj), 
+      () => (_ctx.obj),
       { class: () => ("bar") }
     ]
   }, null, true)
@@ -262,7 +262,7 @@ exports[`compiler: element transform > component with dynamic event arguments 1`
 export function render(_ctx) {
   const _component_Foo = _resolveComponent("Foo")
   const n0 = _createComponentWithFallback(_component_Foo, { $: [
-    () => ({ [_toHandlerKey(_ctx.foo-_ctx.bar)]: () => _ctx.bar }), 
+    () => ({ [_toHandlerKey(_ctx.foo-_ctx.bar)]: () => _ctx.bar }),
     () => ({ [_toHandlerKey(_ctx.baz)]: () => _ctx.qux })
   ] }, null, true)
   return n0
@@ -275,7 +275,7 @@ exports[`compiler: element transform > component with dynamic prop arguments 1`]
 export function render(_ctx) {
   const _component_Foo = _resolveComponent("Foo")
   const n0 = _createComponentWithFallback(_component_Foo, { $: [
-    () => ({ [_ctx.foo-_ctx.bar]: _ctx.bar }), 
+    () => ({ [_ctx.foo-_ctx.bar]: _ctx.bar }),
     () => ({ [_ctx.baz]: _ctx.qux })
   ] }, null, true)
   return n0
index 6d62b9c4e3560b6e8b0b9d8cb925d73f97d17737..caac138dcefaecdfb072b110d9d0fbc18859d7a0 100644 (file)
@@ -40,8 +40,8 @@ exports[`compiler: transform <slot> outlets > default slot outlet with props 1`]
 
 export function render(_ctx) {
   const n0 = _createSlot("default", {
-    foo: () => ("bar"), 
-    baz: () => (_ctx.qux), 
+    foo: () => ("bar"),
+    baz: () => (_ctx.qux),
     fooBar: () => (_ctx.foo-_ctx.bar)
   })
   return n0
@@ -125,7 +125,7 @@ exports[`compiler: transform <slot> outlets > statically named slot outlet with
 
 export function render(_ctx) {
   const n0 = _createSlot("foo", {
-    foo: () => ("bar"), 
+    foo: () => ("bar"),
     baz: () => (_ctx.qux)
   })
   return n0
@@ -137,9 +137,9 @@ exports[`compiler: transform <slot> outlets > statically named slot outlet with
 
 export function render(_ctx) {
   const n0 = _createSlot("foo", {
-    foo: () => ("bar"), 
+    foo: () => ("bar"),
     $: [
-      () => (_ctx.obj), 
+      () => (_ctx.obj),
       { baz: () => (_ctx.qux) }
     ]
   })
@@ -152,9 +152,9 @@ exports[`compiler: transform <slot> outlets > statically named slot outlet with
 
 export function render(_ctx) {
   const n0 = _createSlot("default", {
-    onClick: () => _ctx.foo, 
+    onClick: () => _ctx.foo,
     $: [
-      () => (_toHandlers(_ctx.bar)), 
+      () => (_toHandlers(_ctx.bar)),
       { baz: () => (_ctx.qux) }
     ]
   })
index 5ef064974c0e8bcbe9e515b75e60ae93013fe28f..ae1def83001f2b99441afbb5755dbf0f9dad7edf 100644 (file)
@@ -31,7 +31,7 @@ export function render(_ctx) {
   const n0 = _createComponentWithFallback(_component_Comp, {
     foo: () => (_ctx.foo),
     "onUpdate:foo": () => _value => (_ctx.foo = _value),
-    fooModifiers: () => ({ trim: true }), 
+    fooModifiers: () => ({ trim: true }),
     bar: () => (_ctx.bar),
     "onUpdate:bar": () => _value => (_ctx.bar = _value),
     barModifiers: () => ({ number: true })
@@ -59,7 +59,7 @@ export function render(_ctx) {
   const n0 = _createComponentWithFallback(_component_Comp, { $: [
     () => ({ [_ctx.foo]: _ctx.foo,
     ["onUpdate:" + _ctx.foo]: () => _value => (_ctx.foo = _value),
-    [_ctx.foo + "Modifiers"]: () => ({ trim: true }) }), 
+    [_ctx.foo + "Modifiers"]: () => ({ trim: true }) }),
     () => ({ [_ctx.bar]: _ctx.bar,
     ["onUpdate:" + _ctx.bar]: () => _value => (_ctx.bar = _value),
     [_ctx.bar + "Modifiers"]: () => ({ number: true }) })
index e7a2b30e69cc0655e2c1b19e1016b028fd6aa791..8423cb2ed5588d1f5a2c23b05820ce481c229778 100644 (file)
@@ -20,7 +20,7 @@ export function render(_ctx) {
   const _on_update_model = () => {}
   const _on_update_model1 = () => {}
   const n0 = _createComponentWithFallback(_component_Foo, {
-    "onUpdate:model": () => _on_update_model, 
+    "onUpdate:model": () => _on_update_model,
     "onUpdate-model": () => _on_update_model1
   }, null, true)
   return n0
@@ -333,7 +333,7 @@ const t0 = _template("<div></div>", true)
 export function render(_ctx) {
   const n0 = t0()
   _on(n0, "click", _withModifiers(e => _ctx.test(e), ["stop","prevent"]), {
-    capture: true, 
+    capture: true,
     once: true
   })
   return n0
index f296d7257d0e8cf4e45fb1e81939466d43cac4b4..d77f05ab032127b1f43a097e3b80ad5d30ccbfb4 100644 (file)
@@ -9,7 +9,7 @@ export function render(_ctx) {
   const n2 = _createComponentWithFallback(_component_Comp, null, {
     $: [
       () => ({
-        name: _ctx.name, 
+        name: _ctx.name,
         fn: () => {
           const n0 = t0()
           return n0
@@ -30,7 +30,7 @@ export function render(_ctx) {
   const n2 = _createComponentWithFallback(_component_Comp, null, {
     $: [
       () => (_createForSlots(_ctx.list, (item) => ({
-        name: item, 
+        name: item,
         fn: (_slotProps0) => {
           const n0 = t0()
           _renderEffect(() => _setText(n0, _toDisplayString(_slotProps0["bar"])))
@@ -52,7 +52,7 @@ export function render(_ctx) {
   const n2 = _createComponentWithFallback(_component_Comp, null, {
     $: [
       () => (_createForSlots(_ctx.list, (_, __, index) => ({
-        name: index, 
+        name: index,
         fn: () => {
           const n0 = t0()
           return n0
@@ -76,7 +76,7 @@ export function render(_ctx) {
     $: [
       () => (_ctx.condition
         ? {
-          name: "condition", 
+          name: "condition",
           fn: () => {
             const n0 = t0()
             return n0
@@ -84,14 +84,14 @@ export function render(_ctx) {
         }
         : _ctx.anotherCondition
           ? {
-            name: "condition", 
+            name: "condition",
             fn: (_slotProps0) => {
               const n2 = t1()
               return n2
             }
           }
           : {
-            name: "condition", 
+            name: "condition",
             fn: () => {
               const n4 = t2()
               return n4
@@ -131,7 +131,7 @@ export function render(_ctx) {
     "one": () => {
       const n0 = t0()
       return n0
-    }, 
+    },
     "default": () => {
       const n2 = t1()
       const n3 = t2()
@@ -192,7 +192,7 @@ export function render(_ctx) {
   const n1 = _createComponentWithFallback(_component_Comp, null, {
     $: [
       () => ({
-        name: _ctx.named, 
+        name: _ctx.named,
         fn: (_slotProps0) => {
           const n0 = t0()
           _renderEffect(() => _setText(n0, _toDisplayString(_slotProps0["foo"] + _ctx.bar)))
@@ -287,7 +287,7 @@ export function render(_ctx) {
     "header": () => {
       const n0 = t0()
       return n0
-    }, 
+    },
     "default": () => {
       const n2 = t1()
       const n3 = t2()
@@ -309,7 +309,7 @@ export function render(_ctx) {
     "header": () => {
       const n0 = t0()
       return n0
-    }, 
+    },
     "default": () => {
       const n3 = t1()
       return n3
@@ -330,7 +330,7 @@ export function render(_ctx) {
     "header": () => {
       const n0 = t0()
       return n0
-    }, 
+    },
     "footer": () => {
       const n3 = t1()
       return n3
index a693db4ad3961f85cd9367650b565217880c4479..20f6005ffe7bb93bb2ad37b65b485bf56e377d78 100644 (file)
@@ -194,7 +194,7 @@ describe('compiler: element transform', () => {
 
       expect(code).toMatchSnapshot()
       expect(code).contains(`{
-    id: () => ("foo"), 
+    id: () => ("foo"),
     class: () => ("bar")
   }`)
 
@@ -262,7 +262,7 @@ describe('compiler: element transform', () => {
       )
       expect(code).toMatchSnapshot()
       expect(code).contains(`{
-    id: () => ("foo"), 
+    id: () => ("foo"),
     $: [
       () => (_ctx.obj)
     ]
@@ -286,7 +286,7 @@ describe('compiler: element transform', () => {
       )
       expect(code).toMatchSnapshot()
       expect(code).contains(`[
-    () => (_ctx.obj), 
+    () => (_ctx.obj),
     { id: () => ("foo") }
   ]`)
       expect(ir.block.dynamic.children[0].operation).toMatchObject({
@@ -308,9 +308,9 @@ describe('compiler: element transform', () => {
       )
       expect(code).toMatchSnapshot()
       expect(code).contains(`{
-    id: () => ("foo"), 
+    id: () => ("foo"),
     $: [
-      () => (_ctx.obj), 
+      () => (_ctx.obj),
       { class: () => ("bar") }
     ]
   }`)
index 963f46ad2a3a8a4cdf0fea4924a7f370aa95ed2e..414ea0e298b70de8b7928609faf41096e59c578e 100644 (file)
@@ -415,7 +415,7 @@ describe('v-on', () => {
     ])
     expect(code).contains(
       `_on(n0, "click", _withModifiers(e => _ctx.test(e), ["stop","prevent"]), {
-    capture: true, 
+    capture: true,
     once: true
   })`,
     )
index 904b3dc87cac351db97a71a23db1acd32f53c239..93e50a244c1f48731b80c9738d50a2ba8ffb237a 100644 (file)
@@ -79,13 +79,13 @@ export const DELIMITERS_ARRAY: CodeFragmentDelimiters = ['[', ']', ', ']
 export const DELIMITERS_ARRAY_NEWLINE: CodeFragmentDelimiters = [
   ['[', INDENT_START, NEWLINE],
   [INDENT_END, NEWLINE, ']'],
-  [', ', NEWLINE],
+  [',', NEWLINE],
 ]
 export const DELIMITERS_OBJECT: CodeFragmentDelimiters = ['{ ', ' }', ', ']
 export const DELIMITERS_OBJECT_NEWLINE: CodeFragmentDelimiters = [
   ['{', INDENT_START, NEWLINE],
   [INDENT_END, NEWLINE, '}'],
-  [', ', NEWLINE],
+  [',', NEWLINE],
 ]
 
 export function genCall(