]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler/codegen): add simple expression node opening bracket for ConditionalExpr...
authorAndrey Sukhonosov <andrey4897@gmail.com>
Sat, 5 Oct 2019 19:42:49 +0000 (22:42 +0300)
committerEvan You <yyx990803@gmail.com>
Sat, 5 Oct 2019 19:42:49 +0000 (15:42 -0400)
packages/compiler-core/__tests__/__snapshots__/compile.spec.ts.snap
packages/compiler-core/__tests__/transforms/__snapshots__/vSlot.spec.ts.snap
packages/compiler-core/src/codegen.ts

index 1aafaf9ea3ce48ef8d807b2957a3ca0aeb3b539e..d9ade929bac76119fd196c988bde9d352cbb3b00 100644 (file)
@@ -35,7 +35,7 @@ return function render() {
     class: _ctx.bar.baz
   }, [
     toString(_ctx.world.burn()),
-    (openBlock(), _ctx.ok)
+    (openBlock(), (_ctx.ok)
       ? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
       : createBlock(Fragment, { key: 1 }, [\\"no\\"])),
     (openBlock(), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
@@ -57,7 +57,7 @@ export default function render() {
     class: _ctx.bar.baz
   }, [
     _toString(_ctx.world.burn()),
-    (openBlock(), _ctx.ok)
+    (openBlock(), (_ctx.ok)
       ? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
       : createBlock(Fragment, { key: 1 }, [\\"no\\"])),
     (openBlock(), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
index 2532d053fdc6bbd7fc498ab8b58bb3fc9570967d..8bbb14f28eb7a5719bfb17c8e347394ce6a8576c 100644 (file)
@@ -71,7 +71,7 @@ return function render() {
   const _component_Comp = resolveComponent(\\"Comp\\")
   
   return (openBlock(), createBlock(_component_Comp, null, createSlots({ _compiled: true }, [
-    _ctx.ok)
+    (_ctx.ok)
       ? {
           name: \\"one\\",
           fn: (props) => [toString(props)]
index 4c468e30df86d80fc251d2377a10a814c9c584cc..27e63eeb0a109aa196e71c341ea249f1c6739e61 100644 (file)
@@ -528,6 +528,7 @@ function genConditionalExpression(
   const { push, indent, deindent, newline } = context
   if (test.type === NodeTypes.SIMPLE_EXPRESSION) {
     const needsParens = !isSimpleIdentifier(test.content)
+    needsParens && push(`(`)
     genExpression(test, context)
     needsParens && push(`)`)
   } else {