Skip to content

Fixed syntax error when function expression on v-on. #35

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

Merged
merged 5 commits into from
Dec 31, 2018

Conversation

ota-meshi
Copy link
Member

@ota-meshi ota-meshi commented Dec 10, 2018

This PR will fix parsing errors reported in vuejs/eslint-plugin-vue#716.

@codecov
Copy link

codecov bot commented Dec 10, 2018

Codecov Report

Merging #35 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #35      +/-   ##
==========================================
+ Coverage   85.94%   85.97%   +0.03%     
==========================================
  Files          32       32              
  Lines        2013     2018       +5     
  Branches      514      515       +1     
==========================================
+ Hits         1730     1735       +5     
  Misses        192      192              
  Partials       91       91
Impacted Files Coverage Δ
src/script/index.ts 85.22% <100%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b599764...e214142. Read the comment docs.

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

Thank you for this PR, and I apologize for my delay.

I have a change request. Please unwrap VOnExpression node if Vue.js doesn't handle it as a statement list. I intended VOnExpression node to be a statement list such as BlockStatement.

@ota-meshi
Copy link
Member Author

ota-meshi commented Dec 29, 2018

Thank you for checking!

Please unwrap VOnExpression node if Vue.js doesn't handle it as a statement list.

Is that to build an AST like the following?

code:

<a @click="function(arg){ foo(); }">

AST on v-on:click:

       {
          "type": "VOnExpression",
          "body": [
            {
              "type": "ExpressionStatement",
              "expression": {
                "type": "CallExpression",
                "callee": {
                  "type": "Identifier",
                  "name": "foo"
                },
                "arguments": []
              }
            }
          ]
        }

Do you unwrap in the same way for Arrow Function?
When unwrapping the Arrow Function, AST will be changed.

@ota-meshi
Copy link
Member Author

AST of Arrow Function is now as follows.

code:

<a @click="arg => foo();">
         {
            "type": "VOnExpression",
            "body": [
              {
                "type": "ExpressionStatement",
                "expression": {
                  "type": "ArrowFunctionExpression",
                  "params": [
                    {
                      "type": "Identifier",
                      "name": "arg"
                    }
                  ],
                  "body": {
                    "type": "CallExpression",
                    "callee": {
                      "type": "Identifier",
                      "name": "foo"
                    },
                    "arguments": []
                  }
                }
              }
            ]
          }

@mysticatea
Copy link
Member

mysticatea commented Dec 29, 2018

No. I meant to use parseExpression simply if it's function path or simple path.

For example:

<a @click="function(arg){ foo(); }">
ExpressionContainer > FunctionExpression

<a @click="arg => foo()">
ExpressionContainer > ArrowFunctionExpression

<a @click="foo">
ExpressionContainer > Identifier

<a @click="foo; bar;">
ExpressionContainer > VOnExpression > ExpressionStatement x 2

@ota-meshi
Copy link
Member Author

ota-meshi commented Dec 29, 2018

I got it!

@ota-meshi
Copy link
Member Author

@mysticatea
I changed it. Please check again.

Copy link
Member

@mysticatea mysticatea left a comment

Choose a reason for hiding this comment

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

LGTM, thank you very much!

@mysticatea mysticatea merged commit 4840849 into vuejs:master Dec 31, 2018
@ota-meshi ota-meshi deleted the issue-eslint-plugin-vue716 branch January 3, 2019 01:00
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.

2 participants