Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-sfc): properly handle assignment expressions with local vars in inline mode #4520

Merged
merged 4 commits into from
Sep 5, 2021

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Sep 4, 2021

fix #4514

Copy link
Contributor

@lidlanca lidlanca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider an additional test for the "local variable" in template, which is not explicitly
covered by the assignment fix test case

  test('template local variable', ()=>{
    const { content } = compile(
      `<script setup>
      import {ref} from "vue"
      const v = ref()
      </script>
      <template>
        <div @click="(e) => {
          let a = 1 
          const b = a
          var c = b
          (a,b,c,d,e)  // all local

          // nested scopes
          (()=>{
            let x = a
            (()=>{
              let z = x
              let z2 = z
            })
            let fromNonLocalZ = z // _ctx is expected
          })        
          v = a
          var d = 4
      }"/>

      </template>
      `,
      { inlineTemplate: true }
    )
    assertCode(content)
  })

@yyx990803 yyx990803 merged commit 5594643 into vuejs:master Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

template | local variable reference in a function is prefixed with _ctx
3 participants