Skip to content

Bug: Attributes' value with spread operator is not being parsed #30

Closed
@michalsnik

Description

@michalsnik

I confirmed the following issue: vuejs/eslint-plugin-vue#497

This code:

<input v-on="{ ...$listeners }" />

results in the following AST:

         - type: VAttribute
            directive: true
            key:
              type: VDirectiveKey
              name: on
              argument: null
              modifiers: []
              shorthand: false
              raw:
                name: on
                argument: null
                modifiers: []
            value:
              type: VExpressionContainer
              expression: null
              references: []

Whereas for this:

<input v-on="{ click: action }" />

we get the correct AST with VOnExpression:

         - type: VAttribute
            directive: true
            key:
              type: VDirectiveKey
              name: on
              argument: null
              modifiers: []
              shorthand: false
              raw:
                name: on
                argument: null
                modifiers: []
            value:
              type: VExpressionContainer
              expression:
                type: VOnExpression
                body:
                  - type: BlockStatement
                    body:
                      - type: LabeledStatement
                        body:
                          type: ExpressionStatement
                          expression:
                            type: Identifier
                            name: action
                        label:
                          type: Identifier
                          name: click
              references:
                - id:
                    type: Identifier
                    name: action
                  mode: r

Can we parse objects with spread operators inside attributes' values properly? Same applies to attributes and bindings.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions