fix(compiler/codegen): add simple expression node opening bracket for ConditionalExpression (#110)
This commit is contained in:
		
							parent
							
								
									842f235ede
								
							
						
					
					
						commit
						de9507b6ff
					
				@ -35,7 +35,7 @@ return function render() {
 | 
				
			|||||||
    class: _ctx.bar.baz
 | 
					    class: _ctx.bar.baz
 | 
				
			||||||
  }, [
 | 
					  }, [
 | 
				
			||||||
    toString(_ctx.world.burn()),
 | 
					    toString(_ctx.world.burn()),
 | 
				
			||||||
    (openBlock(), _ctx.ok)
 | 
					    (openBlock(), (_ctx.ok)
 | 
				
			||||||
      ? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
 | 
					      ? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
 | 
				
			||||||
      : createBlock(Fragment, { key: 1 }, [\\"no\\"])),
 | 
					      : createBlock(Fragment, { key: 1 }, [\\"no\\"])),
 | 
				
			||||||
    (openBlock(), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
 | 
					    (openBlock(), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
 | 
				
			||||||
@ -57,7 +57,7 @@ export default function render() {
 | 
				
			|||||||
    class: _ctx.bar.baz
 | 
					    class: _ctx.bar.baz
 | 
				
			||||||
  }, [
 | 
					  }, [
 | 
				
			||||||
    _toString(_ctx.world.burn()),
 | 
					    _toString(_ctx.world.burn()),
 | 
				
			||||||
    (openBlock(), _ctx.ok)
 | 
					    (openBlock(), (_ctx.ok)
 | 
				
			||||||
      ? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
 | 
					      ? createBlock(\\"div\\", { key: 0 }, \\"yes\\")
 | 
				
			||||||
      : createBlock(Fragment, { key: 1 }, [\\"no\\"])),
 | 
					      : createBlock(Fragment, { key: 1 }, [\\"no\\"])),
 | 
				
			||||||
    (openBlock(), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
 | 
					    (openBlock(), createBlock(Fragment, null, renderList(_ctx.list, (value, index) => {
 | 
				
			||||||
 | 
				
			|||||||
@ -71,7 +71,7 @@ return function render() {
 | 
				
			|||||||
  const _component_Comp = resolveComponent(\\"Comp\\")
 | 
					  const _component_Comp = resolveComponent(\\"Comp\\")
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  return (openBlock(), createBlock(_component_Comp, null, createSlots({ _compiled: true }, [
 | 
					  return (openBlock(), createBlock(_component_Comp, null, createSlots({ _compiled: true }, [
 | 
				
			||||||
    _ctx.ok)
 | 
					    (_ctx.ok)
 | 
				
			||||||
      ? {
 | 
					      ? {
 | 
				
			||||||
          name: \\"one\\",
 | 
					          name: \\"one\\",
 | 
				
			||||||
          fn: (props) => [toString(props)]
 | 
					          fn: (props) => [toString(props)]
 | 
				
			||||||
 | 
				
			|||||||
@ -528,6 +528,7 @@ function genConditionalExpression(
 | 
				
			|||||||
  const { push, indent, deindent, newline } = context
 | 
					  const { push, indent, deindent, newline } = context
 | 
				
			||||||
  if (test.type === NodeTypes.SIMPLE_EXPRESSION) {
 | 
					  if (test.type === NodeTypes.SIMPLE_EXPRESSION) {
 | 
				
			||||||
    const needsParens = !isSimpleIdentifier(test.content)
 | 
					    const needsParens = !isSimpleIdentifier(test.content)
 | 
				
			||||||
 | 
					    needsParens && push(`(`)
 | 
				
			||||||
    genExpression(test, context)
 | 
					    genExpression(test, context)
 | 
				
			||||||
    needsParens && push(`)`)
 | 
					    needsParens && push(`)`)
 | 
				
			||||||
  } else {
 | 
					  } else {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user